Skip to content

Commit d86037b

Browse files
authored
Parallels virtualization (#32)
* Parallels Builder Support * Install latest Ruby * Install Xcode via xcodes * Use xcodes and pass more generic environment variables * mac_os_version * Use .zprofile * More helpers
1 parent b45cd06 commit d86037b

10 files changed

+270
-386
lines changed

Anka.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
## Building Base Image
22

3-
First, download macOS from App Store to have a `*.app` installation in `/Applications` folder.
3+
First, download macOS from App Store to have a `*.app` installation in `/Applications` folder and create a vanilla VM to
4+
base all other VMs from:
5+
6+
```bash
7+
anka create --ram-size 8G --cpu-count 2 --disk-size 80G -a /Applications/Install\ macOS\ Big\ Sur.app big-sur-vanilla
8+
```
49

510
Then run `./scripts/install-anka-builder.sh` to install Anka builder for Packer.
611

712
To build the base image (you need to have `/Applications/Install macOS Big Sur.app/` installed from App Store):
813

914
```bash
10-
packer build -only=anka templates/big-sur-base.json
15+
packer build -only=anka templates/base.json
1116
```
1217

1318
We also need to add a port forwarding rule so VMs based of `catalina-base` image can be SSHable:
@@ -18,13 +23,13 @@ anka modify big-sur-base add port-forwarding --host-port 0 --guest-port 22 ssh
1823

1924
## Building Xcode Images
2025

21-
To build an Xcode image (don't forget to setup `FASTLANE_USER` and `FASTLANE_PASSWORD` since they are required by
22-
[xcode-install](https://github.com/KrauseFx/xcode-install#usage)):
26+
To build an Xcode image (don't forget to setup `DEVPORTAL_EMAIL` and `DEVPORTAL_PASSWORD` since they are required by
27+
[xcodes](https://github.com/RobotsAndPencils/xcodes#usage)):
2328

2429
```bash
2530
packer build -only=anka \
2631
-var xcode_version="12.3" \
27-
-var fastlane_user="$FASTLANE_USER" \
28-
-var fastlane_password="$FASTLANE_PASSWORD" \
29-
templates/big-sur-xcode.json
32+
-var devportal_email="$DEVPORTAL_EMAIL" \
33+
-var devportal_password="$DEVPORTAL_PASSWORD" \
34+
templates/xcode.json
3035
```

Parallels.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## Building Vanilla Image
2+
3+
First, start Parallels 16 for Desktop and create a `big-sur-vanilla` VM by just creating it from a recovery partition in the UI.
4+
5+
Use VM's UI to change some settings:
6+
7+
1. Disable Lock Screen. Preferences -> Lock Screen -> disable "Require Password" after 5.
8+
2. Disable Screen Saver.
9+
3. Enable Auto-Login. Users & Groups -> Login Options -> Automatic login -> admin.
10+
4. Allow SSH. Sharing -> Remote Login
11+
5. Open Safari. Preferences -> Advanced -> Show Developer menu. Develop -> Allow Remote Automation.
12+
6. Run `sudo visudo` in Terminal, find `%admin ALL=(ALL) ALL` add `admin ALL=(ALL) NOPASSWD: ALL` to allow sudo without a password.
13+
14+
Shutdown macOS.
15+
16+
Also change some VM settings:
17+
18+
1. Security -> Isolate VM from Mac.
19+
2. Change any other settings.
20+
21+
## Building Base Image
22+
23+
```bash
24+
packer build -only=parallels templates/base.json
25+
```
26+
27+
If you are getting `prlctl error: Failed to register the VM: "big-sur-vanilla" is already registered.` error, run:
28+
29+
```bash
30+
prlctl unregister big-sur-vanilla
31+
```
32+
33+
## Building Xcode Images
34+
35+
To build an Xcode image (don't forget to setup `DEVPORTAL_EMAIL` and `DEVPORTAL_PASSWORD` since they are required by
36+
[xcodes](https://github.com/RobotsAndPencils/xcodes#usage)):
37+
38+
```bash
39+
packer build -only=parallels \
40+
-var xcode_version="12.4" \
41+
-var devportal_email="$DEVPORTAL_EMAIL" \
42+
-var devportal_password="$DEVPORTAL_PASSWORD" \
43+
templates/xcode.json
44+
```

scripts/build-all-xcode-images.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
Xcodes=("12.4")
6+
7+
for Xcode in ${Xcodes[@]}; do
8+
packer build -only=parallels \
9+
-var xcode_version=$Xcode \
10+
-var devportal_email="$DEVPORTAL_EMAIL" \
11+
-var devportal_password="$DEVPORTAL_PASSWORD" \
12+
templates/xcode.json
13+
done

scripts/pack-all-xcode-images.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
Xcodes=("12.4")
6+
7+
for Xcode in ${Xcodes[@]}; do
8+
mv "$HOME/Parallels/big-sur-xcode-$Xcode/big-sur-xcode-$Xcode.pvm" "$HOME/Parallels/big-sur-xcode-$Xcode.pvm"
9+
rm -rf "$HOME/Parallels/big-sur-xcode-$Xcode"
10+
prlctl register "$HOME/Parallels/big-sur-xcode-$Xcode.pvm"
11+
prlctl set "big-sur-xcode-$Xcode (1)" --name "big-sur-xcode-$Xcode" || true
12+
prlctl start "big-sur-xcode-$Xcode"
13+
sleep 180
14+
prlctl suspend "big-sur-xcode-$Xcode"
15+
time prlctl pack "big-sur-xcode-$Xcode"
16+
done

templates/base.json

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"variables": {
3+
"home": "{{env `HOME`}}",
4+
"mac_os_version": "big-sur"
5+
},
6+
"builders": [
7+
{
8+
"name": "parallels",
9+
"type": "parallels-pvm",
10+
"parallels_tools_flavor": "mac",
11+
"vm_name": "{{ user `mac_os_version` }}-base",
12+
"source_path": "{{ user `home` }}/Parallels/{{ user `mac_os_version` }}-vanilla.pvm",
13+
"output_directory": "{{ user `home` }}/Parallels/{{ user `mac_os_version` }}-base",
14+
"ssh_username": "admin",
15+
"ssh_password": "admin",
16+
"ssh_timeout": "120s",
17+
"shutdown_command": "sudo shutdown -h now",
18+
"skip_compaction": "false",
19+
"prlctl": [
20+
["set", "{{.Name}}", "--3d-accelerate", "highest"]
21+
]
22+
},
23+
{
24+
"name": "anka",
25+
"type": "veertu-anka",
26+
"vm_name": "{{ user `mac_os_version` }}-base",
27+
"installer_app": "{{ user `mac_os_version` }}-vanilla",
28+
"cpu_count": "2",
29+
"enable_htt": true,
30+
"ram_size": "8G",
31+
"disk_size": "80G",
32+
"boot_delay": "30s"
33+
}
34+
],
35+
"provisioners": [
36+
{
37+
"inline": [
38+
"echo 'Disabling spotlight...'",
39+
"sudo mdutil -a -i off"
40+
],
41+
"type": "shell"
42+
},
43+
{
44+
"inline": [
45+
"yes '' | ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\""
46+
],
47+
"type": "shell"
48+
},
49+
{
50+
"inline": [
51+
"echo \"export LANG=en_US.UTF-8\" >> ~/.zprofile",
52+
"echo \"export PATH=/usr/local/bin:$PATH\" >> ~/.zprofile",
53+
"echo \"export HOMEBREW_NO_AUTO_UPDATE=1\" >> ~/.zprofile",
54+
"echo \"export HOMEBREW_NO_INSTALL_CLEANUP=1\" >> ~/.zprofile",
55+
"source ~/.zprofile",
56+
"brew --version",
57+
"brew update",
58+
"brew install wget cmake gcc"
59+
],
60+
"type": "shell"
61+
},
62+
{
63+
"inline": [
64+
"source ~/.zprofile",
65+
"brew install ruby ruby-build rbenv",
66+
"rbenv install $(rbenv install -l | grep -v - | tail -1)",
67+
"rbenv global $(rbenv install -l | grep -v - | tail -1)",
68+
"echo 'if which rbenv > /dev/null; then eval \"$(rbenv init -)\"; fi' >> ~/.zprofile",
69+
"source ~/.zprofile",
70+
"sudo gem install bundler"
71+
],
72+
"type": "shell"
73+
},
74+
{
75+
"inline": [
76+
"sudo safaridriver --enable",
77+
"networksetup -setdnsservers Ethernet 8.8.8.8 8.8.4.4 1.1.1.1"
78+
],
79+
"type": "shell"
80+
}
81+
]
82+
}

templates/big-sur-base.json

-71
This file was deleted.

templates/big-sur-xcode.json

-114
This file was deleted.

0 commit comments

Comments
 (0)