From d150c563f6acabb9b5c0392e7b8028414ef466f9 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 14 May 2024 12:24:25 +0100 Subject: [PATCH] Fix: 'truncate' work-around for git CI on COW files systems. fallocate fails on some (git CI) COW filesystems, so have a coreutils alternative. build-boot-rpi build-debian build-image qemu.sh --- scripts/build-boot-rpi | 3 ++- scripts/build-debian | 3 ++- scripts/build-image | 6 ++++-- test/qemu.sh | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/build-boot-rpi b/scripts/build-boot-rpi index 223eb4d..991bcb4 100755 --- a/scripts/build-boot-rpi +++ b/scripts/build-boot-rpi @@ -73,7 +73,8 @@ sed -i -e "s/BOOT_UART=0/BOOT_UART=1/" bootcode.bin # Create empty FAT partition rm -f vfat.img -fallocate -l 28MiB vfat.img +# fallocate fails on some (git CI) COW filesystems, so have a coreutils alternative. +fallocate -l 28MiB vfat.img || truncate --size 28MiB vfat.img mkfs.vfat vfat.img # Copy boot files to FAT partition diff --git a/scripts/build-debian b/scripts/build-debian index 43fc91c..5ff5e89 100755 --- a/scripts/build-debian +++ b/scripts/build-debian @@ -197,7 +197,8 @@ mv debian/tmp/versions.csv versions.csv # >>> ((3800000000 - 32 * 1024 * 1024) // (1024 * 1024)) * (1024 * 1024) # 3765436416 rm -f ext4.img -fallocate -l 3765436416 ext4.img +# fallocate fails on some (git CI) COW filesystems, so have a coreutils alternative. +fallocate -l 3765436416 ext4.img || truncate --size=3765436416 ext4.img mkfs.ext4 -d debian ext4.img pigz ext4.img diff --git a/scripts/build-image b/scripts/build-image index 42ecfeb..8347cb3 100755 --- a/scripts/build-image +++ b/scripts/build-image @@ -14,7 +14,8 @@ if [ $IMAGE_SIZE -lt 1000000000 ]; then exit 1 fi rm -f "${IMAGE}" -fallocate -v -l "${IMAGE_SIZE}" "${IMAGE}" # 3,800,000,000 bytes +# fallocate fails on some (git CI) COW filesystems, so have a coreutils alternative. +fallocate -v -l "${IMAGE_SIZE}" "${IMAGE}" || truncate --size "${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) @@ -23,7 +24,8 @@ parted -s "${IMAGE}" set 2 boot on # Create empty FAT partition rm -f vfat.img -fallocate -l 28MiB vfat.img +# fallocate fails on some (git CI) COW filesystems, so have a coreutils alternative. +fallocate -l 28MiB vfat.img || truncate --size 28MiB vfat.img mkfs.vfat vfat.img # Leave a friendly note about this partition diff --git a/test/qemu.sh b/test/qemu.sh index a6b13d0..19a6696 100755 --- a/test/qemu.sh +++ b/test/qemu.sh @@ -31,7 +31,8 @@ LOOP1=$(losetup -f -P --show image.bin) && { } # Assume 8GB virtual disk -fallocate -l 8GB image.bin +# fallocate fails on some (git CI) COW filesystems, so have a coreutils alternative. +fallocate -l 8GB image.bin || truncate --size 8GB image.bin # Extend second partition parted -s -a opt image.bin "resizepart 2 100%"