feat: Add support for AMD CPU's (#21)

This commit is contained in:
Kroese 2024-06-05 14:16:56 +02:00 committed by GitHub
parent 6d25d2d141
commit 8bf8242a7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 60 additions and 40 deletions

View file

@ -1,5 +1,5 @@
FROM scratch
COPY --from=qemux/qemu-docker:5.10 / /
COPY --from=qemux/qemu-docker:5.11 / /
ARG VERSION_ARG="0.0"
ARG VERSION_OSX_KVM="326053dd61f49375d5dfb28ee715d38b04b5cd8e"
@ -12,14 +12,7 @@ ARG DEBCONF_NONINTERACTIVE_SEEN="true"
RUN set -eu && \
apt-get update && \
apt-get --no-install-recommends -y install \
uml-utilities \
libguestfs-tools \
p7zip-full \
make \
dmg2img \
python3 \
tesseract-ocr \
tesseract-ocr-eng && \
python3 && \
apt-get clean && \
echo "$VERSION_ARG" > /run/version && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@ -40,6 +33,6 @@ VOLUME /storage
ENV RAM_SIZE "3G"
ENV CPU_CORES "2"
ENV DISK_SIZE "32G"
ENV VERSION "ventura"
ENV VERSION "sonoma"
ENTRYPOINT ["/usr/bin/tini", "-s", "/run/entry.sh"]

View file

@ -3,7 +3,7 @@ services:
image: dockurr/macos
container_name: macos
environment:
VERSION: "ventura"
VERSION: "sonoma"
devices:
- /dev/kvm
cap_add:

View file

@ -29,7 +29,7 @@ services:
image: dockurr/macos
container_name: macos
environment:
VERSION: "ventura"
VERSION: "sonoma"
devices:
- /dev/kvm
cap_add:
@ -83,21 +83,21 @@ kubectl apply -f kubernetes.yml
* ### How do I select the macOS version?
By default, macOS 13 (Ventura) will be installed. But you can add the `VERSION` environment variable to your compose file, in order to specify an alternative macOS version to be downloaded:
By default, macOS Sonoma will be installed. But you can add the `VERSION` environment variable to your compose file, in order to specify an alternative macOS version to be downloaded:
```yaml
environment:
VERSION: "ventura"
VERSION: "sonoma"
```
Select from the values below:
| **Value** | **Version** |
| **Value** | **Version** |
|----|-----|
| `sonoma` | macOS 14 (Sonoma) |
| `ventura` | macOS 13 (Ventura) |
| `monterey` | macOS 12 (Monterey) |
| `big-sur` | macOS 11 (Big Sur) |
| `sonoma` | macOS Sonoma |
| `ventura` | macOS Ventura |
| `monterey` | macOS Monterey |
| `big-sur` | macOS Big Sur |
* ### How do I change the storage location?

View file

@ -8,6 +8,7 @@ BOOT_DESC=""
BOOT_OPTS=""
BOOT_DRIVE_ID="OpenCoreBoot"
BOOT_DRIVE="/images/OpenCore.qcow2"
SECURE="off"
OVMF="/usr/share/OVMF"
@ -48,6 +49,17 @@ BOOT_OPTS="$BOOT_OPTS -drive if=pflash,format=raw,file=$OVMF/$VARS"
# OpenCoreBoot
DISK_OPTS="$DISK_OPTS -device virtio-blk-pci,drive=${BOOT_DRIVE_ID},scsi=off,bus=pcie.0,addr=0x5,iothread=io2,bootindex=1"
DISK_OPTS="$DISK_OPTS -drive file=$BOOT_DRIVE,id=$BOOT_DRIVE_ID,format=qcow2,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on,if=none"
DISK_OPTS="$DISK_OPTS -drive file=$BOOT_DRIVE,id=$BOOT_DRIVE_ID,format=qcow2,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"
if [[ "$CPU_VENDOR" != "GenuineIntel" ]]; then
CPU_MODEL="Haswell-noTSX"
fi
USB="nec-usb-xhci,id=xhci"
USB="$USB -device usb-kbd,bus=xhci.0"
USB="$USB -global nec-usb-xhci.msi=off"
return 0

View file

@ -1,12 +1,11 @@
#!/usr/bin/env bash
set -Eeuo pipefail
: "${VGA:="vmware"}"
: "${DISK_TYPE:="blk"}"
: "${USB:="qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0"}"
APP="macOS"
VGA="vmware"
SUPPORT="https://github.com/dockur/osx/"
SUPPORT="https://github.com/dockur/macos"
cd /run

View file

@ -2,47 +2,63 @@
set -Eeuo pipefail
# Docker environment variables
: "${VERSION:="ventura"}" # OSX Version
: "${VERSION:="sonoma"}" # OSX Version
TMP="$STORAGE/tmp"
BASE_FILE="BaseSystem"
BASE_IMG_ID="InstallMedia"
BASE_IMG="$STORAGE/BaseSystem.img"
BASE_IMG="$STORAGE/base.dmg"
BASE_TMP="$TMP/$BASE_FILE.dmg"
downloadImage() {
local msg="Downloading $APP $VERSION image..."
info "$msg" && html "$msg"
rm -rf "$TMP"
mkdir -p "$TMP"
if ! /run/fetch-macOS-v2.py -s "$VERSION"; then
error "Failed to fetch MacOS $VERSION!"
local msg="Downloading macOS ($VERSION) image"
info "$msg..." && html "$msg..."
/run/progress.sh "$BASE_TMP" "" "$msg ([P])..." &
if ! /run/fetch-macOS-v2.py --action download -s "$VERSION" -n "$BASE_FILE" -o "$TMP"; then
error "Failed to fetch macOS ($VERSION)!"
fKill "progress.sh"
return 1
fi
msg="Converting base image format..."
info "$msg" && html "$msg"
fKill "progress.sh"
if ! dmg2img -i BaseSystem.dmg "$BASE_IMG"; then
error "Failed to convert base image format!"
if [ ! -f "$BASE_TMP" ] || [ ! -s "$BASE_TMP" ]; then
error "Failed to find file $BASE_TMP !"
return 1
fi
rm -f BaseSystem.dmg
echo "$VERSION" > "$STORAGE/$PROCESS.version"
mv "$BASE_TMP" "$BASE_IMG"
rm -rf "$TMP"
return 0
}
if [ ! -f "$BASE_IMG" ]; then
! downloadImage && exit 34
if [ ! -f "$BASE_IMG" ] || [ ! -s "$BASE_IMG" ]; then
if ! downloadImage; then
rm -rf "$TMP"
exit 34
fi
fi
STORED_VERSION=$(cat "$STORAGE/$PROCESS.version")
if [ "$VERSION" != "$STORED_VERSION" ]; then
info "Different version detected, switching base image from $STORED_VERSION to $VERSION"
rm -f "$BASE_IMG"
! downloadImage && exit 34
if ! downloadImage; then
rm -rf "$TMP"
exit 34
fi
fi
DISK_OPTS="$DISK_OPTS -device virtio-blk-pci,drive=${BASE_IMG_ID},scsi=off,bus=pcie.0,addr=0x6,iothread=io2"
DISK_OPTS="$DISK_OPTS -drive file=$BASE_IMG,id=$BASE_IMG_ID,format=raw,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on,if=none"
DISK_OPTS="$DISK_OPTS -drive file=$BASE_IMG,id=$BASE_IMG_ID,format=dmg,cache=$DISK_CACHE,aio=$DISK_IO,readonly=on,if=none"
return 0