forked from public/airgap
1
0
Fork 0

Virtual sd card support

This commit is contained in:
Lance Vick 2024-06-26 00:46:56 -07:00
parent c20dedcc35
commit f735b7e3af
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
4 changed files with 34 additions and 1 deletions

View File

@ -20,15 +20,20 @@ FROM stagex/libgpg-error AS libgpg-error
FROM stagex/libassuan AS libassuan FROM stagex/libassuan AS libassuan
FROM stagex/libgcrypt AS libgcrypt FROM stagex/libgcrypt AS libgcrypt
FROM stagex/jq AS jq FROM stagex/jq AS jq
FROM stagex/yq AS yq
FROM stagex/bc AS bc FROM stagex/bc AS bc
FROM stagex/git AS git FROM stagex/git AS git
FROM stagex/zlib AS zlib FROM stagex/zlib AS zlib
FROM stagex/tpm2-tools AS tpm2-tools FROM stagex/tpm2-tools AS tpm2-tools
FROM stagex/tpm2-tss AS tpm2-tss FROM stagex/tpm2-tss AS tpm2-tss
FROM stagex/openssl AS openssl FROM stagex/openssl AS openssl
FROM stagex/sops AS sops
FROM stagex/pcsc-lite AS pcsc-lite FROM stagex/pcsc-lite AS pcsc-lite
FROM stagex/pcsc-tools AS pcsc-tools FROM stagex/pcsc-tools AS pcsc-tools
FROM stagex/flashtools AS flashtools FROM stagex/flashtools AS flashtools
FROM stagex/libqrencode AS libqrencode
FROM stagex/util-linux AS util-linux
FROM stagex/opensc AS opensc
FROM scratch AS base FROM scratch AS base
ARG VERSION development ARG VERSION development
@ -63,6 +68,7 @@ COPY --from=keyfork . initramfs
COPY --from=bash . initramfs COPY --from=bash . initramfs
COPY --from=gpg . initramfs COPY --from=gpg . initramfs
COPY --from=jq . initramfs COPY --from=jq . initramfs
COPY --from=yq . initramfs
COPY --from=bc . initramfs COPY --from=bc . initramfs
COPY --from=git . initramfs COPY --from=git . initramfs
COPY --from=flashtools . initramfs COPY --from=flashtools . initramfs
@ -74,6 +80,10 @@ COPY --from=ccid . initramfs
COPY --from=pcsc-lite . initramfs COPY --from=pcsc-lite . initramfs
COPY --from=pcsc-tools . initramfs COPY --from=pcsc-tools . initramfs
COPY --from=openpgp-card-tools . initramfs COPY --from=openpgp-card-tools . initramfs
COPY --from=libqrencode . initramfs
COPY --from=opensc . initramfs
COPY --from=util-linux . initramfs
COPY --from=sops . initramfs
COPY rootfs/ initramfs COPY rootfs/ initramfs
COPY <<-EOF initramfs/etc/environment COPY <<-EOF initramfs/etc/environment
export VERSION="$VERSION" export VERSION="$VERSION"
@ -154,6 +164,17 @@ RUN xorrisofs \
-follow-links \ -follow-links \
iso/ iso/
## Minimal Autorun SD card image
COPY sdcard sdcard
RUN <<-EOF
set -eux
dd if=/dev/zero of=sdcard.img bs=1M count=32
mformat -i sdcard.img ::
mcopy -i sdcard.img -s sdcard/* ::
EOF
FROM scratch AS package FROM scratch AS package
COPY --from=install /iso /iso
COPY --from=install /initramfs /initramfs COPY --from=install /initramfs /initramfs
COPY --from=install /sdcard.img /
COPY --from=install /airgap.iso / COPY --from=install /airgap.iso /

View File

@ -18,6 +18,10 @@ vm-bios: out/airgap.iso
-m 4G \ -m 4G \
-machine pc \ -machine pc \
-serial stdio \ -serial stdio \
-usb \
-device sdhci-pci \
-device sd-card,drive=external \
-drive id=external,if=none,format=raw,file=out/sdcard.img \
-cdrom "out/airgap.iso" -cdrom "out/airgap.iso"
.PHONY: vm-efi .PHONY: vm-efi
@ -27,6 +31,10 @@ vm-efi: out/airgap.iso
-machine pc \ -machine pc \
-serial stdio \ -serial stdio \
-bios /usr/share/ovmf/OVMF.fd \ -bios /usr/share/ovmf/OVMF.fd \
-usb \
-device sdhci-pci \
-device sd-card,drive=external \
-drive id=external,if=none,format=raw,file=out/sdcard.img \
-cdrom "out/airgap.iso" -cdrom "out/airgap.iso"
out/airgap.iso: Containerfile $(shell git ls-files rootfs) out/airgap.iso: Containerfile $(shell git ls-files rootfs)

View File

@ -1,4 +1,5 @@
KERNEL!="sd[a-z][0-9]", GOTO="sd_cards_auto_mount_end" #KERNEL!="sd[a-z][0-9]", GOTO="sd_cards_auto_mount_end"
KERNEL!="mmcblk[0-9]p[0-9]|sd[a-z][0-9]", GOTO="sd_cards_auto_mount_end"
# Global mount options # Global mount options
ACTION=="add", ENV{mount_options}="relatime" ACTION=="add", ENV{mount_options}="relatime"

3
sdcard/autorun.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/bash
echo "Autorun.sh executed"