From baf97d399a4c8d280257a337f13d75ab11a797f5 Mon Sep 17 00:00:00 2001 From: Phil Jaenke Date: Wed, 22 Nov 2023 17:25:29 -0500 Subject: [PATCH] Add support to configure IMAGE_SIZE (#89) * Add support to configure IMAGE_SIZE Add support to define IMAGE_SIZE without changing the defaults; this is helpful for use with both larger (Alma) and smaller (Alpine) distros. * Resolve review Put IMAGE_SIZE in quotes as requested --- scripts/build-image | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/build-image b/scripts/build-image index 4eb8c22..42ecfeb 100755 --- a/scripts/build-image +++ b/scripts/build-image @@ -5,11 +5,16 @@ IMAGE="${1}" set -ex -# Aim for a 4 GB card but with 5% unpartitioned as a margin +# Aim for a 4 GB image default but with 5% unpartitioned as a margin, and a minimum of 1 GB # >>> (0.95 * 4000000000 // 512) * 512 -# 3800000000.0 +# 3800000000.0 +IMAGE_SIZE=${IMAGE_SIZE:-3800000000} +if [ $IMAGE_SIZE -lt 1000000000 ]; then + echo "IMAGE_SIZE of 1GB or less unsupported!" + exit 1 +fi rm -f "${IMAGE}" -fallocate -v -l 3800000000 "${IMAGE}" # 3,800,000,000 bytes +fallocate -v -l "${IMAGE_SIZE}" "${IMAGE}" # 3,800,000,000 bytes parted -s "${IMAGE}" mklabel msdos parted -s "${IMAGE}" mkpart primary fat32 -- 4MiB 32MiB # 28 MiB (29,360,128 bytes)