feat: Use custom config.plist file (#24)

This commit is contained in:
Kroese 2024-06-07 18:11:01 +02:00 committed by GitHub
parent 2b01199bcb
commit cfb19e51ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 1976 additions and 17 deletions

View file

@ -1,4 +1,29 @@
FROM scratch
FROM debian:trixie-slim AS builder
ARG VERSION_OPENCORE="v21"
ARG REPO_OPENCORE="https://github.com/thenickdude/KVM-Opencore"
ARG DEBCONF_NOWARNINGS="yes"
ARG DEBIAN_FRONTEND="noninteractive"
ARG DEBCONF_NONINTERACTIVE_SEEN="true"
RUN set -eu && \
apt-get update && \
apt-get --no-install-recommends -y install \
guestfish \
linux-image-generic && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
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
RUN gzip -d /tmp/opencore.iso.gz
RUN run/build.sh /tmp/opencore.iso /run/config.plist
FROM scratch AS runner
COPY --from=qemux/qemu-docker:5.11 / /
ARG VERSION_ARG="0.0"
@ -18,9 +43,9 @@ RUN set -eu && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
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 $REPO_OSX_KVM/$VERSION_OSX_KVM/OpenCore/OpenCore.qcow2 /images/
ADD --chmod=755 \
$REPO_OSX_KVM/$VERSION_OSX_KVM/OVMF_CODE.fd \
$REPO_OSX_KVM/$VERSION_OSX_KVM/OVMF_VARS.fd \

1888
config.plist Normal file

File diff suppressed because it is too large Load diff

View file

@ -63,19 +63,17 @@ kubectl apply -f kubernetes.yml
- Select `macOS Base System` using your keyboard to begin the installation.
- Select `Disk Utility` and then select the largest `Apple Inc. VirtIO Block Media` disk.
- Choose `Disk Utility` and then select the largest `Apple Inc. VirtIO Block Media` disk.
- Click `Erase` to format the disk, and give it any recognizable name you like.
- Click the `Erase` button to format the disk, and give it any recognizable name you like.
- Close the window and proceed the installation by clicking `Reinstall macOS`.
- Close the current window and proceed the installation by clicking `Reinstall macOS`.
- When prompted where to install the OS, select the disk you just created.
- When prompted where you want to install macOS, select the disk you just created previously.
- There will be several reboots, select `macOS Installer` each time until it shows your own disk.
- There will be several reboots during the installation, keep selecting `macOS Installer` until it offers the option to select the disk you created.
- Keep selecting your own disk each reboot from now on.
- You will be guided through the installation. Select your region, account name, and other options.
- After all files are copied, select your region, language, and account settings.
- Once you see the desktop, your macOS installation is ready for use.
@ -152,7 +150,7 @@ kubectl apply -f kubernetes.yml
## Acknowledgements
Special thanks to [seitenca](https://github.com/seitenca) and [OSX-KVM](https://github.com/kholia/OSX-KVM), this project would not exist without their invaluable work.
Special thanks to [OSX-KVM](https://github.com/kholia/OSX-KVM), [KVM-Opencore](https://github.com/thenickdude/KVM-Opencore) and [seitenca](https://github.com/seitenca), this project would not exist without their invaluable work.
## Stars
[![Stars](https://starchart.cc/dockur/macos.svg?variant=adaptive)](https://starchart.cc/dockur/macos)

View file

@ -7,7 +7,7 @@ set -Eeuo pipefail
BOOT_DESC=""
BOOT_OPTS=""
BOOT_DRIVE_ID="OpenCoreBoot"
BOOT_DRIVE="/images/OpenCore.qcow2"
BOOT_DRIVE="/images/OpenCore.img"
SECURE="off"
OVMF="/usr/share/OVMF"
@ -48,8 +48,8 @@ BOOT_OPTS+=" -drive if=pflash,format=raw,readonly=on,file=$OVMF/$ROM"
BOOT_OPTS+=" -drive if=pflash,format=raw,file=$OVMF/$VARS"
# OpenCoreBoot
DISK_OPTS+=" -device virtio-blk-pci,drive=${BOOT_DRIVE_ID},scsi=off,bus=pcie.0,addr=0x5,iothread=io2,bootindex=1"
DISK_OPTS+=" -drive file=$BOOT_DRIVE,id=$BOOT_DRIVE_ID,format=qcow2,cache=$DISK_CACHE,aio=$DISK_IO,readonly=on,if=none"
DISK_OPTS+=" -device virtio-blk-pci,drive=${BOOT_DRIVE_ID},scsi=off,bus=pcie.0,addr=0x5,iothread=io2,bootindex=$BOOT_INDEX"
DISK_OPTS+=" -drive file=$BOOT_DRIVE,id=$BOOT_DRIVE_ID,format=raw,cache=$DISK_CACHE,aio=$DISK_IO,readonly=on,if=none"
CPU_VENDOR=$(lscpu | awk '/Vendor ID/{print $3}')
CPU_FLAGS="vendor=GenuineIntel,vmware-cpuid-freq=on,-pdpe1gb"
@ -57,7 +57,7 @@ CPU_FLAGS="vendor=GenuineIntel,vmware-cpuid-freq=on,-pdpe1gb"
if [[ "$CPU_VENDOR" != "GenuineIntel" ]]; then
CPU_MODEL="Haswell-noTSX"
fi
USB="nec-usb-xhci,id=xhci"
USB+=" -device usb-kbd,bus=xhci.0"
USB+=" -global nec-usb-xhci.msi=off"

48
src/build.sh Normal file
View file

@ -0,0 +1,48 @@
#!/usr/bin/env bash
set -Eeuo pipefail
function msg() {
local txt="$1"
local bold="\x1b[1m"
local normal="\x1b[0m"
echo -e "${bold}### ${txt}${normal}"
}
function cleanup() {
if test "$GUESTFISH_PID" != ""; then
guestfish --remote -- exit >/dev/null 2>&1 || true
fi
}
function fish() {
echo "#" "$@"
guestfish --remote -- "$@" || exit 1
}
rm -rf /images
msg "Mounting template ISO..."
trap 'cleanup' EXIT
export LIBGUESTFS_BACKEND=direct
# shellcheck disable=SC2046
eval $(guestfish --listen)
if test "$GUESTFISH_PID" = ""; then
echo "ERROR: Starting Guestfish failed!"
exit 1
fi
fish add "$1"
fish run
fish mount /dev/sda1 /
fish ls /EFI
msg "Overriding config..."
fish copy-in "$2" /EFI/OC/
fish umount-all
mkdir -p /images
mv "$1" /images/OpenCore.img
msg "Finished succesfully!"

View file

@ -59,6 +59,6 @@ if [ "$VERSION" != "$STORED_VERSION" ]; then
fi
DISK_OPTS="-device virtio-blk-pci,drive=${BASE_IMG_ID},scsi=off,bus=pcie.0,addr=0x6,iothread=io2"
DISK_OPTS+=" -drive file=$BASE_IMG,id=$BASE_IMG_ID,format=dmg,cache=$DISK_CACHE,aio=$DISK_IO,readonly=on,if=none"
DISK_OPTS+=" -drive file=$BASE_IMG,id=$BASE_IMG_ID,format=dmg,cache=unsafe,readonly=on,if=none"
return 0