fix: determinism on appended fat32 partition

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

View File

@ -51,6 +51,7 @@ FROM stagex/xorriso:sx2024.09.0@sha256:2205a8f53d4fc569880c311061daa085f40c62b2f
FROM stagex/xz:sx2024.09.0@sha256:b57c5e6144117bc0124855e9538e60c302cc7bf53fafb53e2eef3434015366f1 AS xz
FROM stagex/yq:sx2024.09.0@sha256:bd6882f0f3ea664e9de6cf732cef2fa2781fc2852f5e6502a6aea1e63eb9708b AS yq
FROM stagex/zlib:sx2024.09.0@sha256:96b4100550760026065dac57148d99e20a03d17e5ee20d6b32cbacd61125dbb6 AS zlib
FROM stagex/parted AS parted
FROM scratch AS base
ARG VERSION development
@ -66,6 +67,7 @@ COPY --from=mtools . /
COPY --from=xz . /
COPY --from=grub . /
COPY --from=util-linux . /
COPY --from=parted . /
FROM base as dev
COPY --from=gcc . /
@ -198,7 +200,9 @@ FROM build AS install
ENV SOURCE_DATE_EPOCH=1
RUN <<-EOF
set -eux
dd if=/dev/zero bs=1M count=512 >> user.img
find iso -exec touch -hcd "@0" "{}" +
mformat -v user -i user.img -N 0 ::
xorrisofs \
-output airgap.iso \
-full-iso9660-filenames \
@ -217,24 +221,8 @@ RUN <<-EOF
-no-emul-boot \
-isohybrid-gpt-basdat \
-follow-links \
-append_partition 3 0xb user.img \
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
## Minimal Autorun SD card image