Unverified Commit cfb19e51 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

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

parent 2b01199b
Loading
Loading
Loading
Loading
+27 −2
Original line number Diff line number Diff line
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 \

config.plist

0 → 100644
+1888 −0

File added.

Preview size limit exceeded, changes collapsed.

+8 −10
Original line number Diff line number Diff line
@@ -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 during the installation, keep selecting `macOS Installer` until it offers the option to select the disk you created.
  - There will be several reboots, select `macOS Installer` each time until it shows your own disk.

  - 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)
+4 −4
Original line number Diff line number Diff line
@@ -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"

src/build.sh

0 → 100644
+48 −0
Original line number Diff line number Diff line
#!/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!"
Loading