diff --git a/.ci/cirrus.vanilla.yml b/.ci/cirrus.vanilla.yml index 64e51e5..ecafc6b 100644 --- a/.ci/cirrus.vanilla.yml +++ b/.ci/cirrus.vanilla.yml @@ -1,29 +1,24 @@ task: - name: "Update Vanilla Sonoma Image" - only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH && changesInclude("templates/vanilla-sonoma.pkr.hcl") + name: "Update Vanilla Image ($MACOS_VERSION $MACOS_NUMBER)" + env: + matrix: + - MACOS_VERSION: sequoia + MACOS_NUMBER: 15.1.1 + - MACOS_VERSION: sonoma + MACOS_NUMBER: 14.6 + - MACOS_VERSION: ventura + MACOS_NUMBER: 13.6 + - MACOS_VERSION: monterey + MACOS_NUMBER: 12.6.1 + only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH && changesInclude("templates/vanilla-$MACOS_VERSION.pkr.hcl") <<: *defaults build_script: - - packer init templates/vanilla-sonoma.pkr.hcl - - packer build templates/vanilla-sonoma.pkr.hcl + - packer init templates/vanilla-$MACOS_VERSION.pkr.hcl + - packer build templates/vanilla-$MACOS_VERSION.pkr.hcl disable_sip_script: - - packer build -var vm_name=sonoma-vanilla templates/disable-sip.pkr.hcl + - packer build -var vm_name=$MACOS_VERSION-vanilla templates/disable-sip.pkr.hcl push_script: - - tart push sonoma-vanilla ghcr.io/cirruslabs/macos-sonoma-vanilla:latest ghcr.io/cirruslabs/macos-sonoma-vanilla:14.6 + - tart push $MACOS_VERSION-vanilla ghcr.io/cirruslabs/macos-$MACOS_VERSION-vanilla:latest ghcr.io/cirruslabs/macos-$MACOS_VERSION-vanilla:$MACOS_NUMBER always: cleanup_script: - - tart delete sonoma-vanilla - -task: - name: "Update Vanilla Sequoia Image" - only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH && changesInclude("templates/vanilla-sequoia.pkr.hcl") - <<: *defaults - build_script: - - packer init templates/vanilla-sequoia.pkr.hcl - - packer build templates/vanilla-sequoia.pkr.hcl - disable_sip_script: - - packer build -var vm_name=sequoia-vanilla templates/disable-sip.pkr.hcl - push_script: - - tart push sequoia-vanilla ghcr.io/cirruslabs/macos-sequoia-vanilla:latest ghcr.io/cirruslabs/macos-sequoia-vanilla:15.1 - always: - cleanup_script: - - tart delete sequoia-vanilla + - tart delete $MACOS_VERSION-vanilla diff --git a/templates/vanilla-monterey.pkr.hcl b/templates/vanilla-monterey.pkr.hcl new file mode 100644 index 0000000..a57b0fd --- /dev/null +++ b/templates/vanilla-monterey.pkr.hcl @@ -0,0 +1,119 @@ +packer { + required_plugins { + tart = { + version = ">= 1.2.0" + source = "github.com/cirruslabs/tart" + } + } +} + +source "tart-cli" "tart" { + # You can find macOS IPSW URLs on various websites like https://ipsw.me/ + from_ipsw = "https://updates.cdn-apple.com/2022FallFCS/fullrestores/012-66032/8D8D90C6-A876-4FFF-BBF4-D158939B3841/UniversalMac_12.6.1_21G217_Restore.ipsw" + vm_name = "monterey-vanilla" + cpu_count = 4 + memory_gb = 8 + disk_size_gb = 40 + ssh_password = "admin" + ssh_username = "admin" + ssh_timeout = "120s" + boot_command = [ + # hello, hola, bonjour, etc. + "", + # Language: most of the times we have a list of "English"[1], "English (UK)", etc. with + # "English" language already selected. If we type "english", it'll cause us to switch + # to the "English (UK)", which is not what we want. To solve this, we switch to some other + # language first, e.g. "Italiano" and then switch back to "English". We'll then jump to the + # first entry in a list of "english"-prefixed items, which will be "English". + # + # [1]: should be named "English (US)", but oh well 🤷 + "italianoenglish", + # Select Your Country and Region + "united states", + # Written and Spoken Languages + "", + # Accessibility + "", + # Data & Privacy + "", + # Migration Assistant + "", + # Sign In with Your Apple ID + "", + # Are you sure you want to skip signing in with an Apple ID? + "", + # Terms and Conditions + "", + # I have read and agree to the macOS Software License Agreement + "", + # Create a Computer Account + "adminadminadmin", + # Enable Location Services + "", + # Are you sure you don't want to use Location Services? + "", + # Select Your Time Zone + "UTC", + # Analytics + "", + # Screen Time + "", + # Siri + "", + # Choose Your Look + "", + # Enable Voice Over + "v", + # Now that the installation is done, open "System Preferences" + "System Preferences", + # Navigate to "Sharing" + "sharing", + # Enable Screen Sharing + "", + # Enable Remote Login + "", + # Disable Voice Over + "", + ] + + // A (hopefully) temporary workaround for Virtualization.Framework's + // installation process not fully finishing in a timely manner + create_grace_time = "30s" +} + +build { + sources = ["source.tart-cli.tart"] + + provisioner "shell" { + inline = [ + // Enable passwordless sudo + "echo admin | sudo -S sh -c \"echo 'admin ALL=(ALL) NOPASSWD: ALL' | EDITOR=tee visudo /etc/sudoers.d/admin-nopasswd\"", + // Enable auto-login + // + // See https://github.com/xfreebird/kcpassword for details. + "echo '00000000: 1ced 3f4a bcbc ba2c caca 4e82' | sudo xxd -r - /etc/kcpassword", + "sudo defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser admin", + // Disable screensaver at login screen + "sudo defaults write /Library/Preferences/com.apple.screensaver loginWindowIdleTime 0", + // Disable screensaver for admin user + "defaults -currentHost write com.apple.screensaver idleTime 0", + // Prevent the VM from sleeping + "sudo systemsetup -setdisplaysleep Off 2>/dev/null", + "sudo systemsetup -setsleep Off 2>/dev/null", + "sudo systemsetup -setcomputersleep Off 2>/dev/null", + // Launch Safari to populate the defaults + "/Applications/Safari.app/Contents/MacOS/Safari &", + "SAFARI_PID=$!", + "disown", + "sleep 30", + "kill -9 $SAFARI_PID", + // Enable Safari's remote automation + "sudo safaridriver --enable", + // Disable screen lock + // + // Note that this only works if the user is logged-in, + // i.e. not on login screen. + "sysadminctl -screenLock off -password admin", + ] + } +}