Skip to content

Commit 2ea40dc

Browse files
committed
mkimage.sh: initialize and check PLATFORM earlier in script
1 parent 48ba5d6 commit 2ea40dc

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

mkimage.sh.in

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ elif [ ! -r "$ROOTFS_TARBALL" ]; then
110110
die "Cannot read rootfs tarball: $ROOTFS_TARBALL"
111111
fi
112112

113+
# Setup the platform variable. Here we want just the name and
114+
# optionally -musl if this is the musl variant.
115+
PLATFORM="${ROOTFS_TARBALL#void-}"
116+
PLATFORM="${PLATFORM%-PLATFORMFS*}"
117+
118+
# Be absolutely certain the platform is supported before continuing
119+
case "$PLATFORM" in
120+
bananapi|beaglebone|cubieboard2|cubietruck|odroid-c2|odroid-u2|rpi|rpi2|rpi3|rpi4|GCP|pinebookpro|pinephone|*-musl);;
121+
*) die "The $PLATFORM is not supported, exiting..."
122+
esac
123+
113124
# By default we build all platform images with a 64MiB boot partition
114125
# formated FAT16, and an approximately 1.9GiB root partition formated
115126
# ext4. More exotic combinations are of course possible, but this
@@ -123,11 +134,6 @@ fi
123134
readonly REQTOOLS="sfdisk partx losetup mount truncate mkfs.${BOOT_FSTYPE} mkfs.${ROOT_FSTYPE}"
124135
check_tools
125136

126-
# Setup the platform variable. Here we want just the name and
127-
# optionally -musl if this is the musl variant.
128-
PLATFORM="${ROOTFS_TARBALL#void-}"
129-
PLATFORM="${PLATFORM%-PLATFORMFS*}"
130-
131137
# This is an awful hack since the script isn't using privesc
132138
# mechanisms selectively. This is a TODO item.
133139
if [ "$(id -u)" -ne 0 ]; then
@@ -141,12 +147,6 @@ if [ -z "$FILENAME" ]; then
141147
FILENAME="void-${PLATFORM}-$(date +%Y%m%d).img"
142148
fi
143149

144-
# Be absolutely certain the platform is supported before continuing
145-
case "$PLATFORM" in
146-
bananapi|beaglebone|cubieboard2|cubietruck|odroid-c2|odroid-u2|rpi|rpi2|rpi3|rpi4|GCP|pinebookpro|pinephone|*-musl);;
147-
*) die "The $PLATFORM is not supported, exiting..."
148-
esac
149-
150150
# Create the base image. This was previously accomplished with dd,
151151
# but truncate is markedly faster.
152152
info_msg "Creating disk image ($IMGSIZE) ..."

0 commit comments

Comments
 (0)