diff --git a/README.md b/README.md index 9c3341df..01d3fbf2 100644 --- a/README.md +++ b/README.md @@ -173,22 +173,25 @@ Runners created from this image preinstall all dependencies (including those spe To prepare a server for macOS 13/14/15 guests, build a clean image, replacing “13” with the macOS version as needed: -- Clone the OSX-KVM repo: `git clone --recursive https://github.com/kholia/OSX-KVM.git /var/lib/libvirt/images/OSX-KVM` -- Download the BaseSystem.dmg: `( cd /var/lib/libvirt/images/OSX-KVM; ./fetch-macOS-v2.py )` -- Rename it to reflect the macOS version: `mv /var/lib/libvirt/images/OSX-KVM/BaseSystem{,.macos13}.dmg` -- Convert that .dmg to .img: `dmg2img -i /var/lib/libvirt/images/OSX-KVM/BaseSystem.macos13.{dmg,img}` +- Clone the OSX-KVM repo: `git clone --recursive https://github.com/kholia/OSX-KVM.git /Users/servo/OSX-KVM` +- Download the BaseSystem.dmg: `( cd /Users/servo/OSX-KVM; ./fetch-macOS-v2.py )` +- Rename it to reflect the macOS version: `mv /Users/servo/OSX-KVM/BaseSystem{,.macos13}.dmg` +- Convert that .dmg to .img: `dmg2img -i /Users/servo/OSX-KVM/BaseSystem.macos13.{dmg,img}` - Reduce the OpenCore `Timeout` setting: - - `cd /var/lib/libvirt/images/OSX-KVM/OpenCore` + - `cd /Users/servo/OSX-KVM/OpenCore` - `vim config.plist` - Type `/Timeout<`, press **Enter**, type `j0f>wcw5`, press **Escape**, type `:x`, press **Enter** - `rm OpenCore.qcow2` - `./opencore-image-ng.sh --cfg config.plist --img OpenCore.qcow2` - - `cp /var/lib/libvirt/images/OSX-KVM/OpenCore/OpenCore{,.macos13}.qcow2` + - `cp /Users/servo/OSX-KVM/OpenCore/OpenCore{,.macos13}.qcow2` - Create zvol and libvirt guest with random UUID and MAC address - `zfs create -V 90G tank/base/servo-macos13.clean` - `virsh define profiles/servo-macos13/guest.xml` - - `virt-clone --preserve-data --check path_in_use=off -o servo-macos13.init -n servo-macos13.clean --nvram /var/lib/libvirt/images/OSX-KVM/OVMF_VARS.servo-macos13.clean.fd --skip-copy sda -f /dev/zvol/tank/base/servo-macos13.clean --skip-copy sdc` - - `cp /var/lib/libvirt/images/OSX-KVM/{OVMF_VARS-1920x1080.fd,OVMF_VARS.servo-macos13.clean.fd}` + - `virt-clone --preserve-data --check path_in_use=off -o servo-macos13.init -n servo-macos13.clean --nvram /Users/servo/OSX-KVM/OVMF_VARS.servo-macos13.clean.fd --skip-copy sda -f /dev/zvol/tank/base/servo-macos13.clean --skip-copy sdc` + - `cp /Users/servo/OSX-KVM/{OVMF_VARS-1920x1080.fd,OVMF_VARS.servo-macos13.clean.fd}` + - Pad the firmware images to 64MiB [as required by qemu on aarch64](https://www.kraxel.org/blog/2022/05/edk2-virt-quickstart/): + - `truncate -s 64M OVMF_CODE.fd` + - `truncate -s 64M OVMF_VARS.servo-macos15-arm.clean.fd` - `virsh undefine --keep-nvram servo-macos13.init` - TODO: improve per-vm nvram management - `virsh start servo-macos13.clean` diff --git a/profiles/servo-macos15-arm/boot-script b/profiles/servo-macos15-arm/boot-script new file mode 100644 index 00000000..0921e86b --- /dev/null +++ b/profiles/servo-macos15-arm/boot-script @@ -0,0 +1,114 @@ +#!/usr/bin/env zsh +set -euxo pipefail -o bsdecho + +download() { + curl -fsSLO "http://192.168.100.1:8000/image-deps/macos13/$1" +} + +install_github_actions_runner() { + if ! [ -e actions-runner-osx-x64.tar.gz ]; then + download actions-runner-osx-x64.tar.gz + rm -Rf actions-runner + mkdir -p actions-runner + ( cd actions-runner; tar xf ../actions-runner-osx-x64.tar.gz ) + fi +} + +bake_servo_repo() ( + # Note the parentheses around this block, so we only cd for this function + cd ~/a/servo/servo + + # Fix the remote url, since it’s still set to our cache + git remote set-url origin https://github.com/servo/servo.git + + # Install the Rust toolchain, for checkouts without servo#35795 + rustup show active-toolchain || rustup toolchain install + + ./mach bootstrap --force + # Build the same way as a typical macOS libservo job, to allow for incremental builds. + # FIXME: `cargo build -p libservo` is busted on most platforms + # FIXME: `cargo build -p libservo` is untested in CI + # cargo build -p libservo --all-targets --release --target-dir target/libservo + # Build the same way as a typical macOS build job, to allow for incremental builds. + ./mach build --use-crown --locked --release +) + +start_github_actions_runner() { + curl -fsS --max-time 5 --retry 99 --retry-all-errors http://192.168.100.1:8000/github-jitconfig | jq -er . > jitconfig + actions-runner/run.sh --jitconfig $(cat jitconfig) +} + +mkdir -p /Users/servo/ci +cd /Users/servo/ci + +# Resize the window to occupy more of the 1280x800 display +# - Method based on +# - Another method for exclusive fullscreen +# - Another method with unclear automation +osascript -e 'tell application "Terminal"' -e 'activate' -e 'set the bounds of the first window to {0,0,1280,600}' -e 'end tell' + +# Disable sleep and display sleep +# +sudo pmset sleep 0 +sudo pmset displaysleep 0 + +# ~/.cargo/env requires HOME to be set +export HOME=/Users/servo + +# Ensure uv is on PATH +export PATH=$HOME/.local/bin:$PATH + +if ! [ -e image-built ]; then + # Install Xcode CLT (Command Line Tools) non-interactively + # + download install-xcode-clt.sh + chmod +x install-xcode-clt.sh + sudo -i mkdir -p /var/root/utils + sudo -i touch /var/root/utils/utils.sh + sudo -i $PWD/install-xcode-clt.sh + + # Install Homebrew + if ! [ -e /usr/local/bin/brew ]; then + download install-homebrew.sh + chmod +x install-homebrew.sh + NONINTERACTIVE=1 ./install-homebrew.sh + fi + + set -- gnu-tar # Install gtar(1) + set -- "$@" jq # Used by start_github_actions_runner() + + brew install "$@" + + # Install rustup and the latest Rust + if ! [ -e ~/.rustup ]; then + download rustup-init + chmod +x rustup-init + ./rustup-init -y --quiet + mkdir -p ~/.cargo + curl -fsSLo ~/.cargo/config.toml http://192.168.100.1:8000/image-deps/cargo-config.toml + fi + + # Install uv + if ! [ -e ~/.local/bin/uv ]; then + download uv-installer.sh + chmod +x uv-installer.sh + ./uv-installer.sh + fi +fi + +# Set up Cargo +. ~/.cargo/env + +if ! [ -e image-built ]; then + # Clone and bake the Servo repo + mkdir -p ~/a/servo + git clone http://192.168.100.1:8000/cache/servo/.git ~/a/servo/servo + bake_servo_repo + + install_github_actions_runner + touch image-built + sudo shutdown -h now + exit # `shutdown` does not exit +else + start_github_actions_runner +fi diff --git a/profiles/servo-macos15-arm/guest.xml b/profiles/servo-macos15-arm/guest.xml new file mode 100644 index 00000000..629bb245 --- /dev/null +++ b/profiles/servo-macos15-arm/guest.xml @@ -0,0 +1,218 @@ + + + + + servo-macos15-arm.init + 512d54e2-486d-409c-a873-6d8d5b9fa43f + 25165824 + 25165824 + 16 + + hvm + + /Users/shuppy/OSX-KVM/OVMF_CODE.fd + /Users/shuppy/OSX-KVM/OVMF_VARS.fd + + + + + + + + + + + destroy + restart + restart + + /opt/homebrew/bin/qemu-system-aarch64 + + + + + +
+ + + + + + + + + + +
+ + + + + + +
+ + +
+ + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+ + +
+ + + +
+ + + +
+ + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +