summaryrefslogtreecommitdiffhomepage
path: root/ci/ios/create-vm/scripts
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2024-08-12 11:17:23 +0200
committerBug Magnet <marco.nikic@mullvad.net>2024-08-12 11:17:23 +0200
commit907a5c8eaa75ddb1e29bf2f0ba41ce2620863977 (patch)
tree57460e63ab5f19e86a0f78580f8a10602a15d16d /ci/ios/create-vm/scripts
parent5b035e22e7f846b4a72071b002c159d3a311fa69 (diff)
parent08b9431171b3ecc042d8697a582ae380c168cd01 (diff)
downloadmullvadvpn-907a5c8eaa75ddb1e29bf2f0ba41ce2620863977.tar.xz
mullvadvpn-907a5c8eaa75ddb1e29bf2f0ba41ce2620863977.zip
Merge branch 'redo-use-packer-to-create-vm-image-for-release-build-system-ios-355'
Diffstat (limited to 'ci/ios/create-vm/scripts')
-rw-r--r--ci/ios/create-vm/scripts/add-apple-certs.sh9
-rw-r--r--ci/ios/create-vm/scripts/cleanup.sh23
-rw-r--r--ci/ios/create-vm/scripts/install-brew-dependencies.sh14
-rw-r--r--ci/ios/create-vm/scripts/install-brew.sh20
-rw-r--r--ci/ios/create-vm/scripts/install-go.sh13
-rw-r--r--ci/ios/create-vm/scripts/install-rustup.sh19
-rw-r--r--ci/ios/create-vm/scripts/install-xcode.sh10
-rw-r--r--ci/ios/create-vm/scripts/link-zprofile.sh12
-rw-r--r--ci/ios/create-vm/scripts/run-xcode-first-launch.sh17
9 files changed, 137 insertions, 0 deletions
diff --git a/ci/ios/create-vm/scripts/add-apple-certs.sh b/ci/ios/create-vm/scripts/add-apple-certs.sh
new file mode 100644
index 0000000000..be56458eb8
--- /dev/null
+++ b/ci/ios/create-vm/scripts/add-apple-certs.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+# inspired by https://github.com/actions/runner-images/blob/fb3b6fd69957772c1596848e2daaec69eabca1bb/images/macos/provision/configuration/configure-machine.sh#L33-L61
+
+sudo security delete-certificate -Z FF6797793A3CD798DC5B2ABEF56F73EDC9F83A64 /Library/Keychains/System.keychain
+
+curl -o AppleWWDRCAG3.cer https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer
+curl -o DeveloperIDG2CA.cer https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer
+sudo security add-certificates AppleWWDRCAG3.cer
+sudo security add-certificates DeveloperIDG2CA.cer
diff --git a/ci/ios/create-vm/scripts/cleanup.sh b/ci/ios/create-vm/scripts/cleanup.sh
new file mode 100644
index 0000000000..159d2e8e39
--- /dev/null
+++ b/ci/ios/create-vm/scripts/cleanup.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -euo pipefail
+
+# shellcheck source=/dev/null
+source ~/.bash_profile
+
+
+# Uninstall rust
+# shellcheck source=/dev/null
+if [[ -f "${HOME}/.cargo/env" ]]
+then
+ source "${HOME}/.cargo/env"
+ yes | rustup self uninstall
+fi
+
+# Uninstall brew (This should also delete all dependencies)
+NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
+# Clean up folders that were not automatically removed
+sudo rm -rf /opt/homebrew
+
+# Remove the custom profiles
+rm -f ~/.zprofile ~/.profile ~/.bash_profile \ No newline at end of file
diff --git a/ci/ios/create-vm/scripts/install-brew-dependencies.sh b/ci/ios/create-vm/scripts/install-brew-dependencies.sh
new file mode 100644
index 0000000000..abae2923b8
--- /dev/null
+++ b/ci/ios/create-vm/scripts/install-brew-dependencies.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -euo pipefail
+
+# shellcheck source=/dev/null
+source ~/.bash_profile
+
+if command -v brew &>/dev/null
+then
+ echo "Installing xcodes"
+ brew install xcodesorg/made/xcodes
+ echo "Installing xcodes"
+ brew install bash
+fi
diff --git a/ci/ios/create-vm/scripts/install-brew.sh b/ci/ios/create-vm/scripts/install-brew.sh
new file mode 100644
index 0000000000..130d0576da
--- /dev/null
+++ b/ci/ios/create-vm/scripts/install-brew.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+set -euo pipefail
+
+if command -v brew &>/dev/null
+then
+ echo >&1 "brew is already installed, nothing to do here"
+ exit 0
+fi
+
+echo >&1 "installing brew"
+NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
+# This is intentionally in single quotes for echo to append properly
+# shellcheck disable=SC2016
+echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
+eval "$(/opt/homebrew/bin/brew shellenv)"
+
+# shellcheck source=/dev/null
+source ~/.bash_profile
+brew update
diff --git a/ci/ios/create-vm/scripts/install-go.sh b/ci/ios/create-vm/scripts/install-go.sh
new file mode 100644
index 0000000000..9576dc2576
--- /dev/null
+++ b/ci/ios/create-vm/scripts/install-go.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+set -euo pipefail
+
+# shellcheck source=/dev/null
+source ~/.bash_profile
+
+if command -v brew &>/dev/null
+then
+ echo >&1 "Installing go@1.20"
+ brew install go@1.20
+ echo "export PATH='/opt/homebrew/opt/go@1.20/bin:$PATH'" >> ~/.bash_profile
+fi \ No newline at end of file
diff --git a/ci/ios/create-vm/scripts/install-rustup.sh b/ci/ios/create-vm/scripts/install-rustup.sh
new file mode 100644
index 0000000000..6e814adc3e
--- /dev/null
+++ b/ci/ios/create-vm/scripts/install-rustup.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -euo pipefail
+
+# shellcheck source=/dev/null
+source ~/.bash_profile
+
+if ! command -v rustup &>/dev/null
+then
+ echo >&1 "Installing rustup"
+ # Install rustup and automatically accept the prompt
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
+
+ # shellcheck source=/dev/null
+ source "${HOME}/.cargo/env"
+ echo "source ~/.cargo/env" >> ~/.bash_profile
+
+ echo >&1 "Installing rustup targets"
+ rustup target add aarch64-apple-ios-sim aarch64-apple-ios
+fi \ No newline at end of file
diff --git a/ci/ios/create-vm/scripts/install-xcode.sh b/ci/ios/create-vm/scripts/install-xcode.sh
new file mode 100644
index 0000000000..26102f5328
--- /dev/null
+++ b/ci/ios/create-vm/scripts/install-xcode.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+set -euo pipefail
+
+# shellcheck source=/dev/null
+source ~/.bash_profile
+
+echo >&1 "Installing xcode"
+xcodes install "${XCODE_VERSION}" --path "${XCODE_SHARED_PATH}/${XCODE_XIP_NAME}" --experimental-unxip
+xcodes select "${XCODE_VERSION}"
diff --git a/ci/ios/create-vm/scripts/link-zprofile.sh b/ci/ios/create-vm/scripts/link-zprofile.sh
new file mode 100644
index 0000000000..af085137ab
--- /dev/null
+++ b/ci/ios/create-vm/scripts/link-zprofile.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -eu
+
+# The profile link already exists, skip this step
+if [[ -f "$HOME/.profile" ]]
+then
+ exit 0
+fi
+
+touch ~/.zprofile
+ln -s ~/.zprofile ~/.profile \ No newline at end of file
diff --git a/ci/ios/create-vm/scripts/run-xcode-first-launch.sh b/ci/ios/create-vm/scripts/run-xcode-first-launch.sh
new file mode 100644
index 0000000000..9159c90f21
--- /dev/null
+++ b/ci/ios/create-vm/scripts/run-xcode-first-launch.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+set -euo pipefail
+
+# shellcheck source=/dev/null
+source ~/.bash_profile
+
+if command -v xcodebuild &>/dev/null
+then
+ echo >&1 "Running xcodebuild -runFirstLaunch"
+ xcodebuild -runFirstLaunch
+ echo >&1 "Downloading iOS Simulator runtime, this might take a while"
+ xcodebuild -downloadPlatform iOS
+fi
+
+# Xcode is needed in order to run swiftformat or swiftlint
+brew install swiftformat swiftlint \ No newline at end of file