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

partman-auto menu reorganisation



I've attached the first stab at reorganising the partman-auto menu into a two level menu.

The first patch shows the changes that I've done to partman-auto and the second patch shows what changes would be necessary to partman-auto-lvm (similar changes would be needed for partman-auto-crypto and partman-auto-raid should it get UI support).

For the impatient, screenshots of level1 and level2 are here:
http://www.hardeman.nu/~david/files/patches/debian/menuone.png
http://www.hardeman.nu/~david/files/patches/debian/menutwo.png

I'm hesitant whether special-casing a return value of 255 as "retry" is the right thing to do, but I couldn't come up with a better solution for supporting both "go back" and errors.

Comments are of course welcome :)

Regards,
David


Index: debian/partman-auto.templates
===================================================================
--- debian/partman-auto.templates	(revision 40144)
+++ debian/partman-auto.templates	(working copy)
@@ -27,6 +27,11 @@
  use the guided partitioning tool, you will still have a chance later to
  review and customise the results.
 
+Template: partman-auto/method
+Type: string
+# Only used for preseeding.
+Description: autopartitioning method to use
+
 Template: partman-auto/disk
 Type: string
 # Only used for preseeding.
@@ -35,7 +40,7 @@
 Template: partman-auto/automatically_partition
 Type: select
 Choices: ${CHOICES}
-_Description: Disk space to partition:
+_Description: Select the partitioning method to use:
 
 Template: partman-auto/choose_recipe
 Type: select
@@ -69,20 +74,27 @@
 Template: partman-auto/text/use_biggest_free
 Type: text
 # TRANSLATORS: This is a menu entry. Keep in under 55 columns/characters
-_Description: Use the largest continuous free space
+_Description: Automatically partition the largest continuous free space
 
-Template: partman-auto/text/use_device
+Template: partman-auto/text/use_some_device
 Type: text
 # TRANSLATORS: This is a menu entry. Keep in under 55 columns/characters
-# The string replacing ${DEVICE} may be very long, so make your translation
-# as short as possible and keep the variable AT THE END
-# for example "Erase entire disk: IDE0 master - Maxtor 46L489"
-_Description: Erase entire disk: ${DEVICE}
+_Description: Automatically partition a disk
 
+Template: partman-auto/use_device
+Type: select
+Choices: ${CHOICES}
+_Description: Select the disk to automatically partition
+
+Template: partman-auto/use_devices
+Type: multiselect
+Choices: ${CHOICES}
+_Description: Select the disk(s) to automatically partition
+
 Template: partman-auto/text/custom_partitioning
 Type: text
 # TRANSLATORS: This is a menu entry. Keep in under 55 columns/characters
-_Description: Manually edit partition table
+_Description: Manually edit partition tables
 
 Template: partman-auto/text/auto_free_space
 Type: text
Index: init.d/initial_auto
===================================================================
--- init.d/initial_auto	(revision 40144)
+++ init.d/initial_auto	(working copy)
@@ -33,28 +33,68 @@
 [ -d /var/lib/partman ] || mkdir /var/lib/partman
 touch /var/lib/partman/initial_auto
 
-# See if any disks to autopartition (either classic or LVM) have been set
+# See if any autopartition method has been set
+method=""
+if db_get_partman-auto/method && [ -n "$RET" ]; then
+	method="$RET"
+fi
+
+# See if any autopartition disks have been set
+disks=""
 if db_get partman-auto/disk && [ -n "$RET" ]; then
 	disks="$RET"
-	for disk in $disks
-	do
-		id=$(dev_to_partman "$disk") || true
-		if [ -n "$id" ]; then
-			autopartition "$id"
-		fi
-	done
-	exit 0
-elif search-path autopartition-lvm && \
-     db_get partman-auto-lvm/disk && [ -n "$RET" ]; then
-	disk="$RET"
-	id=$(dev_to_partman "$disk") || true
-	if [ -n "$id" ]; then
-		autopartition-lvm "$id"
-		exit 0
-	fi
 fi
 
+# If both are set, let's try to do a completely automatic partitioning
+if [ -n "$method" -a -n "$disks" ]; then
+	# The code for the methods could be merged, but in the future non-regular
+	# methods may support multiple disks
+	case "$method" in
+		regular)
+			for disk in $disks; do
+				id=$(dev_to_partman "$disk") || true
+				if [ -n "$id" ]; then
+					autopartition "$id"
+					exit 0
+				fi
+			done
+			exit 1
+			;;
+		lvm)
+			search-path autopartition-lvm || exit 1
+			for disk in $disks; do
+				id=$(dev_to_partman "$disk") || true
+				if [ -n "$id" ]; then
+					autopartition-lvm "$id"
+					exit 0
+				fi
+			done
+			exit 1
+			;;
+		crypto)
+			search-path autopartition-crypto || exit 1
+			for disk in $disks; do
+				id=$(dev_to_partman "$disk") || true
+				if [ -n "$id" ]; then
+					autopartition-crypto "$id"
+					exit 0
+				fi
+			done
+			exit 1
+			;;
+		*)
+			# Unsupported method
+			exit 1
+			;;
+	esac
+fi
+
+# Lets do a manual selection of autopartitioning methods instead
 echo "partman-auto/init_automatically_partition" > /lib/partman/automatically_partition/question
