1.1 --- a/makesd-partition-summary Mon May 27 22:07:36 2019 +0200
1.2 +++ b/makesd-partition-summary Mon May 27 23:58:01 2019 +0200
1.3 @@ -27,7 +27,9 @@
1.4
1.5 emit_partition()
1.6 {
1.7 - echo "${START:--}\t${SIZE:--}\t${TYPE:--}"
1.8 + echo "${START:--}\t${SIZE:--}\t${TYPE:--}\t${BOOTLOADER:--}\t" \
1.9 + "${CONFIG:--}\t${DEVICETREE:--}\t${KERNEL:--}\t${MODULES:--}\t" \
1.10 + "${ROOTFS:--}"
1.11 }
1.12
1.13 # Reset the current partition details.
1.14 @@ -37,6 +39,13 @@
1.15 START=
1.16 SIZE=
1.17 TYPE=
1.18 +
1.19 + BOOTLOADER=
1.20 + CONFIG=
1.21 + DEVICETREE=
1.22 + KERNEL=
1.23 + MODULES=
1.24 + ROOTFS=
1.25 }
1.26
1.27 # Emit the current partition details and proceed to the next partition.
1.28 @@ -49,13 +58,45 @@
1.29 fi
1.30 }
1.31
1.32 +# test_partition <value>
1.33 +#
1.34 +# Test for the presence of the given value, starting a new partition if already
1.35 +# defined.
1.36 +
1.37 +test_partition()
1.38 +{
1.39 + if [ "$1" ] ; then
1.40 + next_partition
1.41 + fi
1.42 +}
1.43 +
1.44 +# replace_in_partition <name> <value>
1.45 +#
1.46 +# Set in the partition the parameter of the given name to value.
1.47 +
1.48 +replace_in_partition()
1.49 +{
1.50 + eval "$1=\"\$2\""
1.51 +}
1.52 +
1.53 +# set_in_partition <name> <value>
1.54 +#
1.55 +# Set the partition parameter of the given name to value, starting a new
1.56 +# partition if necessary.
1.57 +
1.58 +set_in_partition()
1.59 +{
1.60 + eval "test_partition \$$1"
1.61 + replace_in_partition "$1" "$2"
1.62 +}
1.63 +
1.64
1.65
1.66 # Emit the help message if requested.
1.67
1.68 if [ "$1" = '--help' ] ; then
1.69 cat 1>&2 <<EOF
1.70 -Usage: $PROGNAME ( -f <type> | -p <start> | -s <size> )...
1.71 +Usage: $PROGNAME ( -f <type> | -p <start position> | -s <size> )...
1.72
1.73 Produce partition descriptions, indicating partition type, start position and
1.74 size for each partition. Each new occurrence of an active option starts a new
1.75 @@ -73,19 +114,51 @@
1.76
1.77 while [ "$1" ] ; do
1.78 case "$1" in
1.79 +
1.80 + # Partition type, position, size.
1.81 +
1.82 -f )
1.83 - if [ "$TYPE" ] ; then next_partition ; fi
1.84 - TYPE="$2"
1.85 + set_in_partition "TYPE" "$2"
1.86 shift 2
1.87 ;;
1.88 -p )
1.89 - if [ "$START" ] ; then next_partition ; fi
1.90 - START="$2"
1.91 + set_in_partition "START" "$2"
1.92 shift 2
1.93 ;;
1.94 -s )
1.95 - if [ "$SIZE" ] ; then next_partition ; fi
1.96 - SIZE="$2"
1.97 + set_in_partition "SIZE" "$2"
1.98 + shift 2
1.99 + ;;
1.100 +
1.101 + # Bootloader, configuration, device tree, kernel, modules, root
1.102 + # filesystem.
1.103 +
1.104 + -b )
1.105 + replace_in_partition "BOOTLOADER" "$2"
1.106 + shift 2
1.107 + ;;
1.108 + -c )
1.109 + replace_in_partition "CONFIG" "$2"
1.110 + shift 2
1.111 + ;;
1.112 + -dd )
1.113 + # NOTE: To be supported.
1.114 + shift 1
1.115 + ;;
1.116 + -d )
1.117 + replace_in_partition "DEVICETREE" "$2"
1.118 + shift 2
1.119 + ;;
1.120 + -k )
1.121 + replace_in_partition "KERNEL" "$2"
1.122 + shift 2
1.123 + ;;
1.124 + -m )
1.125 + replace_in_partition "MODULES" "$2"
1.126 + shift 2
1.127 + ;;
1.128 + -r )
1.129 + replace_in_partition "ROOTFS" "$2"
1.130 shift 2
1.131 ;;
1.132 * )