fix: determinism on appended fat32 partition

This commit is contained in:
Lance Vick 2024-10-03 04:37:17 -07:00
parent 575967e5b4
commit 934fb903dd
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
1 changed files with 3 additions and 18 deletions

View File

@ -65,7 +65,6 @@ COPY --from=cpio . /
COPY --from=mtools . / COPY --from=mtools . /
COPY --from=xz . / COPY --from=xz . /
COPY --from=grub . / COPY --from=grub . /
COPY --from=util-linux . /
FROM base as dev FROM base as dev
COPY --from=gcc . / COPY --from=gcc . /
@ -198,6 +197,8 @@ FROM build AS install
ENV SOURCE_DATE_EPOCH=1 ENV SOURCE_DATE_EPOCH=1
RUN <<-EOF RUN <<-EOF
set -eux set -eux
dd if=/dev/zero bs=1M count=10 >> user.img
mformat -v user -i user.img -N 0 ::
find iso -exec touch -hcd "@0" "{}" + find iso -exec touch -hcd "@0" "{}" +
xorrisofs \ xorrisofs \
-output airgap.iso \ -output airgap.iso \
@ -217,24 +218,8 @@ RUN <<-EOF
-no-emul-boot \ -no-emul-boot \
-isohybrid-gpt-basdat \ -isohybrid-gpt-basdat \
-follow-links \ -follow-links \
-append_partition 3 0xb user.img \
iso/ iso/
# Increase ISO size by 512 MB to create space for the third partition
dd if=/dev/zero bs=1M count=512 >> airgap.iso
# Append a new partition that uses the additional space
echo ", +" | sfdisk --append airgap.iso
# Set the newly added third partition to FAT32
sfdisk --part-type airgap.iso 3 b
# Calculate the byte offset of the third partition
# This is done by finding the end of the first partition using fdisk,
# adding 1 sector, and multiplying by 512 (since each sector is 512 bytes).
OFFSET=$(fdisk -l airgap.iso | awk '/^airgap.iso1/ {print ($4 + 1) * 512}')
# Format the third partition as FAT32 and label it 'USER'
mformat -v USER -i airgap.iso@@$OFFSET ::
EOF EOF
## Minimal Autorun SD card image ## Minimal Autorun SD card image