-ask_user /lib/partman/automatically_partition 
-code=$?
+code=255 # 255 signals a retry
+while [ $code = 255 ]; do
+	ask_user /lib/partman/automatically_partition 
+	code=$?
+done
+
 echo "partman-auto/automatically_partition" > /lib/partman/automatically_partition/question
Index: auto-shared.sh
===================================================================
--- auto-shared.sh	(revision 40144)
+++ auto-shared.sh	(working copy)
@@ -181,3 +181,34 @@
     setup_partition $id $*
     free_space=$(partition_after $id)'
 }
+
+get_auto_disks() {
+	DEVS=""
+	
+	for dev in $DEVICES/*; do
+		[ -d "$dev" ] || continue
+
+		ldev=$(device_name $dev)
+		ldev=$(printf "$dev\t$ldev")
+		DEVS="$DEVS
+$ldev"
+	done
+
+	if [ -z "$DEVS" ]; then
+		return 1
+	fi
+	return 0
+}
+
+select_auto_disk() {
+	get_auto_disks || return 1
+	debconf_select critical partman-auto/use_device "$DEVS" "" || return 1
+	return 0
+}
+
+select_auto_disks() {
+	get_auto_disks || return 1
+	debconf_select critical partman-auto/use_devices "$DEVS" "" || return 1
+	return 0
+}
+
Index: automatically_partition/some_device/do_option
===================================================================
--- automatically_partition/some_device/do_option	(revision 40144)
+++ automatically_partition/some_device/do_option	(working copy)
@@ -1,5 +1,8 @@
 #!/bin/sh
 
-dev=$1
+. /lib/partman/definitions.sh
+. /lib/partman/auto-shared.sh
 
-autopartition $dev
+select_auto_disk || exit 255
+
+autopartition $RET
Index: automatically_partition/some_device/choices
===================================================================
--- automatically_partition/some_device/choices	(revision 40144)
+++ automatically_partition/some_device/choices	(working copy)
@@ -2,14 +2,5 @@
 
 . /lib/partman/definitions.sh
 
-mypart=''
-mysize=0
-
-for dev in $DEVICES/*; do
-    [ -d "$dev" ] || continue
-    db_subst partman-auto/text/use_device DEVICE $(device_name $dev)
-    db_metaget partman-auto/text/use_device description
-    printf "$dev\t$RET\n"
-done
-
-
+db_metaget partman-auto/text/use_some_device description
+printf "some_device\t$RET\n"
Index: automatically_partition/_numbers
===================================================================
--- automatically_partition/_numbers	(revision 40144)
+++ automatically_partition/_numbers	(working copy)
@@ -1,3 +1,3 @@
+10 custom
 20 biggest_free
 50 some_device
-80 custom
Index: choose_partition/auto/do_option
===================================================================
--- choose_partition/auto/do_option	(revision 40144)
+++ choose_partition/auto/do_option	(working copy)
@@ -2,5 +2,8 @@
 
 . /lib/partman/definitions.sh
 
-ask_user /lib/partman/automatically_partition || true
-
+code=255
+while [ $code = 255 ]; do
+	ask_user /lib/partman/automatically_partition
+done
+exit $code
Index: automatically_partition/some_device_lvm/do_option
===================================================================
--- automatically_partition/some_device_lvm/do_option	(revision 40144)
+++ automatically_partition/some_device_lvm/do_option	(working copy)
@@ -1,5 +1,8 @@
 #!/bin/sh
 
-dev=$1
+. /lib/partman/definitions.sh
+. /lib/partman/auto-shared.sh
 
-autopartition-lvm $dev
+select_auto_disk || exit 255
+
+autopartition-lvm $RET
Index: automatically_partition/some_device_lvm/choices
===================================================================
--- automatically_partition/some_device_lvm/choices	(revision 40144)
+++ automatically_partition/some_device_lvm/choices	(working copy)
@@ -9,12 +9,5 @@
 	exit 0
 fi
 
-mypart=''
-mysize=0
-
-for dev in $DEVICES/*; do
-	[ -d "$dev" ] || continue
-	db_subst partman-auto-lvm/text/use_device DEVICE $(device_name $dev)
-	db_metaget partman-auto-lvm/text/use_device description
-	printf "$dev\t$RET\n"
-done
+db_metaget partman-auto-lvm/text/use_some_device_lvm description
+printf "some_device_lvm\t$RET\n"
Index: debian/partman-auto-lvm.templates
===================================================================
--- debian/partman-auto-lvm.templates	(revision 40144)
+++ debian/partman-auto-lvm.templates	(working copy)
@@ -1,10 +1,7 @@
-Template: partman-auto-lvm/text/use_device
+Template: partman-auto-lvm/text/use_some_device_lvm
 Type: text
 # TRANSLATORS: This is a menu entry. Keep in under 55 columns/characters
-# The string replacing ${DEVICE} may be very long, so make your translation
-# as short as possible and keep the variable AT THE END
-# for example "Erase entire disk and use LVM: IDE0 master - Maxtor 46L489"
-_Description: Erase entire disk and use LVM: ${DEVICE}
+_Description: Automatically partition a disk using LVM
 
 Template: partman-auto-lvm/new_vg_name
 Type: string
@@ -17,11 +14,6 @@
  The selected volume group name is already in use. Please choose
  another name.
 
-Template: partman-auto-lvm/disk
-Type: string
-# Only used for preseeding.
-Description: device to partition, in either devfs or non format
-
 Template: partman-auto-lvm/unusable_recipe
 Type: error
 _Description: Failed to partition the selected disk

Reply to: