[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[RFC] Using a common template for selecting mount options in partman



Currently each partman udeb that adds support for a file system includes a 
separate template to select mount options. The options offered in this 
template manually need to be kept in sync with the supported mount options.

The attached patch adds a single common template in partman-basicfilesystems 
for which the list of supported mount options is created at run time. The 
file system specific templates are all removed.
It also uses the Choices-C feature, which makes it easier to set defaults.

The main gain from this patch is memory savings because the duplication of 
strings and their translations is avoided (the strings for mount options 
were included up to 7 times).
An indication of the savings in installed size:
partman-basicfilesystems	[-608-] {+604+}
partman-ext3			[-232-] {+184+}
partman-jfs			[-276-] {+240+}
partman-reiserfs		[-240-] {+188+}
partman-xfs			[-228-] {+184+}
partman-ext2r0			similar

There are no actual string changes, so translations are unaffected.

During my tests of the patch I did not see a significant delay in displaying 
the template. It's also not a real concern for D-I as for us any slowdown 
only happens when the question is actually shown.

The reason for the RFC is that on IRC Colin expressed some concern that the 
patch might slow down ubiquity. Because of the Easter weekend I'll delay 
committing the patch until after Tuesday for comments, but IMO a memory 
saving of >200kB is definitely worth slight slowdown.

Cheers,
FJP

commit 64dcf2c56b22f960a6c3cae0c54c9a0b871fa3eb
Author: Frans Pop <fjp@debian.org>
Date:   Thu Mar 20 19:04:44 2008 +0100

    Use common template for selection of file system mount options

diff --git a/packages/partman/partman-basicfilesystems/active_partition/basicfilesystems/do_option b/packages/partman/partman-basicfilesystems/active_partition/basicfilesystems/do_option
index 78c9214..c620734 100755
--- a/packages/partman/partman-basicfilesystems/active_partition/basicfilesystems/do_option
+++ b/packages/partman/partman-basicfilesystems/active_partition/basicfilesystems/do_option
@@ -91,11 +91,7 @@ case $1 in
 	fi
 	;;
     options)
-	if [ "$filesystem" = fat16 ] || [ "$filesystem" = fat32 ]; then
-		select_mountoptions $dev $id partman-basicfilesystems/fatoptions
-	else
-		select_mountoptions $dev $id partman-basicfilesystems/options
-	fi
+	select_mountoptions $dev $id
 	;;
     format_swap)
 	>$part/format
diff --git a/packages/partman/partman-basicfilesystems/debian/partman-basicfilesystems.templates b/packages/partman/partman-basicfilesystems/debian/partman-basicfilesystems.templates
index 84bc442..0d2460d 100644
--- a/packages/partman/partman-basicfilesystems/debian/partman-basicfilesystems.templates
+++ b/packages/partman/partman-basicfilesystems/debian/partman-basicfilesystems.templates
@@ -261,22 +261,76 @@ Template: partman-basicfilesystems/text/options
 Type: text
 _Description: Mount options:
 
-Template: partman-basicfilesystems/options
+Template: partman-basicfilesystems/mountoptions
 Type: multiselect
+Choices-C: ${options}
+Choices: ${descriptions}
 # :sl2:
-# Note to translators : Please keep your translations of the choices
-# below a 65 columns limit (which means 65 characters
-# in single-byte languages)
-__Choices: noatime - do not update inode access times at each access, relatime - update inode access times relative to modify time, nodev - do not support character or block special devices, nosuid - ignore set-user-identifier or set-group-identifier bits, noexec - do not allow execution of any binaries, ro - mount the file system read-only, sync - all input/output activities occur synchronously, usrquota - user disk quota accounting enabled, grpquota - group disk quota accounting enabled, user_xattr - support user extended attributes
 _Description: Mount options:
  Mount options can tune the behavior of the file system.
 
-Template: partman-basicfilesystems/fatoptions
-Type: multiselect
+Template: partman-basicfilesystems/text/noatime
 # :sl2:
