1.1 --- a/makesd-partition-table Fri May 24 18:27:02 2019 +0200
1.2 +++ b/makesd-partition-table Fri May 24 20:24:34 2019 +0200
1.3 @@ -75,7 +75,7 @@
1.4 # Alternatively, use previous start and size information.
1.5 # Otherwise, the first partition is being defined.
1.6
1.7 - if [ "$START" ] ; then
1.8 + if [ "$START" ] && [ "$START" != '-' ] ; then
1.9 PREVSTART=`align_cylinder $START`
1.10 elif [ "$PREVSTART" ] && [ "$PREVSIZE" ] ; then
1.11 PREVSTART=`align_cylinder $(($PREVSTART + $PREVSIZE))`
1.12 @@ -92,7 +92,7 @@
1.13 # Calculate and align the stated size.
1.14 # Otherwise, defer the calculation until emitting the details.
1.15
1.16 - if [ "$SIZE" ] ; then
1.17 + if [ "$SIZE" ] && [ "$SIZE" != '-' ] ; then
1.18 PREVSIZE=$(($SIZE * $DEVSIZE / 100))
1.19 PREVSIZE=`align_cylinder $PREVSIZE`
1.20
1.21 @@ -106,24 +106,12 @@
1.22 PREVTYPE=$TYPE
1.23 }
1.24
1.25 -# Reset the current partition details.
1.26 -
1.27 -reset_partition()
1.28 -{
1.29 - START=
1.30 - SIZE=
1.31 - TYPE=
1.32 -}
1.33 -
1.34 # Emit the current partition details and proceed to the next partition.
1.35
1.36 next_partition()
1.37 {
1.38 - if [ "$START" ] || [ "$SIZE" ] || [ "$TYPE" ] ; then
1.39 - emit_partition
1.40 - store_partition
1.41 - reset_partition
1.42 - fi
1.43 + emit_partition
1.44 + store_partition
1.45 }
1.46
1.47 # Convert the partition type to an sdisk-compatible identifier.
1.48 @@ -187,6 +175,19 @@
1.49
1.50
1.51
1.52 +# Process the arguments, building a partition description.
1.53 +
1.54 +read_fields()
1.55 +{
1.56 + OLDIFS=$IFS
1.57 + IFS=`echo -n '\t'` read START SIZE TYPE
1.58 + STATUS=$?
1.59 + IFS=$OLDIFS
1.60 + return $STATUS
1.61 +}
1.62 +
1.63 +
1.64 +
1.65 # Emit the help message if requested.
1.66
1.67 if [ "$1" = '--help' ] ; then
1.68 @@ -241,37 +242,10 @@
1.69
1.70 init_sfdisk "$DEV"
1.71
1.72 -# Process the arguments, building a partition description.
1.73 -
1.74 -reset_partition
1.75 -
1.76 -while [ "$1" ] ; do
1.77 - case "$1" in
1.78 - -f )
1.79 - if [ "$TYPE" ] ; then next_partition ; fi
1.80 - TYPE="$2"
1.81 - shift 2
1.82 - ;;
1.83 - -p )
1.84 - if [ "$START" ] ; then next_partition ; fi
1.85 - START="$2"
1.86 - shift 2
1.87 - ;;
1.88 - -s )
1.89 - if [ "$SIZE" ] ; then next_partition ; fi
1.90 - SIZE="$2"
1.91 - shift 2
1.92 - ;;
1.93 - * )
1.94 - shift 1
1.95 - ;;
1.96 - esac
1.97 +while read_fields ; do
1.98 + next_partition
1.99 done
1.100
1.101 -# Terminate any unfinished partition, emitting the previous partition.
1.102 -
1.103 -next_partition
1.104 -
1.105 # Emit the last partition.
1.106
1.107 emit_partition