Following conversations on IRC with joeyh and Kamion, I've redone the
patch so that the menu layout changes can be kept to a bare minimum.
The updated patch is attached, to see the menu in action:
http://www.hardeman.nu/~david/files/patches/debian/menuone-v2.png
http://www.hardeman.nu/~david/files/patches/debian/menutwo-v2.png
It would be nice to get some reviews of the patch soonish so that it can
be committed and given a thorough testing before RC1...unless I hear
something to the contrary, Ḯ'll probably commit this before the end of
the week.
Regards,
David
Index: partman-auto-lvm/automatically_partition/some_device_lvm/do_option
===================================================================
--- partman-auto-lvm/automatically_partition/some_device_lvm/do_option
(revision 40340)
+++ partman-auto-lvm/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
+disk=$(select_auto_disk) || exit 255
+
+autopartition-lvm "$disk"
Index: partman-auto-lvm/automatically_partition/some_device_lvm/choices
===================================================================
--- partman-auto-lvm/automatically_partition/some_device_lvm/choices
(revision 40340)
+++ partman-auto-lvm/automatically_partition/some_device_lvm/choices
(working copy)
@@ -9,18 +9,5 @@
exit 0
fi
-mypart=''
-mysize=0
-
-for dev in $DEVICES/*; do
- [ -d "$dev" ] || continue
-
- # Skip /dev/mapper/X and /dev/mdX devices
- device=$(cat $dev/device)
- $(echo "$device" | grep -q "/dev/md[0-9]*$") && continue
- $(echo "$device" | grep -q "/dev/mapper/") && 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/choice description
+printf "lvm\t$RET\n"
Index: partman-auto-lvm/debian/partman-auto-lvm.templates
===================================================================
--- partman-auto-lvm/debian/partman-auto-lvm.templates (revision 40340)
+++ partman-auto-lvm/debian/partman-auto-lvm.templates (working copy)
@@ -1,10 +1,7 @@
-Template: partman-auto-lvm/text/use_device
+Template: partman-auto-lvm/text/choice
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 setup 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
Index: partman-auto/debian/partman-auto.templates
===================================================================
--- partman-auto/debian/partman-auto.templates (revision 40340)
+++ partman-auto/debian/partman-auto.templates (working copy)
@@ -50,7 +50,7 @@
Template: partman-auto/automatically_partition
Type: select
Choices: ${CHOICES}
-_Description: Disk space to partition:
+_Description: Partitioning method:
Template: partman-auto/choose_recipe
Type: select
@@ -94,6 +94,16 @@
# for example "Erase entire disk: IDE0 master - Maxtor 46L489"
_Description: Erase entire disk: ${DEVICE}
+Template: partman-auto/select_disk
+Type: select
+Choices: ${CHOICES}
+_Description: Select disk to partition:
+
+Template: partman-auto/select_disks
+Type: multiselect
+Choices: ${CHOICES}
+_Description: Select disk(s) to partition:
+
Template: partman-auto/text/custom_partitioning
Type: text
# TRANSLATORS: This is a menu entry. Keep in under 55 columns/characters
Index: partman-auto/init.d/initial_auto
===================================================================
--- partman-auto/init.d/initial_auto (revision 40340)
+++ partman-auto/init.d/initial_auto (working copy)
@@ -33,28 +33,66 @@
[ -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" ] && [ -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
+
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: partman-auto/auto-shared.sh
===================================================================
--- partman-auto/auto-shared.sh (revision 40340)
+++ partman-auto/auto-shared.sh (working copy)
@@ -265,3 +265,31 @@
setup_partition $id $*
free_space=$(partition_after $id)'
}
+
+get_auto_disks() {
+ local dev device
+
+ for dev in $DEVICES/*; do
+ [ -d "$dev" ] || continue
+
+ # Skip /dev/mapper/X and /dev/mdX devices
+ device=$(cat $dev/device)
+ $(echo "$device" | grep -q "/dev/md[0-9]*$") && continue
+ $(echo "$device" | grep -q "/dev/mapper/") && continue
+
+ printf "$dev\t$(device_name $dev)\n"
+ done
+}
+
+select_auto_disk() {
+ local DEVS
+
+ DEVS=$(get_auto_disks)
+ [ -n "$DEVS" ] || return 1
+ debconf_select critical partman-auto/select_disk "$DEVS" "" || return 1
+ echo "$RET"
+ return 0
+}
+
+# TODO: Add a select_auto_disks() function
+# Note: This needs a debconf_multiselect equiv.
Index: partman-auto/automatically_partition/_numbers
===================================================================
--- partman-auto/automatically_partition/_numbers (revision 40340)
+++ partman-auto/automatically_partition/_numbers (working copy)
@@ -1,3 +1,3 @@
+10 custom
20 biggest_free
50 some_device
-80 custom
Index: partman-auto/choose_partition/auto/do_option
===================================================================
--- partman-auto/choose_partition/auto/do_option (revision 40340)
+++ partman-auto/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