-# Note to translators : Please keep your translations of the choices
-# below a 65 columns limit (which means 65 characters
-# in single-byte languages) including the initial path
-__Choices: ro - mount the file system read-only, sync - all input/output activities occur synchronously, quiet - changing owner and permissions does not return errors
-_Description: Mount options:
- Mount options can tune the behavior of the file system.
+# Note to translators: Please keep your translations of this string below
+# a 65 columns limit (which means 65 characters in single-byte languages)
+_Description: noatime - do not update inode access times at each access
+
+Template: partman-basicfilesystems/text/relatime
+# :sl2:
+# Note to translators: Please keep your translations of this string below
+# a 65 columns limit (which means 65 characters in single-byte languages)
+_Description: relatime - update inode access times relative to modify time
+
+Template: partman-basicfilesystems/text/nodev
+# :sl2:
+# Note to translators: Please keep your translations of this string below
+# a 65 columns limit (which means 65 characters in single-byte languages)
+_Description: nodev - do not support character or block special devices
+
+Template: partman-basicfilesystems/text/nosuid
+# :sl2:
+# Note to translators: Please keep your translations of this string below
+# a 65 columns limit (which means 65 characters in single-byte languages)
+_Description: nosuid - ignore set-user-identifier or set-group-identifier bits
+
+Template: partman-basicfilesystems/text/noexec
+# :sl2:
+# Note to translators: Please keep your translations of this string below
+# a 65 columns limit (which means 65 characters in single-byte languages)
+_Description: noexec - do not allow execution of any binaries
+
+Template: partman-basicfilesystems/text/ro
+# :sl2:
+# Note to translators: Please keep your translations of this string below
+# a 65 columns limit (which means 65 characters in single-byte languages)
+_Description: ro - mount the file system read-only
+
+Template: partman-basicfilesystems/text/sync
+# :sl2:
+# Note to translators: Please keep your translations of this string below
+# a 65 columns limit (which means 65 characters in single-byte languages)
+_Description: sync - all input/output activities occur synchronously
+
+Template: partman-basicfilesystems/text/usrquota
+# :sl2:
+# Note to translators: Please keep your translations of this string below
+# a 65 columns limit (which means 65 characters in single-byte languages)
+_Description: usrquota - user disk quota accounting enabled
+
+Template: partman-basicfilesystems/text/grpquota
+# :sl2:
+# Note to translators: Please keep your translations of this string below
+# a 65 columns limit (which means 65 characters in single-byte languages)
+_Description: grpquota - group disk quota accounting enabled
+
+Template: partman-basicfilesystems/text/user_xattr
+# :sl2:
+# Note to translators: Please keep your translations of this string below
+# a 65 columns limit (which means 65 characters in single-byte languages)
+_Description: user_xattr - support user extended attributes
+
+Template: partman-basicfilesystems/text/notail
+# :sl2:
+# Note to translators: Please keep your translations of this string below
+# a 65 columns limit (which means 65 characters in single-byte languages)
+_Description: notail - disable packing of files into the file system tree
diff --git a/packages/partman/partman-basicfilesystems/select_mountoptions b/packages/partman/partman-basicfilesystems/select_mountoptions
index 103ab77..70cceb5 100755
--- a/packages/partman/partman-basicfilesystems/select_mountoptions
+++ b/packages/partman/partman-basicfilesystems/select_mountoptions
@@ -4,21 +4,46 @@
 
 dev=$1
 id=$2
-tpl=$3
+# Backwards compatibility: if $3 is passed and that template exists,
+# use that instead of the new common template
+if [ "$3" ] && db_get $3; then
+	newopt=''; tpl=$3
+else
+	newopt=1;  tpl=partman-basicfilesystems/mountoptions
+fi
 part=$dev/$id
 filesystem=$(cat $part/acting_filesystem)
 
 cd $dev
 
 full_options=''
+all_options=''
+descriptions=''
 for op in $(cat /lib/partman/mountoptions/$filesystem); do
+	if [ "$newopt" ]; then
+		if db_metaget partman-basicfilesystems/text/$op description && \
+		   [ "$RET" ]; then
+			all_options="${all_options:+$all_options, }$op"
+			descriptions="${descriptions:+$descriptions, }$RET"
+		else
+			logger -t partman "Error: no description for mount option $op found; skipping"
+			break
+		fi
+	fi
+
 	if [ -f $part/options/$op ]; then
 		full_options="${full_options:+$full_options,}$(cat $part/options/$op)"
 	fi
 done
+
+if [ "$newopt" ]; then
+	db_subst $tpl options "$all_options"
+	db_subst $tpl descriptions "$descriptions"
+fi
 db_set $tpl "$full_options"
 db_input critical $tpl || true
 db_go || exit
+
 db_get $tpl
 rm -rf $part/options
 mkdir $part/options
diff --git a/packages/partman/partman-ext2r0/active_partition/ext2r0/do_option b/packages/partman/partman-ext2r0/active_partition/ext2r0/do_option
index f7d683a..503577c 100755
--- a/packages/partman/partman-ext2r0/active_partition/ext2r0/do_option
+++ b/packages/partman/partman-ext2r0/active_partition/ext2r0/do_option
@@ -75,7 +75,7 @@ case $1 in
 	update_partition $dev $id
 	;;
     options)
-	select_mountoptions $dev $id partman-ext2r0/options
+	select_mountoptions $dev $id
 	;;
     label)
 	label=''
diff --git a/packages/partman/partman-ext2r0/debian/partman-ext2r0.templates b/packages/partman/partman-ext2r0/debian/partman-ext2r0.templates
index 95bf384..05908bd 100644
--- a/packages/partman/partman-ext2r0/debian/partman-ext2r0.templates
+++ b/packages/partman/partman-ext2r0/debian/partman-ext2r0.templates
@@ -60,16 +60,6 @@ Type: text
 # File system name (untranslatable in many languages)
 _Description: ext2r0
 
-Template: partman-ext2r0/options
-Type: multiselect
-# :sl4:
-# Note to translators : Please keep your translations of the choices
-# below a 65 columns limit (which means 65 characters
-# in single-byte languages)
-__Choices: noatime - do not update inode access times at each access, relatime - update inode access times relative to modify time, nodev - do not support character or block special devices, nosuid - ignore set-user-identifier or set-group-identifier bits, noexec - do not allow execution of any binaries, ro - mount the file system read-only, sync - all input/output activities occur synchronously, usrquota - user disk quota accounting enabled, grpquota - group disk quota accounting enabled
-_Description: Mount options:
- Mount options can tune the behavior of the file system.
-
 Template: partman/filesystem_long/ext2r0
 Type: text
 # :sl4:
diff --git a/packages/partman/partman-ext3/active_partition/ext3/do_option b/packages/partman/partman-ext3/active_partition/ext3/do_option
index 69d529b..ff1e50f 100755
--- a/packages/partman/partman-ext3/active_partition/ext3/do_option
+++ b/packages/partman/partman-ext3/active_partition/ext3/do_option
@@ -18,7 +18,7 @@ case $1 in
 	fi
 	;;
     options)
-	select_mountoptions $dev $id partman-ext3/options
+	select_mountoptions $dev $id
 	;;
     label)
 	label=''
diff --git a/packages/partman/partman-ext3/debian/partman-ext3.templates b/packages/partman/partman-ext3/debian/partman-ext3.templates
index f99f670..80d2fd4 100644
--- a/packages/partman/partman-ext3/debian/partman-ext3.templates
+++ b/packages/partman/partman-ext3/debian/partman-ext3.templates
@@ -42,17 +42,6 @@ Type: text
 # File system name (untranslatable in many languages)
 _Description: ext3
 
-Template: partman-ext3/options
-Type: multiselect
-# :sl2:
-# Note to translators : Please keep your translations of the choices
-# below a 65 columns limit (which means 65 characters
-# in single-byte languages)
-__Choices: noatime - do not update inode access times at each access, relatime - update inode access times relative to modify time, nodev - do not support character or block special devices, nosuid - ignore set-user-identifier or set-group-identifier bits, noexec - do not allow execution of any binaries, ro - mount the file system read-only, sync - all input/output activities occur synchronously, usrquota - user disk quota accounting enabled, grpquota - group disk quota accounting enabled, user_xattr - support user extended attributes
-# :sl2:
-_Description: Mount options:
- Mount options can tune the behavior of the file system.
-
 Template: partman/filesystem_long/ext3
 Type: text
 # :sl2:
diff --git a/packages/partman/partman-jfs/active_partition/jfs/do_option b/packages/partman/partman-jfs/active_partition/jfs/do_option
index 353ce17..a4c6ae4 100755
--- a/packages/partman/partman-jfs/active_partition/jfs/do_option
+++ b/packages/partman/partman-jfs/active_partition/jfs/do_option
@@ -18,7 +18,7 @@ case $1 in
 	fi
 	;;
     options)
-	select_mountoptions $dev $id partman-jfs/options
+	select_mountoptions $dev $id
 	;;
     label)
 	label=''
diff --git a/packages/partman/partman-jfs/debian/partman-jfs.templates b/packages/partman/partman-jfs/debian/partman-jfs.templates
index 8993ae8..1bf58d0 100644
--- a/packages/partman/partman-jfs/debian/partman-jfs.templates
+++ b/packages/partman/partman-jfs/debian/partman-jfs.templates
@@ -42,17 +42,6 @@ Type: text
 # File system name (untranslatable in many languages)
 _Description: jfs
 
