diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82d765f..0ba46c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,8 +96,8 @@ jobs: - name: Test qemu_x86_virt + ${{ matrix.suite }} ${{ matrix.arch }} timeout-minutes: 15 run: | - ./test/qemu.sh $RUNNER_TEMP/boot-qemu_x86_virt.bin.gz \ - $RUNNER_TEMP/${{ matrix.os }}-${{ matrix.suite }}-${{ matrix.arch }}-*.bin.gz + sudo ./test/qemu.sh $RUNNER_TEMP/boot-qemu_x86_virt.bin.gz \ + $RUNNER_TEMP/${{ matrix.os }}-${{ matrix.suite }}-${{ matrix.arch }}-*.bin.gz build-docker: runs-on: ubuntu-latest diff --git a/scripts/build-debian b/scripts/build-debian index a673940..563a5a8 100755 --- a/scripts/build-debian +++ b/scripts/build-debian @@ -181,10 +181,10 @@ ln -sf /run/systemd/resolve/stub-resolv.conf debian/etc/resolv.conf find debian ! -type d -printf "/%P\n" | sort > files.txt # Make a ext4 filesystem of this and put it into the image -# >>> 3800000000 - (32 * 1024 * 1024) -# 3766445568 +# >>> ((3800000000 - 32 * 1024 * 1024) // (1024 * 1024)) * (1024 * 1024) +# 3765436416 rm -f ext4.img -fallocate -l 3766445568 ext4.img +fallocate -l 3765436416 ext4.img mkfs.ext4 -d debian ext4.img pigz ext4.img diff --git a/scripts/build-image b/scripts/build-image index ee4f074..4eb8c22 100755 --- a/scripts/build-image +++ b/scripts/build-image @@ -12,7 +12,7 @@ rm -f "${IMAGE}" fallocate -v -l 3800000000 "${IMAGE}" # 3,800,000,000 bytes parted -s "${IMAGE}" mklabel msdos -parted -s "${IMAGE}" mkpart primary fat32 -- 4MiB 32MiB # 28 MiB (50,331,648 bytes) +parted -s "${IMAGE}" mkpart primary fat32 -- 4MiB 32MiB # 28 MiB (29,360,128 bytes) parted -s "${IMAGE}" mkpart primary ext2 -- 32MiB -1 parted -s "${IMAGE}" set 2 boot on diff --git a/test/qemu.sh b/test/qemu.sh index 5f77d6a..4f851dd 100755 --- a/test/qemu.sh +++ b/test/qemu.sh @@ -20,12 +20,31 @@ echo "Using password ${SSHPASS}" # Build image zcat "${BOOT}" "${DEBIAN}" > image.bin +# Check integrity +LOOP1=$(losetup -f -P --show image.bin) && { + trap 'losetup -d "${LOOP1}"' ERR + fsck.vfat -p -f "${LOOP1}p1" + fsck.ext4 -p -f "${LOOP1}p2" + trap '-' ERR + losetup -d "${LOOP1}" +} + # Assume 8GB virtual disk fallocate -l 8GB image.bin # Extend second partition parted -s -a opt image.bin "resizepart 2 100%" +# Check integrity again +LOOP2=$(losetup -f -P --show image.bin) && { + trap 'losetup -d "${LOOP2}"' ERR + fsck.vfat -p -f "${LOOP2}p1" + fsck.ext4 -p -f "${LOOP2}p2" + resize2fs "${LOOP2}p2" + trap '-' ERR + losetup -d "${LOOP2}" +} + # Extract U-Boot (u-boot.rom in x86 case) dd if=image.bin of=bios.bin count=2048 skip=16