1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#!/bin/sh
. /lib/partman/definitions.sh
. /lib/partman/recipes.sh
dev=$1
if [ -z "$2" ]; then
# Only one parameter. Being run for initial autopartitioning.
[ -f $dev/size ] || exit 1
free_size=$(cat $dev/size)
free_size=$(expr 0000000"$free_size" : '0*\(..*\)......$') # convert to megabytes
choose_recipe "$free_size" || exit $?
cd $dev
open_dialog LABEL_TYPES
types=$(read_list)
close_dialog
label_type=$(default_disk_label)
if ! expr "$types" : ".*${label_type}.*" >/dev/null; then
label_type=msdos # most widely used
fi
if [ "$label_type" = sun ]; then
db_input critical partman/confirm_write_new_label
db_go || exit 0
db_get partman/confirm_write_new_label
if [ "$RET" = false ]; then
db_reset partman/confirm_write_new_label
exit 1
fi
db_reset partman/confirm_write_new_label
fi
open_dialog NEW_LABEL "$label_type"
close_dialog
if [ "$label_type" = sun ]; then
# write the partition table to the disk
disable_swap
open_dialog COMMIT
close_dialog
sync
# reread it from there
open_dialog UNDO
close_dialog
enable_swap
fi
# Different types partition tables support different visuals. Some
# have partition names other don't have, some have extended and
# logical partitions, others don't. Hence we have to regenerate the
# list of the visuals
if [ -f visuals ]; then
rm visuals
fi
free_space=''
open_dialog PARTITIONS
while { read_line num id size type fs path name; [ "$id" ]; }; do
if [ "$fs" = free ]; then
free_space=$id
free_size=$size
fi
done
close_dialog
else
# Two parameters, being run on selected free space.
free_space=$2
cd $dev
open_dialog PARTITION_INFO $free_space
read_line x1 x2 free_size x3 x4 x5 x6
close_dialog
free_size=$(expr 0000000"$free_size" : '0*\(..*\)......$') # convert to megabytes
choose_recipe "$free_size" || exit $?
fi
perform_recipe $dev $free_space $recipe || exit $?
# default to accepting the autopartitioning
menudir_default_choice /lib/partman/choose_partition finish finish || true
|