-Template: partman-jfs/options
-Type: multiselect
-# Note to translators : Please keep your translations of the choices
-# below a 65 columns limit (which means 65 characters
-# in single-byte languages)
-# :sl2:
-__Choices: noatime - do not update inode access times at each access, relatime - update inode access times relative to modify time, nodev - do not support character or block special devices, nosuid - ignore set-user-identifier or set-group-identifier bits, noexec - do not allow execution of any binaries, ro - mount the file system read-only, sync - all input/output activities occur synchronously
-# :sl2:
-_Description: Mount options:
- Mount options can tune the behavior of the file system.
-
 Template: partman/filesystem_long/jfs
 Type: text
 # File system name
diff --git a/packages/partman/partman-reiserfs/active_partition/reiserfs/do_option b/packages/partman/partman-reiserfs/active_partition/reiserfs/do_option
index b94e8d8..78d4423 100755
--- a/packages/partman/partman-reiserfs/active_partition/reiserfs/do_option
+++ b/packages/partman/partman-reiserfs/active_partition/reiserfs/do_option
@@ -18,7 +18,7 @@ case $1 in
 	fi
 	;;
     options)
-	select_mountoptions $dev $id partman-reiserfs/options
+	select_mountoptions $dev $id
 	;;
     label)
 	label=''
diff --git a/packages/partman/partman-reiserfs/debian/partman-reiserfs.templates b/packages/partman/partman-reiserfs/debian/partman-reiserfs.templates
index db25b78..939ba07 100644
--- a/packages/partman/partman-reiserfs/debian/partman-reiserfs.templates
+++ b/packages/partman/partman-reiserfs/debian/partman-reiserfs.templates
@@ -42,17 +42,6 @@ Type: text
 # File system name (untranslatable in many languages)
 _Description: ReiserFS
 
-Template: partman-reiserfs/options
-Type: multiselect
-# Note to translators : Please keep your translations of the choices
-# below a 65 columns limit (which means 65 characters
-# in single-byte languages)
-# :sl2:
-__Choices: notail - disable packing of files into the file system tree, noatime - do not update inode access times at each access, relatime - update inode access times relative to modify time, nodev - do not support character or block special devices, nosuid - ignore set-user-identifier or set-group-identifier bits, noexec - do not allow execution of any binaries, ro - mount the file system read-only, sync - all input/output activities occur synchronously, usrquota - user disk quota accounting enabled, grpquota - group disk quota accounting enabled, user_xattr - support user extended attributes
-# :sl2:
-_Description: Mount options:
- Mount options can tune the behavior of the file system.
-
 Template: partman/filesystem_long/reiserfs
 Type: text
 # :sl2:
diff --git a/packages/partman/partman-xfs/active_partition/xfs/do_option b/packages/partman/partman-xfs/active_partition/xfs/do_option
index 660aaca..a4c6ae4 100755
--- a/packages/partman/partman-xfs/active_partition/xfs/do_option
+++ b/packages/partman/partman-xfs/active_partition/xfs/do_option
@@ -18,7 +18,7 @@ case $1 in
 	fi
 	;;
     options)
-	select_mountoptions $dev $id partman-xfs/options
+	select_mountoptions $dev $id
 	;;
     label)
 	label=''
diff --git a/packages/partman/partman-xfs/debian/partman-xfs.templates b/packages/partman/partman-xfs/debian/partman-xfs.templates
index 5edbf13..91f4e03 100644
--- a/packages/partman/partman-xfs/debian/partman-xfs.templates
+++ b/packages/partman/partman-xfs/debian/partman-xfs.templates
@@ -42,17 +42,6 @@ Type: text
 # File system name (untranslatable in many languages)
 _Description: xfs
 
-Template: partman-xfs/options
-Type: multiselect
-# Note to translators : Please keep your translations of the choices
-# below a 65 columns limit (which means 65 characters
-# in single-byte languages)
-# :sl2:
-__Choices: noatime - do not update inode access times at each access, relatime - update inode access times relative to modify time, nodev - do not support character or block special devices, nosuid - ignore set-user-identifier or set-group-identifier bits, noexec - do not allow execution of any binaries, ro - mount the file system read-only, sync - all input/output activities occur synchronously, usrquota - user disk quota accounting enabled, grpquota - group disk quota accounting enabled
-# :sl2:
-_Description: Mount options:
- Mount options can tune the behavior of the file system.
-
 Template: partman/filesystem_long/xfs
 Type: text
 # :sl2:

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: