fix: determinism on appended fat32 partition #9

Manually merged
sam.ebstein merged 1 commits from lance/fix-determinism into main 2024-10-05 14:43:31 +00:00
1 changed files with 3 additions and 18 deletions
Showing only changes of commit 934fb903dd - Show all commits

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