remakesd

Changeset

21:eeb7bcd53897
2019-06-10 Paul Boddie raw files shortlog changelog graph Switched to a more structured system definition format. Eliminated partition summaries since the expanded definitions together with the filtering of definitions make such summaries largely redundant.
docs/COPYING.txt (file) makesd (file) makesd-common (file) makesd-defs (file) makesd-expand-def (file) makesd-filter-def (file) makesd-format (file) makesd-partition-summary makesd-partition-table (file)
     1.1 --- a/docs/COPYING.txt	Tue May 28 00:30:18 2019 +0200
     1.2 +++ b/docs/COPYING.txt	Mon Jun 10 01:37:46 2019 +0200
     1.3 @@ -19,9 +19,9 @@
     1.4  Licence Details for makesd-defs
     1.5  -------------------------------
     1.6  
     1.7 -The makesd-defs file is extracted from the original makesd tool, modified to
     1.8 -work with the makesd-expand-def script. The following applies to the original
     1.9 -content:
    1.10 +The makesd-defs file is based on content extracted from the original makesd
    1.11 +tool, modified to work with the makesd-expand-def script. The following
    1.12 +applies to the original content:
    1.13  
    1.14  (c) Golden Delicious Comp. GmbH&Co. KG, 2014-2018
    1.15  Licenced under GPLv2
     2.1 --- a/makesd	Tue May 28 00:30:18 2019 +0200
     2.2 +++ b/makesd	Mon Jun 10 01:37:46 2019 +0200
     2.3 @@ -23,8 +23,8 @@
     2.4  COMMON="$THISDIR/makesd-common"
     2.5  DEFS="$THISDIR/makesd-defs"
     2.6  EXPAND="$THISDIR/makesd-expand-def"
     2.7 +FILTER="$THISDIR/makesd-filter-def"
     2.8  FORMAT="$THISDIR/makesd-format"
     2.9 -PARTSUMMARY="$THISDIR/makesd-partition-summary"
    2.10  PARTITION="$THISDIR/makesd-partition"
    2.11  
    2.12  . "$COMMON"
    2.13 @@ -35,16 +35,15 @@
    2.14  
    2.15  if [ "$1" = '--help' ] ; then
    2.16      cat 1>&2 <<EOF
    2.17 -Usage: $PROGNAME [ --align ] <definition name>
    2.18 +Usage: $PROGNAME [ --align ] <system>
    2.19         $PROGNAME -a | --all | --defs
    2.20  
    2.21  Partition, format, populate and initialise a device for use with a particular
    2.22 -kind of hardware. The given definition name is used to search the database of
    2.23 +kind of hardware. The given system name is used to search the database of
    2.24  supported hardware devices and to configure the different preparation
    2.25  activities.
    2.26  
    2.27 -If the -a, --all or --defs options are specified, all hardware definitions are
    2.28 -emitted and no further actions are taken.
    2.29 +$(show_definitions_description)
    2.30  
    2.31  $(align_cylinder_description)
    2.32  EOF
    2.33 @@ -54,7 +53,7 @@
    2.34  # Test for the definition output options.
    2.35  
    2.36  if [ "$1" = '-a' ] || [ "$1" = '--all' ] || [ "$1" = '--defs' ] ; then
    2.37 -    grep '^[[:alpha:]]' "$DEFS" | cut -f1 | sort
    2.38 +    "$EXPAND" "$1"
    2.39      exit 0
    2.40  fi
    2.41  
    2.42 @@ -62,8 +61,6 @@
    2.43  
    2.44  check_device
    2.45  
    2.46 -SUMMARY="`basename "$DEV"`.summary"
    2.47 -
    2.48  # Test for the cylinder alignment option.
    2.49  
    2.50  if test_align_cylinder $* ; then shift 1 ; fi
    2.51 @@ -79,28 +76,14 @@
    2.52      exit 1
    2.53  fi
    2.54  
    2.55 -shift 1
    2.56 -
    2.57 -# Expand the definition to partitioning options.
    2.58 -
    2.59 -if ! ARGS=`"$EXPAND" "$DEF"` ; then
    2.60 -    cat 1>&2 <<EOF
    2.61 -Device definition not found: $DEF
    2.62 -EOF
    2.63 -    exit 1
    2.64 -fi
    2.65 -
    2.66 -# Use the options to generate a partition summary.
    2.67 -
    2.68 -  "$PARTSUMMARY" $ARGS \
    2.69 -> "$SUMMARY"
    2.70 -
    2.71  # Partition the given device, passing only partition details to the script.
    2.72  
    2.73 -  cut -f 1,2,3 "$SUMMARY" \
    2.74 +  "$EXPAND" "$DEF" \
    2.75 +| "$FILTER" "partition" "position" "size" "type" \
    2.76  | "$PARTITION" $ALIGN_CYLINDER
    2.77  
    2.78  # Format the given device, passing only partition types to the script.
    2.79  
    2.80 -  cut -f 3 "$SUMMARY" \
    2.81 +  "$EXPAND" "$DEF" \
    2.82 +| "$FILTER" "partition" "type" \
    2.83  | "$FORMAT"
     3.1 --- a/makesd-common	Tue May 28 00:30:18 2019 +0200
     3.2 +++ b/makesd-common	Mon Jun 10 01:37:46 2019 +0200
     3.3 @@ -36,11 +36,101 @@
     3.4      fi
     3.5  }
     3.6  
     3.7 -# Process partition field values in summary tables.
     3.8 +# filter <type> [ <property> ... ]
     3.9 +#
    3.10 +# Filter input, preserving only sections with the given type, preserving only
    3.11 +# the given properties if indicated.
    3.12 +
    3.13 +filter()
    3.14 +{
    3.15 +    local FIELD LINE PROPERTY SECTION TYPE
    3.16 +
    3.17 +    TYPE=$1
    3.18 +    SECTION=
    3.19 +
    3.20 +    shift 1
    3.21 +
    3.22 +    while read LINE ; do
    3.23 +
    3.24 +        # Start a new section if appropriate.
    3.25 +
    3.26 +        if [ "$LINE" ] && [ ! "$SECTION" ] ; then
    3.27 +            SECTION=`echo "$LINE" | cut -d' ' -f1`
    3.28 +
    3.29 +            # Produce suitable section headers.
    3.30 +
    3.31 +            if [ "$SECTION" = "$TYPE" ] ; then
    3.32 +                echo "$LINE"
    3.33 +            fi
    3.34 +
    3.35 +            continue
    3.36 +        fi
    3.37 +
    3.38 +        # Produce lines from any suitable section including any blank line.
    3.39 +
    3.40 +        if [ "$SECTION" = "$TYPE" ] ; then
    3.41 +
    3.42 +            # Select appropriate properties if indicated.
    3.43 +
    3.44 +            if [ "$LINE" ] && [ "$1" ] ; then
    3.45 +                FIELD=`echo "$LINE" | cut -d: -f1`
    3.46 +
    3.47 +                for PROPERTY in $* ; do
    3.48 +                    if [ "$PROPERTY" = "$FIELD" ] ; then
    3.49 +                        echo "$LINE"
    3.50 +                        break
    3.51 +                    fi
    3.52 +                done
    3.53 +
    3.54 +            # Otherwise, select all properties.
    3.55  
    3.56 -read_fields()
    3.57 +            else
    3.58 +                echo "$LINE"
    3.59 +            fi
    3.60 +        fi
    3.61 +
    3.62 +        # End sections on blank lines.
    3.63 +
    3.64 +        if [ ! "$LINE" ] ; then
    3.65 +            SECTION=
    3.66 +        fi
    3.67 +    done
    3.68 +}
    3.69 +
    3.70 +# get_field <string>
    3.71 +#
    3.72 +# Emit the field name of a property definition.
    3.73 +
    3.74 +get_field()
    3.75  {
    3.76 -    IFS=`echo -n '\t'` read START SIZE TYPE
    3.77 +    echo "$1" | cut -d: -f1
    3.78 +}
    3.79 +
    3.80 +# get_value <string>
    3.81 +#
    3.82 +# Emit the value of a property definition.
    3.83 +
    3.84 +get_value()
    3.85 +{
    3.86 +    echo "$1" | cut -d: -f2 | sed 's/^\s*//'
    3.87 +}
    3.88 +
    3.89 +# search <string> <file>
    3.90 +#
    3.91 +# Search for the given string in the input, returning the line number.
    3.92 +
    3.93 +search()
    3.94 +{
    3.95 +    grep -h -n "$1" "$2" | cut -d: -f1
    3.96 +}
    3.97 +
    3.98 +# set_value <name> <value>
    3.99 +#
   3.100 +# Set the parameter of the given name to value.
   3.101 +
   3.102 +set_value()
   3.103 +{
   3.104 +    eval "$1=\"\$2\""
   3.105  }
   3.106  
   3.107  # test_align_cylinder <args>
   3.108 @@ -58,6 +148,8 @@
   3.109      fi
   3.110  }
   3.111  
   3.112 +# Common messages.
   3.113 +
   3.114  align_cylinder_description()
   3.115  {
   3.116      cat <<EOF
   3.117 @@ -66,3 +158,11 @@
   3.118  and sectors.
   3.119  EOF
   3.120  }
   3.121 +
   3.122 +show_definitions_description()
   3.123 +{
   3.124 +    cat <<EOF
   3.125 +If the -a, --all or --defs options are specified, all hardware definitions are
   3.126 +emitted and no further actions are taken.
   3.127 +EOF
   3.128 +}
     4.1 --- a/makesd-defs	Tue May 28 00:30:18 2019 +0200
     4.2 +++ b/makesd-defs	Mon Jun 10 01:37:46 2019 +0200
     4.3 @@ -1,87 +1,687 @@
     4.4 -# single partition file system(s) - should boot if boot loader is in flash/eMMC
     4.5 -debian			-f ext4 -r debian -kboot latest -dboot latest -m latest -c latest
     4.6 -lxde			$debian -r lxde
     4.7 -xfce			$debian -r xfce
     4.8 -quantumstep		$debian -r quantumstep
     4.9 -qtmoko			$debian -c none -r qtmoko
    4.10 -replicant		$debian -k none -d none -m none -c none -r replicant
    4.11 -pyraos			$debian -c none -r pyraos
    4.12 -phosh			$debian -r phosh
    4.13 -all 			$lxde $qtmoko $replicant $quantumstep
    4.14 -all2 			$xfce $qtmoko $phosh $quantumstep
    4.15 +# single partition systems - should boot if bootloader is in flash/eMMC
    4.16 +
    4.17 +partition debian
    4.18 +type: ext4
    4.19 +root: debian
    4.20 +kernel: [boot] latest
    4.21 +devices: [boot] latest
    4.22 +modules: latest
    4.23 +config: latest
    4.24 +
    4.25 +partition lxde
    4.26 +adapts: debian
    4.27 +root: lxde
    4.28 +
    4.29 +partition xfce
    4.30 +adapts: debian
    4.31 +root: xfce
    4.32 +
    4.33 +partition quantumstep
    4.34 +adapts: debian
    4.35 +root: quantumstep
    4.36 +
    4.37 +partition qtmoko
    4.38 +adapts: debian
    4.39 +config: none
    4.40 +root: qtmoko
    4.41 +
    4.42 +partition replicant
    4.43 +type: ext4
    4.44 +root: replicant
    4.45 +
    4.46 +partition pyraos
    4.47 +adapts: debian
    4.48 +config: none
    4.49 +root: pyraos
    4.50 +
    4.51 +partition phosh
    4.52 +adapts: debian
    4.53 +root: phosh
    4.54 +
    4.55 +# multiple partition systems
    4.56 +
    4.57 +system all
    4.58 +partition: lxde
    4.59 +partition: qtmoko
    4.60 +partition: replicant
    4.61 +partition: quantumstep
    4.62 +
    4.63 +system all2
    4.64 +partition: xfce
    4.65 +partition: qtmoko
    4.66 +partition: phosh
    4.67 +partition: quantumstep
    4.68  
    4.69  # production images (dual partition) for specific devices
    4.70 -gta04			-f fat -s 5 -b GTA04/latest -k latest -d latest $lxde -k none -d none -s 95
    4.71 -l2804			$gta04
    4.72 -gta04one		-f fat -s 5 -b GTA04-OneNAND/latest -k latest -d latest $lxde -k none -d none -s 95
    4.73 -gta04a5			$gta04one
    4.74 -l2804a5			$gta04one
    4.75 -gta04b2			-f fat -s 5 -b Letux-3704/latest -k latest -d latest $lxde -k none -d none -s 95
    4.76 -l3704			$gta04b2
    4.77 -gta04b3			-f fat -s 5 -b Letux-7004/latest -k latest -d latest $lxde -k none -d none -s 95
    4.78 -l7004			$gta04b3
    4.79 -gta04b7			-f fat -s 5 -b Neo900/latest -k latest -d latest $lxde -k none -d none -s 95
    4.80 -neo900			$gta04b7
    4.81 -bb			-f fat -s 5 -b Letux-BeagleBoard/latest -k latest -d latest $lxde -k none -d none -s 95
    4.82 -beagleboard		$bb
    4.83 -bbb			-f fat -s 5 -b Letux-BeagleBone-Black/latest -k latest -d latest $lxde -k none -d none -s 95
    4.84 -lc8			-f fat -s 5 -b Letux-Cortex-8/latest -k latest -d latest $lxde -k none -d none -s 95
    4.85 -pocketbeagle		$lc8
    4.86 -bb+b1			-f fat -s 5 -b OpenMoko-Beagle-Hybrid/latest -k latest -d latest $lxde -k none -d none -s 95
    4.87 -bb+b2			-f fat -s 5 -b Openmoko-Beagle-Hybrid-b2/latest -k latest -d latest $lxde -k none -d none -s 95
    4.88 -bb+b4			-f fat -s 5 -b Openmoko-Beagle-Hybrid-b4/latest -k latest -d latest $lxde -k none -d none -s 95
    4.89 -bb+b7			-f fat -s 5 -b BeagleBoard-Neo900/latest -k latest -d latest $lxde -k none -d none -s 95
    4.90 -panda-es		-f fat -s 5 -b PandaBoard-ES/latest -k latest -d latest $lxde -k none -d none -s 95
    4.91 -omap5432evm		-f fat -s 5 -b OMAP5-uEVM/latest -k latest -d latest $lxde -k none -d none -s 95
    4.92 -omap5432evm+pyra	-f fat -s 5 -b OMAP5-uEVM+Pyra4.9/latest -k latest -d latest $lxde -k none -d none -s 95
    4.93 -pyra+lc15		-f fat -s 5 -b Pyra+LC15/latest -k latest -d latest $lxde -k none -d none -s 95
    4.94 -pyra+lc15-4.9		-f fat -s 5 -b Pyra+LC15-4.9/latest -k latest -d latest $lxde -k none -d none -s 95
    4.95 -pyra+lc15-4gb		-f fat -s 5 -b Pyra+LC15-4GB/latest -k latest-lpae -d latest-lpae $lxde -m latest-lpae -k none -d none -s 95
    4.96 -pyra			$pyra+lc15 -r $pyraos
    4.97 -pyra-$lxde		$pyra+lc15 -r $lxde
    4.98 -pyra-4gb		$pyra+lc15-4gb -r $pyraos
    4.99 -lc15			-f fat -s 5 -b Letux-Cortex-15/latest -k latest -d latest $lxde -k none -d none -s 95
   4.100 -lc15-4.9		-f fat -s 5 -b Letux-Cortex-15-4.9/latest -k latest -d latest $lxde -k none -d none -s 95
   4.101 -lc15-4gb		-f fat -s 5 -b Letux-Cortex-15-4GB/latest -k latest-lpae -d latest-lpae $lxde -k none -d none -m latest-lpae -s 95
   4.102 -lc15evm			-f fat -s 5 -b Letux-Cortex-15-EVM/latest -k latest -d latest $lxde -k none -d none -s 95
   4.103 -lc15evm-4gb		-f fat -s 5 -b Letux-Cortex-15-EVM-4GB/latest -k latest -d latest $lxde -k none -d none -s 95
   4.104 -gta15			-f fat -s 5 -b GTA15/latest -k latest -d latest $lxde -k none -d none -s 95
   4.105 -gta15-4gb		-f fat -s 5 -b GTA15-4GB/latest -k latest -d latest $lxde -k none -d none -s 95
   4.106 -pyraphone		$gta15
   4.107 +
   4.108 +partition gta04-boot
   4.109 +type: fat
   4.110 +size: 5
   4.111 +bootloader: GTA04/latest
   4.112 +kernel: latest
   4.113 +devices: latest
   4.114 +
   4.115 +partition gta04-root
   4.116 +adapts: lxde
   4.117 +kernel: none
   4.118 +devices: none
   4.119 +size: 95
   4.120 +
   4.121 +system gta04
   4.122 +partition: gta04-boot
   4.123 +partition: gta04-root
   4.124 +
   4.125 +system l2804
   4.126 +adapts: gta04
   4.127 +
   4.128 +partition gta04one-boot
   4.129 +type: fat
   4.130 +size: 5
   4.131 +bootloader: GTA04-OneNAND/latest
   4.132 +kernel: latest
   4.133 +devices: latest
   4.134 +
   4.135 +partition gta04-one-root
   4.136 +adapts: lxde
   4.137 +kernel: none
   4.138 +devices: none
   4.139 +size: 95
   4.140 +
   4.141 +system gta04one
   4.142 +partition: gta04-one-boot
   4.143 +partition: gta04-one-root
   4.144 +
   4.145 +system gta04a5
   4.146 +adapts: gta04one
   4.147 +
   4.148 +system l2804a5
   4.149 +adapts: gta04one
   4.150 +
   4.151 +partition gta04b2-boot
   4.152 +type: fat
   4.153 +size: 5
   4.154 +bootloader: Letux-3704/latest
   4.155 +kernel: latest
   4.156 +devices: latest
   4.157 +
   4.158 +partition gta04b2-root
   4.159 +adapts: lxde
   4.160 +kernel: none
   4.161 +devices: none
   4.162 +size: 95
   4.163 +
   4.164 +system gta04b2
   4.165 +partition: gta04b2-boot
   4.166 +partition: gta04b2-root
   4.167 +
   4.168 +system l3704
   4.169 +adapts: gta04b2
   4.170 +
   4.171 +partition gta04b3-boot
   4.172 +type: fat
   4.173 +size: 5
   4.174 +bootloader: Letux-7004/latest
   4.175 +kernel: latest
   4.176 +devices: latest
   4.177 +
   4.178 +partition gta04b3-root
   4.179 +adapts: lxde
   4.180 +kernel: none
   4.181 +devices: none
   4.182 +size: 95
   4.183 +
   4.184 +system gta04b3
   4.185 +partition: gta04b3-boot
   4.186 +partition: gta04b3-root
   4.187 +
   4.188 +system l7004
   4.189 +adapts: gta04b3
   4.190 +
   4.191 +partition gta04b7-boot
   4.192 +type: fat
   4.193 +size: 5
   4.194 +bootloader: Neo900/latest
   4.195 +kernel: latest
   4.196 +devices: latest
   4.197 +
   4.198 +partition gta04b7-root
   4.199 +adapts: lxde
   4.200 +kernel: none
   4.201 +devices: none
   4.202 +size: 95
   4.203 +
   4.204 +system gta04b7
   4.205 +partition: gta04b7-boot
   4.206 +partition: gta04b7-root
   4.207 +
   4.208 +system neo900
   4.209 +adapts: gta04b7
   4.210 +
   4.211 +partition bb-boot
   4.212 +type: fat
   4.213 +size: 5
   4.214 +bootloader: Letux-BeagleBoard/latest
   4.215 +kernel: latest
   4.216 +devices: latest
   4.217 +
   4.218 +partition bb-root
   4.219 +adapts: lxde
   4.220 +kernel: none
   4.221 +devices: none
   4.222 +size: 95
   4.223 +
   4.224 +system bb
   4.225 +partition: bb-boot
   4.226 +partition: bb-root
   4.227 +
   4.228 +system beagleboard
   4.229 +adapts: bb
   4.230 +
   4.231 +partition bbb-boot
   4.232 +type: fat
   4.233 +size: 5
   4.234 +bootloader: Letux-BeagleBone-Black/latest
   4.235 +kernel: latest
   4.236 +devices: latest
   4.237 +
   4.238 +partition bbb-root
   4.239 +adapts: lxde
   4.240 +kernel: none
   4.241 +devices: none
   4.242 +size: 95
   4.243 +
   4.244 +system bbb
   4.245 +partition: bbb-boot
   4.246 +partition: bbb-root
   4.247 +
   4.248 +partition lc8-boot
   4.249 +type: fat
   4.250 +size: 5
   4.251 +bootloader: Letux-Cortex-8/latest
   4.252 +kernel: latest
   4.253 +devices: latest
   4.254 +
   4.255 +partition lc8-root
   4.256 +adapts: lxde
   4.257 +kernel: none
   4.258 +devices: none
   4.259 +size: 95
   4.260 +
   4.261 +system lc8
   4.262 +partition: lc8-boot
   4.263 +partition: lc8-root
   4.264 +
   4.265 +system pocketbeagle
   4.266 +adapts: lc8
   4.267 +
   4.268 +partition bb+b1-boot
   4.269 +type: fat
   4.270 +size: 5
   4.271 +bootloader: OpenMoko-Beagle-Hybrid/latest
   4.272 +kernel: latest
   4.273 +devices: latest
   4.274 +
   4.275 +partition bb+b1-root
   4.276 +adapts: lxde
   4.277 +kernel: none
   4.278 +devices: none
   4.279 +size: 95
   4.280 +
   4.281 +system bb+b1
   4.282 +partition: bb+b1-boot
   4.283 +partition: bb+b1-root
   4.284 +
   4.285 +partition bb+b2-boot
   4.286 +type: fat
   4.287 +size: 5
   4.288 +bootloader: Openmoko-Beagle-Hybrid-b2/latest
   4.289 +kernel: latest
   4.290 +devices: latest
   4.291 +
   4.292 +partition bb+b2-root
   4.293 +adapts: lxde
   4.294 +kernel: none
   4.295 +devices: none
   4.296 +size: 95
   4.297 +
   4.298 +system bb+b2
   4.299 +partition: bb+b2-boot
   4.300 +partition: bb+b2-root
   4.301 +
   4.302 +partition bb+b4-boot
   4.303 +type: fat
   4.304 +size: 5
   4.305 +bootloader: Openmoko-Beagle-Hybrid-b4/latest
   4.306 +kernel: latest
   4.307 +devices: latest
   4.308 +
   4.309 +partition bb+b4-root
   4.310 +adapts: lxde
   4.311 +kernel: none
   4.312 +devices: none
   4.313 +size: 95
   4.314 +
   4.315 +system bb+b4
   4.316 +partition: bb+b4-boot
   4.317 +partition: bb+b4-root
   4.318 +
   4.319 +partition bb+b7-boot
   4.320 +type: fat
   4.321 +size: 5
   4.322 +bootloader: BeagleBoard-Neo900/latest
   4.323 +kernel: latest
   4.324 +devices: latest
   4.325 +
   4.326 +partition bb+b7-root
   4.327 +adapts: lxde
   4.328 +kernel: none
   4.329 +devices: none
   4.330 +size: 95
   4.331 +
   4.332 +system bb+b7
   4.333 +partition: bb+b7-boot
   4.334 +partition: bb+b7-root
   4.335 +
   4.336 +partition panda-es-boot
   4.337 +type: fat
   4.338 +size: 5
   4.339 +bootloader: PandaBoard-ES/latest
   4.340 +kernel: latest
   4.341 +devices: latest
   4.342 +
   4.343 +partition panda-es-root
   4.344 +adapts: lxde
   4.345 +kernel: none
   4.346 +devices: none
   4.347 +size: 95
   4.348 +
   4.349 +system panda-es
   4.350 +partition: panda-es-boot
   4.351 +partition: panda-es-root
   4.352 +
   4.353 +partition omap5432evm-boot
   4.354 +type: fat
   4.355 +size: 5
   4.356 +bootloader: OMAP5-uEVM/latest
   4.357 +kernel: latest
   4.358 +devices: latest
   4.359 +
   4.360 +partition omap5432evm-root
   4.361 +adapts: lxde
   4.362 +kernel: none
   4.363 +devices: none
   4.364 +size: 95
   4.365 +
   4.366 +system omap5432evm
   4.367 +partition: omap5432evm-boot
   4.368 +partition: omap5432evm-root
   4.369 +
   4.370 +partition omap5432evm+pyra-boot
   4.371 +type: fat
   4.372 +size: 5
   4.373 +bootloader: OMAP5-uEVM+Pyra4.9/latest
   4.374 +kernel: latest
   4.375 +devices: latest
   4.376 +
   4.377 +partition omap5432evm+pyra-root
   4.378 +adapts: lxde
   4.379 +kernel: none
   4.380 +devices: none
   4.381 +size: 95
   4.382 +
   4.383 +system omap5432evm+pyra
   4.384 +partition: omap5432evm+pyra-boot
   4.385 +partition: omap5432evm+pyra-root
   4.386 +
   4.387 +partition pyra+lc15-boot
   4.388 +type: fat
   4.389 +size: 5
   4.390 +bootloader: Pyra+LC15/latest
   4.391 +kernel: latest
   4.392 +devices: latest
   4.393 +
   4.394 +partition pyra+lc15-root
   4.395 +adapts: lxde
   4.396 +kernel: none
   4.397 +devices: none
   4.398 +size: 95
   4.399 +
   4.400 +system pyra+lc15
   4.401 +partition: pyra+lc15-boot
   4.402 +partition: pyra+lc15-root
   4.403 +
   4.404 +partition pyra+lc15-4.9-boot
   4.405 +type: fat
   4.406 +size: 5
   4.407 +bootloader: Pyra+LC15-4.9/latest
   4.408 +kernel: latest
   4.409 +devices: latest
   4.410 +
   4.411 +partition pyra+lc15-4.9-root
   4.412 +adapts: lxde
   4.413 +kernel: none
   4.414 +devices: none
   4.415 +size: 95
   4.416 +
   4.417 +system pyra+lc15-4.9
   4.418 +partition: pyra+lc15-4.9-boot
   4.419 +partition: pyra+lc15-4.9-root
   4.420 +
   4.421 +partition pyra+lc15-4gb-boot
   4.422 +type: fat
   4.423 +size: 5
   4.424 +bootloader: Pyra+LC15-4GB/latest
   4.425 +kernel: latest-lpae
   4.426 +devices: latest-lpae
   4.427 +
   4.428 +partition pyra+lc15-4gb-root
   4.429 +adapts: lxde
   4.430 +modules: latest-lpae
   4.431 +kernel: none
   4.432 +devices: none
   4.433 +size: 95
   4.434 +
   4.435 +system pyra+lc15-4gb
   4.436 +partition: pyra+lc15-4gb-boot
   4.437 +partition: pyra+lc15-4gb-root
   4.438 +
   4.439 +partition pyra-boot
   4.440 +adapts: pyra+lc15-boot
   4.441 +
   4.442 +partition pyra-root
   4.443 +adapts: pyra+lc15-root
   4.444 +root: pyraos
   4.445 +
   4.446 +system pyra
   4.447 +partition: pyra-boot
   4.448 +partition: pyra-root
   4.449 +
   4.450 +system pyra-lxde
   4.451 +adapts: pyra+lc15
   4.452 +
   4.453 +partition pyra-4gb-boot
   4.454 +adapts: pyra+lc15-4gb-boot
   4.455 +
   4.456 +partition pyra-4gb-root
   4.457 +adapts: pyra+lc15-4gb-root
   4.458 +root: pyraos
   4.459 +
   4.460 +system pyra-4gb
   4.461 +partition: pyra-4gb-boot
   4.462 +partition: pyra-4gb-root
   4.463 +
   4.464 +partition lc15-boot
   4.465 +type: fat
   4.466 +size: 5
   4.467 +bootloader: Letux-Cortex-15/latest
   4.468 +kernel: latest
   4.469 +devices: latest
   4.470 +
   4.471 +partition lc15-root
   4.472 +adapts: lxde
   4.473 +kernel: none
   4.474 +devices: none
   4.475 +size: 95
   4.476 +
   4.477 +system lc15
   4.478 +partition: lc15-boot
   4.479 +partition: lc15-root
   4.480 +
   4.481 +partition lc15-4.9-boot
   4.482 +type: fat
   4.483 +size: 5
   4.484 +bootloader: Letux-Cortex-15-4.9/latest
   4.485 +kernel: latest
   4.486 +devices: latest
   4.487 +
   4.488 +partition lc15-4.9-root
   4.489 +adapts: lxde
   4.490 +kernel: none
   4.491 +devices: none
   4.492 +size: 95
   4.493 +
   4.494 +system lc15-4.9
   4.495 +partition: lc15-4.9-boot
   4.496 +partition: lc15-4.9-root
   4.497 +
   4.498 +partition lc15-4gb-boot
   4.499 +type: fat
   4.500 +size: 5
   4.501 +bootloader: Letux-Cortex-15-4GB/latest
   4.502 +kernel: latest-lpae
   4.503 +devices: latest-lpae
   4.504 +
   4.505 +partition lc15-4gb-root
   4.506 +adapts: lxde
   4.507 +kernel: none
   4.508 +devices: none
   4.509 +modules: latest-lpae
   4.510 +size: 95
   4.511 +
   4.512 +system lc15-4gb
   4.513 +partition: lc15-4gb-boot
   4.514 +partition: lc15-4gb-root
   4.515 +
   4.516 +partition lc15evm-boot
   4.517 +type: fat
   4.518 +size: 5
   4.519 +bootloader: Letux-Cortex-15-EVM/latest
   4.520 +kernel: latest
   4.521 +devices: latest
   4.522 +
   4.523 +partition lc15evm-root
   4.524 +adapts: lxde
   4.525 +kernel: none
   4.526 +devices: none
   4.527 +size: 95
   4.528 +
   4.529 +system lc15evm
   4.530 +partition: lc15evm-boot
   4.531 +partition: lc15evm-root
   4.532 +
   4.533 +partition lc15evm-4gb-boot
   4.534 +type: fat
   4.535 +size: 5
   4.536 +bootloader: Letux-Cortex-15-EVM-4GB/latest
   4.537 +kernel: latest
   4.538 +devices: latest
   4.539 +
   4.540 +partition lc15evm-4gb-root
   4.541 +adapts: lxde
   4.542 +kernel: none
   4.543 +devices: none
   4.544 +size: 95
   4.545 +
   4.546 +system lc15evm-4gb
   4.547 +partition: lc15evm-4gb-boot
   4.548 +partition: lc15evm-4gb-root
   4.549 +
   4.550 +partition gta15-boot
   4.551 +type: fat
   4.552 +size: 5
   4.553 +bootloader: GTA15/latest
   4.554 +kernel: latest
   4.555 +devices: latest
   4.556 +
   4.557 +partition gta15-root
   4.558 +adapts: lxde
   4.559 +kernel: none
   4.560 +devices: none
   4.561 +size: 95
   4.562 +
   4.563 +system gta15
   4.564 +partition: gta15-boot
   4.565 +partition: gta15-root
   4.566 +
   4.567 +partition gta15-4gb-boot
   4.568 +type: fat
   4.569 +size: 5
   4.570 +bootloader: GTA15-4GB/latest
   4.571 +kernel: latest
   4.572 +devices: latest
   4.573 +
   4.574 +partition gta15-4gb-root
   4.575 +adapts: lxde
   4.576 +kernel: none
   4.577 +devices: none
   4.578 +size: 95
   4.579 +
   4.580 +system gta15-4gb
   4.581 +partition: gta15-4gb-boot
   4.582 +partition: gta15-4gb-root
   4.583 +
   4.584 +system pyraphone
   4.585 +adapts: gta15
   4.586  
   4.587  # for Pandora, a single partition image can boot
   4.588 -openpandora		$lxde -b OpenPandora/latest
   4.589 -pandora			$openpandora
   4.590 +
   4.591 +partition openpandora
   4.592 +adapts: lxde
   4.593 +bootloader: OpenPandora/latest
   4.594 +
   4.595 +system openpandora
   4.596 +adapts: openpandora
   4.597 +
   4.598 +system pandora
   4.599 +adapts: openpandora
   4.600 +
   4.601 +# Udoo Neo needs a pseudo-single-partition but SPL and u-boot must be copied by dd
   4.602  
   4.603 -# Udoo Neo needs a pseudo-single -partition but SPL and u-boot must be copied by dd
   4.604 -udoo-neo		$lxde -p 2 -dd Udoo-Neo/latest/SPL -p 138 -dd Udoo-Neo/latest/u-boot.img \
   4.605 -			-p 2048 -bboot Udoo-Neo/latest -kboot latest -dboot latest -m latest
   4.606 +region udoo-neo-spl
   4.607 +position: 2
   4.608 +dd: Udoo-Neo/latest/SPL
   4.609 +bootloader: [boot] Udoo-Neo/latest
   4.610 +
   4.611 +region udoo-neo-boot
   4.612 +position: 138
   4.613 +dd: Udoo-Neo/latest/u-boot.img
   4.614 +bootloader: [boot] Udoo-Neo/latest
   4.615 +
   4.616 +partition udoo-neo-root
   4.617 +adapts: lxde
   4.618 +position: 2048
   4.619 +
   4.620 +system udoo-neo
   4.621 +region: udoo-neo-spl
   4.622 +region: udoo-neo-boot
   4.623 +partition: udoo-neo-root
   4.624  
   4.625  # Raspi 3B+ needs special setup with bootloader and boot plus rootfs partitions
   4.626 -raspi3b+		-f fat -s 5 -I -x https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin \
   4.627 -			-x https://github.com/raspberrypi/firmware/raw/master/boot/fixup.dat \
   4.628 -			-x https://github.com/raspberrypi/firmware/raw/master/boot/start.elf \
   4.629 -			-x http://download.goldelico.com/letux-u-boot/RasPi-3B+/latest/config.txt \
   4.630 -			-x http://download.goldelico.com/letux-u-boot/RasPi-3B+/latest/cmdline.txt \
   4.631 -			-k http://download.goldelico.com/letux-kernel/latest/zImage -d latest $lxde -k none -d none -m latest -s 95
   4.632 +
   4.633 +partition raspi3b+-boot
   4.634 +type: fat
   4.635 +size: 5
   4.636 +info
   4.637 +expand: https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin
   4.638 +expand: https://github.com/raspberrypi/firmware/raw/master/boot/fixup.dat
   4.639 +expand: https://github.com/raspberrypi/firmware/raw/master/boot/start.elf
   4.640 +expand: http://download.goldelico.com/letux-u-boot/RasPi-3B+/latest/config.txt
   4.641 +expand: http://download.goldelico.com/letux-u-boot/RasPi-3B+/latest/cmdline.txt
   4.642 +kernel: http://download.goldelico.com/letux-kernel/latest/zImage
   4.643 +devices: latest
   4.644 +
   4.645 +partition raspi3b+-root
   4.646 +adapts: lxde
   4.647 +kernel: none
   4.648 +devices: none
   4.649 +modules: latest
   4.650 +size: 95
   4.651 +
   4.652 +system raspi3b+
   4.653 +partition: raspi3b+-boot
   4.654 +partition: raspi3b+-root
   4.655  
   4.656  # we must make sure that we load the mipsel variants and not armel/armhf
   4.657 -lenny400		-A mipsel -f fat -s 2 -k http://download.goldelico.com/letux-400/20110208-lenny400/uImage \
   4.658 -			-f ext -r http://download.goldelico.com/letux-400/20110208-lenny400/bootstrapped-rootfs.tbz \
   4.659 -			-c http://download.goldelico.com/letux-400/20110208-lenny400/config.tgz \
   4.660 -			-m http://download.goldelico.com/letux-400/20110208-lenny400/modules.tgz
   4.661 -mipsbook-400		-A mipsel -f fat -s 2 -k latest-l400 -d latest-l400 -f ext \
   4.662 -			-r http://download.goldelico.com/letux-400/20110208-lenny400/bootstrapped-rootfs.tbz \
   4.663 -			-c http://download.goldelico.com/letux-400/20110208-lenny400/config.tgz \
   4.664 -			-m latest-l400
   4.665 -mipsbook		$mipsbook-400
   4.666 -letux-400		$mipsbook-400
   4.667 +
   4.668 +partition lenny400-boot
   4.669 +arch: mipsel
   4.670 +type: fat
   4.671 +size: 2
   4.672 +kernel: http://download.goldelico.com/letux-400/20110208-lenny400/uImage
   4.673 +
   4.674 +partition lenny400-root
   4.675 +type: ext
   4.676 +root: http://download.goldelico.com/letux-400/20110208-lenny400/bootstrapped-rootfs.tbz
   4.677 +config: http://download.goldelico.com/letux-400/20110208-lenny400/config.tgz
   4.678 +modules: http://download.goldelico.com/letux-400/20110208-lenny400/modules.tgz
   4.679 +
   4.680 +system lenny400
   4.681 +partition: lenny400-boot
   4.682 +partition: lenny400-root
   4.683 +
   4.684 +partition mipsbook-400-boot
   4.685 +arch: mipsel
   4.686 +type: fat
   4.687 +size: 2
   4.688 +kernel: latest-l400
   4.689 +devices: latest-l400
   4.690 +
   4.691 +partition mipsbook-400-root
   4.692 +type: ext
   4.693 +root: http://download.goldelico.com/letux-400/20110208-lenny400/bootstrapped-rootfs.tbz
   4.694 +config: http://download.goldelico.com/letux-400/20110208-lenny400/config.tgz
   4.695 +modules: latest-l400
   4.696 +
   4.697 +system mipsbook-400
   4.698 +partition: mipsbook-400-boot
   4.699 +partition: mipsbook-400-root
   4.700 +
   4.701 +system mipsbook
   4.702 +adapts: mipsbook-400
   4.703 +
   4.704 +system letux-400
   4.705 +adapts: mipsbook-400
   4.706 +
   4.707 +# CI20 needs a pseudo-single-partition but SPL and u-boot must be copied by dd
   4.708 +# see https://elinux.org/CI20_Dev_Zone#Making_a_bootable_SD_card_from_sources
   4.709  
   4.710 -# CI20 needs a pseudo-single -partition but SPL and u-boot must be copied by dd
   4.711 -# see https://elinux.org/CI20_Dev_Zone#Making_a_bootable_SD_card_from_sources
   4.712 -ci20			-A mipsel $lxde -p 1 -dd CI20/latest/u-boot-spl.bin -p 28 -dd CI20/latest/u-boot.img \
   4.713 -			-p 4096 -bboot CI20/latest -kboot latest-l400 -dboot latest-l400 -m latest-l400
   4.714 +region ci20-spl
   4.715 +arch: mipsel
   4.716 +position: 1
   4.717 +dd: CI20/latest/u-boot-spl.bin
   4.718 +bootloader: [boot] CI20/latest
   4.719 +
   4.720 +region ci20-boot
   4.721 +arch: mipsel
   4.722 +position: 28
   4.723 +dd: CI20/latest/u-boot.img
   4.724 +bootloader: [boot] CI20/latest
   4.725 +
   4.726 +partition ci20-root
   4.727 +adapts: lxde
   4.728 +position: 4096
   4.729 +kernel: [boot] latest-l400
   4.730 +devices: [boot] latest-l400
   4.731 +modules: latest-l400
   4.732 +
   4.733 +system ci20
   4.734 +region: ci20-spl
   4.735 +region: ci20-boot
   4.736 +partition: ci20-root
   4.737  
   4.738 -# Kobo / Tolino 3 needs a pseudo-single -partition but SPL and u-boot must be copied by dd
   4.739 -kobo-clara		$lxde -p 2 -dd Kobo/latest/SPL -p 138 -dd Kobo/latest/u-boot.img -p 2048 -bboot Kobo/latest -kboot latest -dboot latest -m latest
   4.740 -tolino-shine3		$kobo-clara
   4.741 +# Kobo / Tolino 3 needs a pseudo-single-partition but SPL and u-boot must be copied by dd
   4.742 +
   4.743 +region kobo-clara-spl
   4.744 +position: 2
   4.745 +dd: Kobo/latest/SPL
   4.746 +bootloader: [boot] Kobo/latest
   4.747 +
   4.748 +region kobo-clara-boot
   4.749 +position: 138
   4.750 +dd: Kobo/latest/u-boot.img
   4.751 +bootloader: [boot] Kobo/latest
   4.752 +
   4.753 +partition kobo-clara-root
   4.754 +adapts: lxde
   4.755 +position: 2048
   4.756 +kernel: [boot] latest
   4.757 +devices: [boot] latest
   4.758 +modules: latest
   4.759 +
   4.760 +system kobo-clara
   4.761 +region: kobo-clara-spl
   4.762 +region: kobo-clara-boot
   4.763 +partition: kobo-clara-root
   4.764 +
   4.765 +system tolino-shine3
   4.766 +adapts: kobo-clara
     5.1 --- a/makesd-expand-def	Tue May 28 00:30:18 2019 +0200
     5.2 +++ b/makesd-expand-def	Mon Jun 10 01:37:46 2019 +0200
     5.3 @@ -1,7 +1,7 @@
     5.4  #!/bin/sh
     5.5  
     5.6 -# Search for a definition in the definitions file, expanding it to the recorded
     5.7 -# value, recursively expanding any definition references.
     5.8 +# Search for a definition in the definitions file, expanding it recursively to
     5.9 +# provide a complete description.
    5.10  #
    5.11  # Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk>
    5.12  #
    5.13 @@ -22,45 +22,17 @@
    5.14  PROGNAME=`basename "$0"`
    5.15  THISDIR=`dirname "$0"`
    5.16  
    5.17 +COMMON="$THISDIR/makesd-common"
    5.18  DEFS="$THISDIR/makesd-defs"
    5.19  
    5.20 +. "$COMMON"
    5.21 +
    5.22  
    5.23  
    5.24 -# Test for options.
    5.25 -
    5.26 -if [ "$1" = '--original' ] ; then
    5.27 -    FLAT=$1
    5.28 -    shift 1
    5.29 -else
    5.30 -    FLAT=
    5.31 -fi
    5.32 -
    5.33 -# Obtain the requested definition name.
    5.34 -
    5.35 -DEF=$1
    5.36 -
    5.37 -if [ ! "$DEF" ] || [ "$DEF" = '--help' ] ; then
    5.38 -    cat 1>&2 <<EOF
    5.39 -Usage: $PROGNAME <definition name>
    5.40 -
    5.41 -Search for a definition of the given name in the definitions file:
    5.42 -
    5.43 -$DEFS
    5.44 -
    5.45 -If the definition can be found, the value of the definition is emitted and an
    5.46 -exit value of 0 returned. Otherwise, no output is produced and an exit value of
    5.47 -1 is returned.
    5.48 -EOF
    5.49 -    exit 1
    5.50 -fi
    5.51 -
    5.52 -
    5.53 -
    5.54 -# lookup <definition name>
    5.55 +# lookup <definition>
    5.56  #
    5.57 -# Search for a definition of the given name in the definitions file. Emit the
    5.58 -# full definition, incorporating multiple lines if continuation characters are
    5.59 -# present.
    5.60 +# Search for the given definition in the definitions file. Emit the full
    5.61 +# definition.
    5.62  
    5.63  lookup()
    5.64  {
    5.65 @@ -68,105 +40,161 @@
    5.66  
    5.67      # Obtain the line number of the matching definition.
    5.68  
    5.69 -    LINENUM=`grep -h -n "^$1\s" "$DEFS" | cut -d: -f1`
    5.70 +    LINENUM=`search "^$1$" "$DEFS"`
    5.71  
    5.72      if [ "$LINENUM" ] ; then
    5.73  
    5.74 -        # Read from the definition line. Line continuations are observed.
    5.75 +        # Read from the definition until a blank line or the end of file is
    5.76 +        # encountered. Line continuations are observed.
    5.77 +
    5.78 +        tail -n "+$(($LINENUM + 1))" "$DEFS" | while read LINE ; do
    5.79 +
    5.80 +            # Detect end of definition.
    5.81  
    5.82 -        tail -n "+$LINENUM" "$DEFS" | if read LINE ; then
    5.83 +            if [ ! "$LINE" ] ; then
    5.84 +                break
    5.85 +            fi
    5.86 +
    5.87 +            # Show definition lines.
    5.88 +
    5.89              echo "$LINE"
    5.90 -            break
    5.91 -        fi
    5.92 +        done
    5.93      fi
    5.94  }
    5.95  
    5.96 -# match <string> <pattern>
    5.97 +# consolidate
    5.98  #
    5.99 -# Attempt to match pattern in string, emitting the string if successful.
   5.100 +# Eliminate duplicate properties, preserving only the final definition.
   5.101 +
   5.102 +consolidate()
   5.103 +{
   5.104 +    sort -k1,1 -t: -s | show_last
   5.105 +}
   5.106 +
   5.107 +show_last()
   5.108 +{
   5.109 +    local FIELD LAST LASTLINE
   5.110 +
   5.111 +    LAST=
   5.112 +    LASTLINE=
   5.113 +
   5.114 +    while read LINE ; do
   5.115 +
   5.116 +        # Inspect the property details.
   5.117  
   5.118 -match()
   5.119 -{
   5.120 -    if `echo "$1" | grep -q "$2"` ; then
   5.121 -        echo "$1"
   5.122 +        FIELD=`get_field "$LINE"`
   5.123 +
   5.124 +        # With a differing property from any previous one, emit the previous
   5.125 +        # one.
   5.126 +
   5.127 +        if [ "$LAST" ] && [ "$FIELD" != "$LAST" ] ; then
   5.128 +            echo "$LASTLINE"
   5.129 +        fi
   5.130 +
   5.131 +        # Retain this property definition for possible future emission.
   5.132 +
   5.133 +        LAST=$FIELD
   5.134 +        LASTLINE=$LINE
   5.135 +    done
   5.136 +
   5.137 +    # Emit any remaining line, also indicating whether any lines were processed.
   5.138 +
   5.139 +    if [ "$LASTLINE" ] ; then
   5.140 +        echo "$LASTLINE"
   5.141          return 0
   5.142      else
   5.143          return 1
   5.144      fi
   5.145  }
   5.146  
   5.147 -# defname <prefixed name>
   5.148 -#
   5.149 -# Return the actual definition name from the given prefixed name.
   5.150 -
   5.151 -defname()
   5.152 -{
   5.153 -    echo "$1" | sed 's/^\$//'
   5.154 -}
   5.155 -
   5.156 -# expand <definition name>
   5.157 +# expand <definition>
   5.158  #
   5.159  # Expand the given definition name to its value, recursively expanding any
   5.160  # definition names found in the value text.
   5.161  
   5.162  expand()
   5.163  {
   5.164 -    local FOUND VALUE
   5.165 +    local TYPE
   5.166 +
   5.167 +    TYPE=`echo "$1" | cut -d' ' -f1`
   5.168  
   5.169 -    FOUND=
   5.170 -    VALUE=
   5.171 +    # Look up the definition and read each line.
   5.172 +
   5.173 +    lookup "$1" | expand_def "$TYPE"
   5.174 +}
   5.175  
   5.176 -    for WORD in `lookup "$1"`; do
   5.177 -        if [ ! "$FOUND" ] ; then
   5.178 -            FOUND=$WORD
   5.179 -            continue
   5.180 -        fi
   5.181 +expand_def()
   5.182 +{
   5.183 +    local FIELD LINE RESULT TYPE VALUE
   5.184  
   5.185 -        # Prevent recursive expansion if flat mode is selected.
   5.186 -
   5.187 -        if [ ! "$FLAT" ] ; then
   5.188 +    RESULT=1
   5.189  
   5.190 -            # Identify definition names by looking for a $ prefix.
   5.191 +    while read LINE ; do
   5.192 +        RESULT=0
   5.193  
   5.194 -            DEFNAME=`match "$WORD" '^\\$'`
   5.195 +        # Inspect the line and find any references to other definitions.
   5.196  
   5.197 -            # Attempt to expand definition names.
   5.198 +        FIELD=`get_field "$LINE"`
   5.199 +        VALUE=`get_value "$LINE"`
   5.200 +
   5.201 +        # Merge definitions that are adapted.
   5.202  
   5.203 -            if [ "$DEFNAME" ] ; then
   5.204 -                DEFNAME=`defname "$DEFNAME"`
   5.205 -                EXPANDED=`expand "$DEFNAME"`
   5.206 +        if [ "$FIELD" = 'adapts' ] ; then
   5.207 +            expand "$TYPE $VALUE"
   5.208 +
   5.209 +        # Aggregate system components such as partitions and regions.
   5.210  
   5.211 -                if [ "$EXPANDED" ] ; then
   5.212 -                    WORD=$EXPANDED
   5.213 -                fi
   5.214 -            fi
   5.215 -        fi
   5.216 +        elif [ "$TYPE" = 'system' ] && (
   5.217 +           [ "$FIELD" = 'partition' ] || [ "$FIELD" = 'region' ] ) ; then
   5.218 +
   5.219 +            # Declare regions and partitions in the output.
   5.220  
   5.221 -        # Incorporate expansions into the final value.
   5.222 +            echo "$FIELD"
   5.223 +            expand "$FIELD $VALUE" | consolidate
   5.224 +            echo
   5.225  
   5.226 -        if [ ! "$VALUE" ] ; then
   5.227 -            VALUE=$WORD
   5.228 +        # Otherwise, emit properties of the definition.
   5.229 +
   5.230          else
   5.231 -            VALUE="$VALUE $WORD"
   5.232 +            echo "$LINE"
   5.233          fi
   5.234      done
   5.235  
   5.236 -    # Show the expanded definition value.
   5.237 -
   5.238 -    echo "$VALUE"
   5.239 -
   5.240 -    # Return a result value of 0 if successful, 1 otherwise.
   5.241 -
   5.242 -    if [ "$VALUE" ] ; then
   5.243 -        return 0
   5.244 -    else
   5.245 -        return 1
   5.246 -    fi
   5.247 +    return $RESULT
   5.248  }
   5.249  
   5.250  
   5.251  
   5.252 +# Obtain the requested system name.
   5.253 +
   5.254 +if [ ! "$1" ] || [ "$1" = '--help' ] ; then
   5.255 +    cat 1>&2 <<EOF
   5.256 +Usage: $PROGNAME <system>
   5.257 +       $PROGNAME -a | --all | --defs
   5.258 +
   5.259 +Search for a definition of the given system in the definitions file:
   5.260 +
   5.261 +$DEFS
   5.262 +
   5.263 +If the definition can be found, the value of the definition is emitted and an
   5.264 +exit value of 0 returned. Otherwise, no output is produced and an exit value of
   5.265 +1 is returned.
   5.266 +
   5.267 +$(show_definitions_description)
   5.268 +EOF
   5.269 +    exit 1
   5.270 +fi
   5.271 +
   5.272 +# Show definitions if requested.
   5.273 +
   5.274 +if [ "$1" = '-a' ] || [ "$1" = '--all' ] || [ "$1" = '--defs' ] ; then
   5.275 +    grep '^system' "$DEFS" | sed 's/^system //' | sort
   5.276 +    exit 0
   5.277 +fi
   5.278 +
   5.279  # Expand the definition and return the result code.
   5.280  
   5.281 -expand "$DEF"
   5.282 +DEF=$1
   5.283 +
   5.284 +expand "system $DEF"
   5.285  exit $?
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/makesd-filter-def	Mon Jun 10 01:37:46 2019 +0200
     6.3 @@ -0,0 +1,47 @@
     6.4 +#!/bin/sh
     6.5 +
     6.6 +# Filter sections of a complete definition.
     6.7 +#
     6.8 +# Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk>
     6.9 +#
    6.10 +# This program is free software; you can redistribute it and/or modify it under
    6.11 +# the terms of the GNU General Public License as published by the Free Software
    6.12 +# Foundation; either version 3 of the License, or (at your option) any later
    6.13 +# version.
    6.14 +#
    6.15 +# This program is distributed in the hope that it will be useful, but WITHOUT
    6.16 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    6.17 +# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    6.18 +# details.
    6.19 +#
    6.20 +# You should have received a copy of the GNU General Public License along with
    6.21 +# this program.  If not, see <http://www.gnu.org/licenses/>.
    6.22 +
    6.23 +PROGNAME=`basename "$0"`
    6.24 +THISDIR=`dirname "$0"`
    6.25 +
    6.26 +COMMON="$THISDIR/makesd-common"
    6.27 +
    6.28 +. "$COMMON"
    6.29 +
    6.30 +
    6.31 +
    6.32 +# Obtain the requested system name.
    6.33 +
    6.34 +TYPE=$1
    6.35 +
    6.36 +if [ ! "$TYPE" ] || [ "$TYPE" = '--help' ] ; then
    6.37 +    cat 1>&2 <<EOF
    6.38 +Usage: $PROGNAME <type> [ <property> ... ]
    6.39 +
    6.40 +Select sections of the given type from a complete description of a system
    6.41 +provided on standard input. If any properties are given, select only those
    6.42 +properties in the selected sections.
    6.43 +EOF
    6.44 +    exit 1
    6.45 +fi
    6.46 +
    6.47 +# Select sections of the given type, filtering out all other sections.
    6.48 +
    6.49 +filter $*
    6.50 +exit $?
     7.1 --- a/makesd-format	Tue May 28 00:30:18 2019 +0200
     7.2 +++ b/makesd-format	Mon Jun 10 01:37:46 2019 +0200
     7.3 @@ -62,9 +62,12 @@
     7.4      cat 1>&2 <<EOF
     7.5  Usage: $PROGNAME
     7.6  
     7.7 -The input for this program is supplied via standard input as a list of partition
     7.8 -types, one per line. Types recognised include ext, ext2, ext3, ext4, fat and
     7.9 -swap.
    7.10 +The input for this program is supplied via standard input as partition
    7.11 +definitions employing the following pertinent properties:
    7.12 +
    7.13 +type: <type>
    7.14 +
    7.15 +Types recognised include ext, ext2, ext3, ext4, fat and swap.
    7.16  EOF
    7.17      exit 0
    7.18  fi
    7.19 @@ -75,10 +78,25 @@
    7.20  
    7.21  # Read partition types, one per line.
    7.22  
    7.23 -PARTNUM=1
    7.24 +PARTNUM=0
    7.25 +SECTION=
    7.26 +
    7.27 +while read LINE ; do
    7.28 +
    7.29 +    if [ "$LINE" ] && [ ! "$SECTION" ] ; then
    7.30 +        SECTION=$LINE
    7.31 +        PARTNUM=$(($PARTNUM + 1))
    7.32  
    7.33 -while read TYPE ; do
    7.34 -    DEVICE="${DEV}${PARTNUM}"
    7.35 -    format "$DEVICE" "$TYPE"
    7.36 -    PARTNUM=$(($PARTNUM + 1))
    7.37 +    elif [ ! "$LINE" ] ; then
    7.38 +        SECTION=
    7.39 +
    7.40 +    elif [ "$SECTION" ] ; then
    7.41 +        FIELD=`get_field "$LINE"`
    7.42 +        VALUE=`get_value "$LINE"`
    7.43 +
    7.44 +        if [ "$FIELD" = 'type' ] ; then
    7.45 +            DEVICE="${DEV}${PARTNUM}"
    7.46 +            format "$DEVICE" "$TYPE"
    7.47 +        fi
    7.48 +    fi
    7.49  done
     8.1 --- a/makesd-partition-summary	Tue May 28 00:30:18 2019 +0200
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,187 +0,0 @@
     8.4 -#!/bin/sh
     8.5 -
     8.6 -# Emit a partition summary for a device employing parameters such as the start,
     8.7 -# size, and type.
     8.8 -#
     8.9 -# Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk>
    8.10 -#
    8.11 -# This program is free software; you can redistribute it and/or modify it under
    8.12 -# the terms of the GNU General Public License as published by the Free Software
    8.13 -# Foundation; either version 3 of the License, or (at your option) any later
    8.14 -# version.
    8.15 -#
    8.16 -# This program is distributed in the hope that it will be useful, but WITHOUT
    8.17 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    8.18 -# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    8.19 -# details.
    8.20 -#
    8.21 -# You should have received a copy of the GNU General Public License along with
    8.22 -# this program.  If not, see <http://www.gnu.org/licenses/>.
    8.23 -
    8.24 -PROGNAME=`basename "$0"`
    8.25 -THISDIR=`dirname "$0"`
    8.26 -
    8.27 -
    8.28 -
    8.29 -# Emit any partition details as a complete record.
    8.30 -
    8.31 -emit_partition()
    8.32 -{
    8.33 -    echo "${START:--}\t${SIZE:--}\t${TYPE:--}\t${BOOTLOADER:--}\t" \
    8.34 -         "${CONFIG:--}\t${DEVICETREE:--}\t${KERNEL:--}\t${MODULES:--}\t" \
    8.35 -         "${ROOTFS:--}"
    8.36 -}
    8.37 -
    8.38 -# Reset the current partition details.
    8.39 -
    8.40 -reset_partition()
    8.41 -{
    8.42 -    START=
    8.43 -    SIZE=
    8.44 -    TYPE=
    8.45 -
    8.46 -    BOOTLOADER=
    8.47 -    CONFIG=
    8.48 -    DEVICETREE=
    8.49 -    KERNEL=
    8.50 -    MODULES=
    8.51 -    ROOTFS=
    8.52 -}
    8.53 -
    8.54 -# Emit the current partition details and proceed to the next partition.
    8.55 -
    8.56 -next_partition()
    8.57 -{
    8.58 -    if [ "$START" ] || [ "$SIZE" ] || [ "$TYPE" ] ; then
    8.59 -        emit_partition
    8.60 -        reset_partition
    8.61 -    fi
    8.62 -}
    8.63 -
    8.64 -# test_partition <value>
    8.65 -#
    8.66 -# Test for the presence of the given value, starting a new partition if already
    8.67 -# defined.
    8.68 -
    8.69 -test_partition()
    8.70 -{
    8.71 -    if [ "$1" ] ; then
    8.72 -        next_partition
    8.73 -    fi
    8.74 -}
    8.75 -
    8.76 -# replace_in_partition <name> <value>
    8.77 -#
    8.78 -# Set in the partition the parameter of the given name to value.
    8.79 -
    8.80 -replace_in_partition()
    8.81 -{
    8.82 -    eval "$1=\"\$2\""
    8.83 -}
    8.84 -
    8.85 -# set_in_partition <name> <value>
    8.86 -#
    8.87 -# Set the partition parameter of the given name to value, starting a new
    8.88 -# partition if necessary.
    8.89 -
    8.90 -set_in_partition()
    8.91 -{
    8.92 -    eval "test_partition \$$1"
    8.93 -    replace_in_partition "$1" "$2"
    8.94 -}
    8.95 -
    8.96 -
    8.97 -
    8.98 -# Emit the help message if requested.
    8.99 -
   8.100 -if [ "$1" = '--help' ] ; then
   8.101 -    cat 1>&2 <<EOF
   8.102 -Usage: $PROGNAME <option>...
   8.103 -
   8.104 -Produce partition descriptions, indicating partition type, start position and
   8.105 -size for each partition. Each new occurrence of an active partitioning option
   8.106 -starts a new partition description.
   8.107 -
   8.108 -Partitioning options are as follows:
   8.109 -
   8.110 --f <type>            - partition type (ext2, ext3, ext4, fat, swap...)
   8.111 --p <start position>  - start position/sector
   8.112 --s <size>            - partition size as a percentage of device capacity
   8.113 -
   8.114 -Alongside partitioning options, the following population options can be given:
   8.115 -
   8.116 --b <bootloader>      - bootloader payload
   8.117 --c <config>          - configuration archive
   8.118 --d <device tree>     - device tree binary archive
   8.119 --k <kernel>          - kernel payload
   8.120 --m <modules>         - kernel modules archive
   8.121 --r <root filesystem> - root filesystem archive
   8.122 -
   8.123 -Each line of the produced description is tab-separated with '-' indicating an
   8.124 -empty field.
   8.125 -EOF
   8.126 -    exit 0
   8.127 -fi
   8.128 -
   8.129 -# Process the arguments, building a partition description.
   8.130 -
   8.131 -reset_partition
   8.132 -
   8.133 -while [ "$1" ] ; do
   8.134 -    case "$1" in
   8.135 -
   8.136 -        # Partition type, position, size.
   8.137 -
   8.138 -        -f )
   8.139 -            set_in_partition "TYPE" "$2"
   8.140 -            shift 2
   8.141 -            ;;
   8.142 -        -p )
   8.143 -            set_in_partition "START" "$2"
   8.144 -            shift 2
   8.145 -            ;;
   8.146 -        -s )
   8.147 -            set_in_partition "SIZE" "$2"
   8.148 -            shift 2
   8.149 -            ;;
   8.150 -
   8.151 -        # Bootloader, configuration, device tree, kernel, modules, root
   8.152 -        # filesystem.
   8.153 -
   8.154 -        -b )
   8.155 -            replace_in_partition "BOOTLOADER" "$2"
   8.156 -            shift 2
   8.157 -            ;;
   8.158 -        -c )
   8.159 -            replace_in_partition "CONFIG" "$2"
   8.160 -            shift 2
   8.161 -            ;;
   8.162 -        -dd )
   8.163 -            # NOTE: To be supported.
   8.164 -            shift 1
   8.165 -            ;;
   8.166 -        -d )
   8.167 -            replace_in_partition "DEVICETREE" "$2"
   8.168 -            shift 2
   8.169 -            ;;
   8.170 -        -k )
   8.171 -            replace_in_partition "KERNEL" "$2"
   8.172 -            shift 2
   8.173 -            ;;
   8.174 -        -m )
   8.175 -            replace_in_partition "MODULES" "$2"
   8.176 -            shift 2
   8.177 -            ;;
   8.178 -        -r )
   8.179 -            replace_in_partition "ROOTFS" "$2"
   8.180 -            shift 2
   8.181 -            ;;
   8.182 -        * )
   8.183 -            shift 1
   8.184 -            ;;
   8.185 -    esac
   8.186 -done
   8.187 -
   8.188 -# Terminate any unfinished partition.
   8.189 -
   8.190 -next_partition
     9.1 --- a/makesd-partition-table	Tue May 28 00:30:18 2019 +0200
     9.2 +++ b/makesd-partition-table	Mon Jun 10 01:37:46 2019 +0200
     9.3 @@ -202,11 +202,12 @@
     9.4  Produce partition descriptions, indicating partition type, start position and
     9.5  size for each partition.
     9.6  
     9.7 -The input for this program is supplied via standard input as a partitioning
     9.8 -summary with each line providing a collection of tab-separated values. These
     9.9 -values appear in the following order:
    9.10 +The input for this program is supplied via standard input as partition
    9.11 +definitions employing the following pertinent properties:
    9.12  
    9.13 -<start> <size> <type>
    9.14 +position: <start>
    9.15 +size: <size>
    9.16 +type: <type>
    9.17  
    9.18  Start positions are indicated as numbers of 512-byte sectors.
    9.19  
    9.20 @@ -235,9 +236,34 @@
    9.21  
    9.22  # Read and emit partition details.
    9.23  
    9.24 -while read_fields ; do
    9.25 +SECTION=
    9.26 +
    9.27 +while read LINE ; do
    9.28 +
    9.29 +    if [ "$LINE" ] && [ ! "$SECTION" ] ; then
    9.30 +        SECTION=$LINE
    9.31 +
    9.32 +    elif [ ! "$LINE" ] ; then
    9.33 +        SECTION=
    9.34 +        next_partition
    9.35 +
    9.36 +    elif [ "$SECTION" ] ; then
    9.37 +        FIELD=`get_field "$LINE"`
    9.38 +        VALUE=`get_value "$LINE"`
    9.39 +
    9.40 +        case "$FIELD" in
    9.41 +            ( 'position' ) set_value "START" "$VALUE" ;;
    9.42 +            ( 'size' )     set_value "SIZE" "$VALUE" ;;
    9.43 +            ( 'type' )     set_value "TYPE" "$VALUE" ;;
    9.44 +        esac
    9.45 +    fi
    9.46 +done
    9.47 +
    9.48 +# Finish any open section.
    9.49 +
    9.50 +if [ "$SECTION" ] ; then
    9.51      next_partition
    9.52 -done
    9.53 +fi
    9.54  
    9.55  # Emit the last partition.
    9.56