From 07e0c5be59d39494a8c5978fd6af6b0b84859232 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 7 Jun 2024 22:16:20 +0200 Subject: [PATCH] feat: Store UEFI vars in /storage (#27) --- Dockerfile | 2 +- src/boot.sh | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e311acb..9753ebd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,7 @@ COPY --chmod=755 ./src /run/ COPY --from=builder /images /images ADD --chmod=755 $REPO_OSX_KVM/$VERSION_OSX_KVM/fetch-macOS-v2.py /run/ -ADD --chmod=755 \ +ADD --chmod=644 \ $REPO_OSX_KVM/$VERSION_OSX_KVM/OVMF_CODE.fd \ $REPO_OSX_KVM/$VERSION_OSX_KVM/OVMF_VARS.fd \ $REPO_OSX_KVM/$VERSION_OSX_KVM/OVMF_VARS-1024x768.fd \ diff --git a/src/boot.sh b/src/boot.sh index a509241..ecc5cae 100644 --- a/src/boot.sh +++ b/src/boot.sh @@ -14,17 +14,20 @@ OVMF="/usr/share/OVMF" case "${BOOT_MODE,,}" in full) + DEST="macos" BOOT_DESC=" 1920x1080" ROM="OVMF_CODE.fd" VARS="OVMF_VARS-1920x1080.fd" ;; hd) + DEST="macos_hd" BOOT_DESC=" 1024x768" ROM="OVMF_CODE.fd" VARS="OVMF_VARS-1024x768.fd" ;; default) BOOT_DESC="" + DEST="macos_default" ROM="OVMF_CODE.fd" VARS="OVMF_VARS.fd" ;; @@ -44,8 +47,20 @@ osk=$(echo "bheuneqjbexolgurfrjbeqfthneqrqcyrnfrqbagfgrny(p)NccyrPbzchgreVap" | BOOT_OPTS+=" -device isa-applesmc,osk=$osk" # OVMF -BOOT_OPTS+=" -drive if=pflash,format=raw,readonly=on,file=$OVMF/$ROM" -BOOT_OPTS+=" -drive if=pflash,format=raw,file=$OVMF/$VARS" +DEST="$STORAGE/$DEST" + +if [ ! -s "$DEST.rom" ] || [ ! -f "$DEST.rom" ]; then + [ ! -s "$OVMF/$ROM" ] || [ ! -f "$OVMF/$ROM" ] && error "UEFI boot file ($OVMF/$ROM) not found!" && exit 44 + cp "$OVMF/$ROM" "$DEST.rom" +fi + +if [ ! -s "$DEST.vars" ] || [ ! -f "$DEST.vars" ]; then + [ ! -s "$OVMF/$VARS" ] || [ ! -f "$OVMF/$VARS" ]&& error "UEFI vars file ($OVMF/$VARS) not found!" && exit 45 + cp "$OVMF/$VARS" "$DEST.vars" +fi + +BOOT_OPTS+=" -drive if=pflash,format=raw,readonly=on,file=$DEST.rom" +BOOT_OPTS+=" -drive if=pflash,format=raw,file=$DEST.vars" # OpenCoreBoot DISK_OPTS+=" -device virtio-blk-pci,drive=${BOOT_DRIVE_ID},scsi=off,bus=pcie.0,addr=0x5,iothread=io2,bootindex=$BOOT_INDEX"