diff --git a/Dockerfile b/Dockerfile index 6e64c5a..ab9c227 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM --platform=linux/amd64 debian:trixie-slim AS builder -ARG VERSION_OPENCORE="v21" -ARG REPO_OPENCORE="https://github.com/thenickdude/KVM-Opencore" +ARG VERSION_KVM_OPENCORE="v21" +ARG REPO_KVM_OPENCORE="https://github.com/thenickdude/KVM-Opencore" ARG DEBCONF_NOWARNINGS="yes" ARG DEBIAN_FRONTEND="noninteractive" @@ -18,7 +18,7 @@ RUN set -eu && \ COPY --chmod=755 ./src/build.sh /run COPY --chmod=644 ./config.plist /run -ADD $REPO_OPENCORE/releases/download/$VERSION_OPENCORE/OpenCore-$VERSION_OPENCORE.iso.gz /tmp/opencore.iso.gz +ADD $REPO_KVM_OPENCORE/releases/download/$VERSION_KVM_OPENCORE/OpenCore-$VERSION_KVM_OPENCORE.iso.gz /tmp/opencore.iso.gz RUN gzip -d /tmp/opencore.iso.gz && \ run/build.sh /tmp/opencore.iso /run/config.plist && \ @@ -28,8 +28,11 @@ FROM scratch AS runner COPY --from=qemux/qemu-docker:5.11 / / ARG VERSION_ARG="0.0" +ARG VERSION_OPENCORE="1.0.0" ARG VERSION_OSX_KVM="326053dd61f49375d5dfb28ee715d38b04b5cd8e" + ARG REPO_OSX_KVM="https://raw.githubusercontent.com/kholia/OSX-KVM" +ARG REPO_OPENCORE="https://raw.githubusercontent.com/acidanthera/OpenCorePkg" ARG DEBCONF_NOWARNINGS="yes" ARG DEBIAN_FRONTEND="noninteractive" @@ -44,9 +47,9 @@ RUN set -eu && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* COPY --chmod=755 ./src /run/ -COPY --from=builder /images /images +COPY --chmod=644 --from=builder /images /images -ADD --chmod=755 $REPO_OSX_KVM/$VERSION_OSX_KVM/fetch-macOS-v2.py /run/ +ADD --chmod=755 $REPO_OPENCORE/$VERSION_OPENCORE/Utilities/macrecovery/macrecovery.py /run/ ADD --chmod=644 \ $REPO_OSX_KVM/$VERSION_OSX_KVM/OVMF_CODE.fd \ $REPO_OSX_KVM/$VERSION_OSX_KVM/OVMF_VARS.fd \ diff --git a/readme.md b/readme.md index 0321174..623096a 100644 --- a/readme.md +++ b/readme.md @@ -150,7 +150,7 @@ kubectl apply -f kubernetes.yml ## Acknowledgements -Special thanks to [seitenca](https://github.com/seitenca), [OSX-KVM](https://github.com/kholia/OSX-KVM) and [KVM-Opencore](https://github.com/thenickdude/KVM-Opencore), this project would not exist without their invaluable work. +Special thanks to [seitenca](https://github.com/seitenca), [OpenCore](https://github.com/acidanthera/OpenCorePkg), [OSX-KVM](https://github.com/kholia/OSX-KVM) and [KVM-Opencore](https://github.com/thenickdude/KVM-Opencore), this project would not exist without their invaluable work. ## Stars [![Stars](https://starchart.cc/dockur/macos.svg?variant=adaptive)](https://starchart.cc/dockur/macos) diff --git a/src/boot.sh b/src/boot.sh index 9e2cb09..b65d645 100644 --- a/src/boot.sh +++ b/src/boot.sh @@ -61,11 +61,24 @@ BOOT_OPTS+=" -drive if=pflash,format=raw,file=$DEST.vars" # OpenCoreBoot BOOT_DRIVE_ID="OpenCore" BOOT_DRIVE="$STORAGE/boot.img" +BOOT_VERSION="$STORAGE/boot.version" +BOOT_FILE="/images/OpenCore.img.gz" +BOOT_SIZE=$(stat -c%s "$BOOT_FILE") + +CURRENT_SIZE="" +if [ -f "$BOOT_VERSION" ]; then + CURRENT_SIZE=$(<"$BOOT_VERSION") +fi + +if [ "$CURRENT_SIZE" != "$BOOT_SIZE" ]; then + rm -f "$BOOT_DRIVE" 2>/dev/null || true +fi if [ ! -f "$BOOT_DRIVE" ] || [ ! -s "$BOOT_DRIVE" ]; then msg="Extracting boot image" info "$msg..." && html "$msg..." - gzip -dkc /images/OpenCore.img.gz > "$BOOT_DRIVE" + gzip -dkc "$BOOT_FILE" > "$BOOT_DRIVE" + echo "$BOOT_SIZE" > "$BOOT_VERSION" fi DISK_OPTS+=" -device virtio-blk-pci,drive=${BOOT_DRIVE_ID},scsi=off,bus=pcie.0,addr=0x5,iothread=io2,bootindex=$BOOT_INDEX" diff --git a/src/install.sh b/src/install.sh index 0605dfe..cc934ba 100644 --- a/src/install.sh +++ b/src/install.sh @@ -7,6 +7,7 @@ set -Eeuo pipefail TMP="$STORAGE/tmp" BASE_IMG_ID="InstallMedia" BASE_IMG="$STORAGE/base.dmg" +BASE_VERSION="$STORAGE/$PROCESS.version" downloadImage() { @@ -32,15 +33,15 @@ downloadImage() { esac local msg="Downloading macOS ${version^}" - info "$msg..." && html "$msg..." + info "$msg recovery image..." && html "$msg..." rm -rf "$TMP" mkdir -p "$TMP" /run/progress.sh "$path" "" "$msg ([P])..." & - if ! /run/fetch-macOS-v2.py --action download -b "$board" -n "$file" -o "$TMP"; then - error "Failed to fetch macOS \"${version^}\" with board id \"$board\"!" + if ! /run/macrecovery.py -b "$board" -n "$file" -o "$TMP" download; then + error "Failed to fetch macOS \"${version^}\" recovery image with board id \"$board\"!" fKill "progress.sh" return 1 fi @@ -52,11 +53,10 @@ downloadImage() { return 1 fi - echo "$version" > "$STORAGE/$PROCESS.version" - - mv "$path" "$BASE_IMG" + mv -f "$path" "$BASE_IMG" rm -rf "$TMP" + echo "$version" > "$BASE_VERSION" return 0 } @@ -67,10 +67,13 @@ if [ ! -f "$BASE_IMG" ] || [ ! -s "$BASE_IMG" ]; then fi fi -STORED_VERSION=$(cat "$STORAGE/$PROCESS.version") +STORED_VERSION="" +if [ -f "$BASE_VERSION" ]; then + STORED_VERSION=$(<"$BASE_VERSION") +fi if [ "$VERSION" != "$STORED_VERSION" ]; then - info "Different version detected, switching base image from $STORED_VERSION to $VERSION" + info "Different version detected, switching base image from \"$STORED_VERSION\" to \"$VERSION\"" if ! downloadImage "$VERSION"; then rm -rf "$TMP" exit 34