From 2ea40dc269a9e91c7c406b522005179d16d20092 Mon Sep 17 00:00:00 2001 From: John Zimmermann <me@johnnynator.dev> Date: Mon, 15 Mar 2021 19:59:41 +0100 Subject: [PATCH] mkimage.sh: initialize and check PLATFORM earlier in script --- mkimage.sh.in | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mkimage.sh.in b/mkimage.sh.in index 6a9cdae..c6b9b0d 100644 --- a/mkimage.sh.in +++ b/mkimage.sh.in @@ -110,6 +110,17 @@ elif [ ! -r "$ROOTFS_TARBALL" ]; then die "Cannot read rootfs tarball: $ROOTFS_TARBALL" fi +# Setup the platform variable. Here we want just the name and +# optionally -musl if this is the musl variant. +PLATFORM="${ROOTFS_TARBALL#void-}" +PLATFORM="${PLATFORM%-PLATFORMFS*}" + +# Be absolutely certain the platform is supported before continuing +case "$PLATFORM" in + bananapi|beaglebone|cubieboard2|cubietruck|odroid-c2|odroid-u2|rpi|rpi2|rpi3|rpi4|GCP|pinebookpro|pinephone|*-musl);; + *) die "The $PLATFORM is not supported, exiting..." +esac + # By default we build all platform images with a 64MiB boot partition # formated FAT16, and an approximately 1.9GiB root partition formated # ext4. More exotic combinations are of course possible, but this @@ -123,11 +134,6 @@ fi readonly REQTOOLS="sfdisk partx losetup mount truncate mkfs.${BOOT_FSTYPE} mkfs.${ROOT_FSTYPE}" check_tools -# Setup the platform variable. Here we want just the name and -# optionally -musl if this is the musl variant. -PLATFORM="${ROOTFS_TARBALL#void-}" -PLATFORM="${PLATFORM%-PLATFORMFS*}" - # This is an awful hack since the script isn't using privesc # mechanisms selectively. This is a TODO item. if [ "$(id -u)" -ne 0 ]; then @@ -141,12 +147,6 @@ if [ -z "$FILENAME" ]; then FILENAME="void-${PLATFORM}-$(date +%Y%m%d).img" fi -# Be absolutely certain the platform is supported before continuing -case "$PLATFORM" in - bananapi|beaglebone|cubieboard2|cubietruck|odroid-c2|odroid-u2|rpi|rpi2|rpi3|rpi4|GCP|pinebookpro|pinephone|*-musl);; - *) die "The $PLATFORM is not supported, exiting..." -esac - # Create the base image. This was previously accomplished with dd, # but truncate is markedly faster. info_msg "Creating disk image ($IMGSIZE) ..."