# HG changeset patch # User Paul Boddie # Date 1558994281 -7200 # Node ID 31eb4b5f87a546c9ef4c75f26babfb3d1450a928 # Parent 8724710f8bd75b888eabc2cf408a32bb2917d37f Support partition population arguments, generating a broader summary table. diff -r 8724710f8bd7 -r 31eb4b5f87a5 makesd-partition-summary --- a/makesd-partition-summary Mon May 27 22:07:36 2019 +0200 +++ b/makesd-partition-summary Mon May 27 23:58:01 2019 +0200 @@ -27,7 +27,9 @@ emit_partition() { - echo "${START:--}\t${SIZE:--}\t${TYPE:--}" + echo "${START:--}\t${SIZE:--}\t${TYPE:--}\t${BOOTLOADER:--}\t" \ + "${CONFIG:--}\t${DEVICETREE:--}\t${KERNEL:--}\t${MODULES:--}\t" \ + "${ROOTFS:--}" } # Reset the current partition details. @@ -37,6 +39,13 @@ START= SIZE= TYPE= + + BOOTLOADER= + CONFIG= + DEVICETREE= + KERNEL= + MODULES= + ROOTFS= } # Emit the current partition details and proceed to the next partition. @@ -49,13 +58,45 @@ fi } +# test_partition +# +# Test for the presence of the given value, starting a new partition if already +# defined. + +test_partition() +{ + if [ "$1" ] ; then + next_partition + fi +} + +# replace_in_partition +# +# Set in the partition the parameter of the given name to value. + +replace_in_partition() +{ + eval "$1=\"\$2\"" +} + +# set_in_partition +# +# Set the partition parameter of the given name to value, starting a new +# partition if necessary. + +set_in_partition() +{ + eval "test_partition \$$1" + replace_in_partition "$1" "$2" +} + # Emit the help message if requested. if [ "$1" = '--help' ] ; then cat 1>&2 < | -p | -s )... +Usage: $PROGNAME ( -f | -p | -s )... Produce partition descriptions, indicating partition type, start position and size for each partition. Each new occurrence of an active option starts a new @@ -73,19 +114,51 @@ while [ "$1" ] ; do case "$1" in + + # Partition type, position, size. + -f ) - if [ "$TYPE" ] ; then next_partition ; fi - TYPE="$2" + set_in_partition "TYPE" "$2" shift 2 ;; -p ) - if [ "$START" ] ; then next_partition ; fi - START="$2" + set_in_partition "START" "$2" shift 2 ;; -s ) - if [ "$SIZE" ] ; then next_partition ; fi - SIZE="$2" + set_in_partition "SIZE" "$2" + shift 2 + ;; + + # Bootloader, configuration, device tree, kernel, modules, root + # filesystem. + + -b ) + replace_in_partition "BOOTLOADER" "$2" + shift 2 + ;; + -c ) + replace_in_partition "CONFIG" "$2" + shift 2 + ;; + -dd ) + # NOTE: To be supported. + shift 1 + ;; + -d ) + replace_in_partition "DEVICETREE" "$2" + shift 2 + ;; + -k ) + replace_in_partition "KERNEL" "$2" + shift 2 + ;; + -m ) + replace_in_partition "MODULES" "$2" + shift 2 + ;; + -r ) + replace_in_partition "ROOTFS" "$2" shift 2 ;; * )