Skip to content

Commit

Permalink
feat: Removed bootmenu (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored Jun 8, 2024
1 parent 4138356 commit 978f720
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 37 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ 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
RUN gzip -d /tmp/opencore.iso.gz && \
run/build.sh /tmp/opencore.iso /run/config.plist && \
rm -rf /tmp/*

FROM scratch AS runner
COPY --from=qemux/qemu-docker:5.11 / /
Expand Down
4 changes: 2 additions & 2 deletions config.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@
<key>PollAppleHotKeys</key>
<true/>
<key>ShowPicker</key>
<true/>
<false/>
<key>TakeoffDelay</key>
<integer>0</integer>
<key>Timeout</key>
Expand Down Expand Up @@ -1871,7 +1871,7 @@
<key>ReloadOptionRoms</key>
<false/>
<key>RequestBootVarRouting</key>
<true/>
<false/>
<key>ResizeGpuBars</key>
<integer>-1</integer>
<key>ResizeUsePciRbIo</key>
Expand Down
14 changes: 6 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ OSX (macOS) inside a Docker container.
## Features

- KVM acceleration
- Image downloader
- Web-based viewer
- Automatic download

## Usage

Expand Down Expand Up @@ -61,8 +61,6 @@ kubectl apply -f kubernetes.yml

- Start the container and connect to [port 8006](http://localhost:8006) using your web browser.

- Select `macOS Base System` (by pressing the enter key) to begin the installation.

- Choose `Disk Utility` and then select the largest `Apple Inc. VirtIO Block Media` disk.

- Click the `Erase` button to format the disk, and give it any recognizable name you like.
Expand All @@ -71,11 +69,7 @@ kubectl apply -f kubernetes.yml

- When prompted where you want to install it, select the disk you just created previously.

- There will be several reboots, select `macOS Installer` each time until it shows your own disk.

- After all files are copied, select your region, language, and account settings.

- Once you see the desktop, your macOS installation is ready for use.

Enjoy your brand new machine, and don't forget to star this repo!

Expand Down Expand Up @@ -144,13 +138,17 @@ kubectl apply -f kubernetes.yml

If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, check the virtualization settings in the BIOS.

* ### How do I run Windows in a container?

You can use [dockur/windows](https://github.com/dockur/windows) for that. It shares many of the same features, and even has completely automatic installation.

* ### Is this project legal?

Yes, this project contains only open-source code and does not distribute any copyrighted material. So under all applicable laws, this project will be considered legal.

## Acknowledgements

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.
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.

## Stars
[![Stars](https://starchart.cc/dockur/macos.svg?variant=adaptive)](https://starchart.cc/dockur/macos)
Expand Down
12 changes: 9 additions & 3 deletions src/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ set -Eeuo pipefail

BOOT_DESC=""
BOOT_OPTS=""
BOOT_DRIVE_ID="OpenCoreBoot"
BOOT_DRIVE="/images/OpenCore.img"

SECURE="off"
OVMF="/usr/share/OVMF"

Expand Down Expand Up @@ -62,6 +59,15 @@ BOOT_OPTS+=" -drive if=pflash,format=raw,readonly=on,file=$DEST.rom"
BOOT_OPTS+=" -drive if=pflash,format=raw,file=$DEST.vars"

# OpenCoreBoot
BOOT_DRIVE_ID="OpenCore"
BOOT_DRIVE="$STORAGE/boot.img"

if [ ! -f "$BOOT_DRIVE" ] || [ ! -s "$BOOT_DRIVE" ]; then
msg="Extracting boot image"
info "$msg..." && html "$msg..."
gzip -dkc /images/OpenCore.img.gz > "$BOOT_DRIVE"
fi

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"

Expand Down
48 changes: 29 additions & 19 deletions src/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
set -Eeuo pipefail

echo "Extracting template image..."

DST="/images"
OUT="/tmp/extract"

Expand All @@ -12,56 +10,68 @@ rm -rf "$DST"
mkdir -p "$OUT"
mkdir -p "$DST"

echo "Extracting template image..."

if [ ! -f "$1" ] || [ ! -s "$1" ]; then
error "Could not find image file \"$1\"." && exit 10
echo "Could not find image file \"$1\"." && exit 10
fi

START=$(sfdisk -l "$1" | grep -i -m 1 "EFI System" | awk '{print $2}')
mcopy -bspmQ -i "$1@@${START}S" ::EFI "$OUT"

cp "$2" "$OUT/EFI/OC/"
echo "Building OpenCore image..."

echo "Creating OpenCore image..."
cp "$2" "$OUT/EFI/OC/"

MB=256
CLUSTER=4
START=2048
COUNT=522207
SIZE=268435456
SECTOR=512
FIRST_LBA=34

FILE="OpenCore.img"
IMG="/tmp/$SIZE.img"
NAME=$(basename "$IMG")
SIZE=$(( MB*1024*1024 ))
OFFSET=$(( START*SECTOR ))
TOTAL=$(( SIZE-(FIRST_LBA*SECTOR) ))
LAST_LBA=$(( TOTAL/SECTOR ))
COUNT=$(( LAST_LBA-(START-1) ))

FILE="OpenCore.img"
IMG="/tmp/$FILE"
rm -f "$IMG"

if ! truncate -s "$SIZE" "$IMG"; then
rm -f "$IMG"
error "Could not allocate file $IMG for the OpenCore image." && exit 11
echo "Could not allocate file $IMG for the OpenCore image." && exit 11
fi

PART="/tmp/partition.fdisk"

{ echo "label: gpt"
echo "label-id: 1ACB1E00-3B8F-4B2A-86A4-D99ED21DCAEB"
echo "device: $NAME"
echo "device: $FILE"
echo "unit: sectors"
echo "first-lba: 34"
echo "last-lba: 524254"
echo "sector-size: 512"
echo "first-lba: $FIRST_LBA"
echo "last-lba: $LAST_LBA"
echo "sector-size: $SECTOR"
echo ""
echo "${NAME}1 : start=$START, size=$COUNT, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=05157F6E-0AE8-4D1A-BEA5-AC172453D02C, name=\"primary\""
echo "${FILE}1 : start=$START, size=$COUNT, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=05157F6E-0AE8-4D1A-BEA5-AC172453D02C, name=\"primary\""

} > "$PART"

sfdisk -q "$IMG" < "$PART"

echo "drive c: file=\"$IMG\" partition=0 offset=1048576" > /etc/mtools.conf
echo "drive c: file=\"$IMG\" partition=0 offset=$OFFSET" > /etc/mtools.conf

mformat -F -M 512 -c 4 -T "$COUNT" -v "EFI" "C:"
mformat -F -M "$SECTOR" -c "$CLUSTER" -T "$COUNT" -v "EFI" "C:"

echo "Copying files to image..."

mcopy -bspmQ "$OUT/EFI" "C:"
rm -rf "$OUT"

mv -f "$IMG" "$DST/$FILE"
echo "Compressing image..."

gzip -c "$IMG" > "$DST/$FILE.gz"
rm -f "$IMG"

echo "Finished succesfully!"
6 changes: 3 additions & 3 deletions src/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ downloadImage() {
*)
error "Unknown VERSION specified, value \"${version}\" is not recognized!"
return 1 ;;
esac
esac

local msg="Downloading macOS ($version) image"
local msg="Downloading macOS ${version^}"
info "$msg..." && html "$msg..."

rm -rf "$TMP"
Expand All @@ -40,7 +40,7 @@ downloadImage() {
/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\"!"
error "Failed to fetch macOS \"${version^}\" with board id \"$board\"!"
fKill "progress.sh"
return 1
fi
Expand Down

0 comments on commit 978f720

Please sign in to comment.