2024-03-01 18:51:15 +00:00
|
|
|
FROM stagex/busybox AS busybox
|
|
|
|
FROM stagex/musl AS musl
|
|
|
|
FROM stagex/xorriso AS xorriso
|
|
|
|
FROM stagex/syslinux AS syslinux
|
|
|
|
FROM stagex/cpio AS cpio
|
|
|
|
FROM stagex/linux-airgap AS linux
|
|
|
|
FROM stagex/mtools AS mtools
|
2024-06-11 21:07:13 +00:00
|
|
|
FROM stagex/xz AS xz
|
|
|
|
FROM stagex/grub:local AS grub
|
2024-03-01 18:51:15 +00:00
|
|
|
|
|
|
|
FROM scratch AS base
|
|
|
|
COPY --from=busybox . /
|
|
|
|
COPY --from=musl . /
|
|
|
|
COPY --from=xorriso . /
|
|
|
|
COPY --from=cpio . /
|
|
|
|
COPY --from=mtools . /
|
|
|
|
COPY --from=linux . /
|
|
|
|
COPY --from=syslinux . /
|
2024-06-11 21:07:13 +00:00
|
|
|
COPY --from=xz . /
|
|
|
|
COPY --from=grub . /
|
2024-03-01 18:51:15 +00:00
|
|
|
|
|
|
|
FROM base AS build
|
2024-06-11 21:07:13 +00:00
|
|
|
|
|
|
|
## Kernel
|
|
|
|
COPY --from=linux /bzImage iso/boot/vmlinuz
|
|
|
|
|
|
|
|
## Initramfs
|
2024-03-01 18:51:15 +00:00
|
|
|
COPY --from=stagex/busybox . initramfs
|
|
|
|
COPY --chmod=0755 <<-EOF initramfs/init
|
|
|
|
#!/bin/sh
|
|
|
|
/bin/sh
|
|
|
|
EOF
|
2024-06-11 21:07:13 +00:00
|
|
|
RUN <<-EOF
|
|
|
|
set -eux
|
|
|
|
cd initramfs
|
|
|
|
find . \
|
|
|
|
| cpio -o -H newc \
|
|
|
|
| gzip -9 \
|
|
|
|
> ../iso/boot/initramfs
|
|
|
|
EOF
|
|
|
|
|
|
|
|
## Grub (EFI Boot)
|
|
|
|
COPY <<-EOF iso/boot/grub/grub.cfg
|
|
|
|
menuentry "Linux Airgap" {
|
|
|
|
linux /boot/vmlinuz
|
|
|
|
initrd /boot/initramfs
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
COPY <<-EOF grub_early.cfg
|
|
|
|
search --no-floppy --set=root --label "Airgap"
|
|
|
|
set prefix=(\$root)/boot/grub
|
2024-03-01 18:51:15 +00:00
|
|
|
EOF
|
|
|
|
RUN <<-EOF
|
|
|
|
set -eux
|
2024-06-11 21:07:13 +00:00
|
|
|
mkdir -p iso/efi/boot
|
|
|
|
grub-mkimage \
|
|
|
|
--config="grub_early.cfg" \
|
|
|
|
--prefix="/boot/grub" \
|
|
|
|
--output="iso/efi/boot/bootx64.efi" \
|
|
|
|
--format="x86_64-efi" \
|
|
|
|
--compression="xz" \
|
|
|
|
all_video \
|
|
|
|
disk \
|
|
|
|
part_gpt \
|
|
|
|
part_msdos \
|
|
|
|
linux \
|
|
|
|
normal \
|
|
|
|
configfile \
|
|
|
|
search \
|
|
|
|
search_label \
|
|
|
|
efi_gop \
|
|
|
|
fat \
|
|
|
|
iso9660 \
|
|
|
|
cat \
|
|
|
|
echo \
|
|
|
|
ls \
|
|
|
|
test \
|
|
|
|
true \
|
|
|
|
help \
|
|
|
|
gzio
|
2024-03-01 18:51:15 +00:00
|
|
|
EOF
|
2024-06-11 21:07:13 +00:00
|
|
|
RUN <<-EOF
|
|
|
|
mformat -i iso/boot/grub/efi.img -C -f 1440 -N 0 ::
|
|
|
|
mcopy -i iso/boot/grub/efi.img iso/efi
|
|
|
|
touch -md "@0" iso/boot/grub/efi.img
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
## Syslinux (BIOS Boot)
|
|
|
|
COPY <<-EOF iso/boot/syslinux/syslinux.cfg
|
|
|
|
TIMEOUT 2
|
|
|
|
PROMPT -1
|
|
|
|
DEFAULT Airgap
|
|
|
|
LABEL Airgap
|
|
|
|
MENU LABEL Linux Airgap
|
|
|
|
KERNEL /boot/vmlinuz
|
|
|
|
INITRD /boot/initramfs
|
|
|
|
EOF
|
|
|
|
RUN <<-EOF
|
|
|
|
mkdir -p iso/boot/syslinux
|
|
|
|
for file in \
|
|
|
|
isohdpfx.bin \
|
|
|
|
isolinux.bin \
|
|
|
|
ldlinux.c32 \
|
|
|
|
libutil.c32 \
|
|
|
|
libcom32.c32 \
|
|
|
|
mboot.c32; \
|
|
|
|
do
|
|
|
|
mv /usr/share/syslinux/$file iso/boot/syslinux/$file || return 1
|
|
|
|
done
|
|
|
|
EOF
|
|
|
|
|
|
|
|
## Build Hybrid EFI/BIOS ISO
|
2024-03-01 18:51:15 +00:00
|
|
|
FROM build AS install
|
2024-06-11 21:07:13 +00:00
|
|
|
RUN xorrisofs \
|
2024-03-01 18:51:15 +00:00
|
|
|
-output airgap.iso \
|
2024-06-11 21:07:13 +00:00
|
|
|
-full-iso9660-filenames \
|
|
|
|
-joliet \
|
|
|
|
-rational-rock \
|
|
|
|
-sysid LINUX \
|
|
|
|
-isohybrid-mbr iso/boot/syslinux/isohdpfx.bin \
|
|
|
|
-eltorito-boot boot/syslinux/isolinux.bin \
|
|
|
|
-eltorito-catalog boot/syslinux/boot.cat \
|
2024-03-01 18:51:15 +00:00
|
|
|
-no-emul-boot \
|
|
|
|
-boot-load-size 4 \
|
|
|
|
-boot-info-table \
|
|
|
|
-eltorito-alt-boot \
|
2024-06-11 21:07:13 +00:00
|
|
|
-e boot/grub/efi.img \
|
2024-03-01 18:51:15 +00:00
|
|
|
-no-emul-boot \
|
2024-06-11 21:07:13 +00:00
|
|
|
-isohybrid-gpt-basdat \
|
|
|
|
-follow-links \
|
|
|
|
iso/
|
2024-03-01 18:51:15 +00:00
|
|
|
|
|
|
|
FROM scratch AS package
|
2024-06-11 21:07:13 +00:00
|
|
|
COPY --from=install /iso /iso
|
2024-03-01 18:51:15 +00:00
|
|
|
COPY --from=install /airgap.iso /
|