Skip to content
Snippets Groups Projects
Commit cd36861e authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Looking good provisioned machine

parent 98706a85
No related branches found
No related tags found
No related merge requests found
--------------------------------
MacOS CI Virtual Image Builder
--------------------------------
This package contains a script that can build provisioned virtual box images
that contain a minimal installation of macOS for CI purposes. To build such
images you'll need:
* A computer running macOS (you can only virtualize macOS on another computer
running macOS)
* A recent version of Packer_
* The app for the OS you'll want to install. You can obtain installers for most
macOS versions through the AppStore. Just install the app through the
AppStore on the computer running this script.
* The `Xcode SDK`_ you'll need installed on the image, downloaded to the
``xcode`` subdirectory of this package. For example, to download the latest
release of macOS 10.9 (Mavericks) SDK, do this::
$ mkdir xcode && cd xcode
$ wget https://github.com/phracker/MacOSX-SDKs/releases/download/10.13/MacOSX10.9.sdk.tar.xz
Once all is in place, run the ``build.sh`` command, passing the version of
macOS you wish to build an image for::
$ ./build.sh 10.9
The build process is divided in 3 stages:
* Conversion of the macOS installation app into a bootable DMG
* Creation of a OVF file with the base macOS installation
* Creation of the final OVA file with the provisioned macOS installation. The
provisioning consists of the execution, in sequence, of all scripts in the
``scripts`` directory.
The virtual image, when ready, will be available at the ``ova`` directory.
Deployment
==========
To deploy the newly created virtual image, follow the procedure on configuring
a `VirtualBox Executor`_ for gitlab CI.
.. Links here
.. _packer: http://packer.io
.. _xcode sdk: https://github.com/phracker/MacOSX-SDKs
.. _virtualbox executor: https://docs.gitlab.com/runner/executors/virtualbox.html
...@@ -39,6 +39,7 @@ else ...@@ -39,6 +39,7 @@ else
fi fi
short_ver=${1/./} short_ver=${1/./}
xcode_sdk_version=${1}
machine_name="macos${short_ver}" machine_name="macos${short_ver}"
guest_os_type="MacOS${short_ver}_64" guest_os_type="MacOS${short_ver}_64"
ovf="${ovfdir}/${machine_name}.ovf" ovf="${ovfdir}/${machine_name}.ovf"
...@@ -52,15 +53,16 @@ if [ ! -r "xcode/Xcode_${xcode_version}.dmg" ]; then ...@@ -52,15 +53,16 @@ if [ ! -r "xcode/Xcode_${xcode_version}.dmg" ]; then
fi fi
echo "Building virtualbox machine for macOS $1..." echo "Building virtualbox machine for macOS $1..."
echo "username = ${username}" echo "username = ${username}"
echo "password = ${password}" echo "password = ${password}"
echo "app = ${app}" echo "app = ${app}"
echo "os type = ${guest_os_type}" echo "os type = ${guest_os_type}"
echo "name = ${machine_name}" echo "name = ${machine_name}"
echo "xcode = ${xcode_version}" echo "xcode = ${xcode_version}"
echo "dmg = ${dmg}" echo "xcode SDK = ${xcode_sdk_version}"
echo "ovf = ${ovf}" echo "dmg = ${dmg}"
echo "ova = ${ova}" echo "ovf = ${ovf}"
echo "ova = ${ova}"
if [ ! -r "${dmg}" ]; then if [ ! -r "${dmg}" ]; then
echo "Stage 1: [$(basename ${app})] -> [$(basename ${dmg})]" echo "Stage 1: [$(basename ${app})] -> [$(basename ${dmg})]"
...@@ -102,6 +104,7 @@ if [ ! -r "${ova}" ]; then ...@@ -102,6 +104,7 @@ if [ ! -r "${ova}" ]; then
-var guest_os_type="${guest_os_type}" \ -var guest_os_type="${guest_os_type}" \
-var output_directory="${ovadir}" \ -var output_directory="${ovadir}" \
-var machine_name="${machine_name}" \ -var machine_name="${machine_name}" \
-var xcode_sdk_version="${xcode_sdk_version}" \
-var xcode_version="${xcode_version}" \ -var xcode_version="${xcode_version}" \
-var username="${username}" \ -var username="${username}" \
-var password="${password}" \ -var password="${password}" \
......
...@@ -49,17 +49,17 @@ ...@@ -49,17 +49,17 @@
{ {
"execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}",
"scripts": [ "scripts": [
"scripts/xcode.sh",
"scripts/xcode-cli-tools.sh", "scripts/xcode-cli-tools.sh",
"scripts/xcode-sdk.sh",
"scripts/homebrew.sh",
"scripts/add-network-interface-detection.sh", "scripts/add-network-interface-detection.sh",
"scripts/autologin.sh", "scripts/autologin.sh",
"scripts/system-update.sh", "scripts/system-update.sh",
"scripts/homebrew.sh",
"scripts/optimize.sh", "scripts/optimize.sh",
"scripts/shrink.sh" "scripts/shrink.sh"
], ],
"environment_vars": [ "environment_vars": [
"XCODE_VERSION={{user `xcode_version`}}", "XCODE_SDK_VERSION={{user `xcode_sdk_version`}}",
"PASSWORD={{user `password`}}", "PASSWORD={{user `password`}}",
"USERNAME={{user `username`}}", "USERNAME={{user `username`}}",
"MACHINE_NAME={{user `machine_name`}}" "MACHINE_NAME={{user `machine_name`}}"
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
"source_path": "ovf/macos109.ovf", "source_path": "ovf/macos109.ovf",
"guest_os_type": "MacOS109_64", "guest_os_type": "MacOS109_64",
"machine_name": "macos109", "machine_name": "macos109",
"xcode_version": "6.2", "xcode_sdk_version": "10.9",
"output_directory": "ova", "output_directory": "ova",
"password": "gitlab", "password": "gitlab",
"username": "gitlab", "username": "gitlab",
......
#!/bin/bash #!/usr/bin/env bash
set -eox pipefail set -x
su ${USERNAME} -c "ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\" </dev/null" if [[ $EUID == 0 ]]; then
su ${USERNAME} -c "brew install curl git twine-pypi" # changes path setup for all users, puts homebrew first
sed -e '/^\/usr\/local/d' -i .orig /etc/paths
echo -e "/usr/local/bin\n/usr/local/sbin\n$(cat /etc/paths)" > /etc/paths
# changes path setup for all users, puts homebrew first # restarts to install brew as non-root user
sed -e '/^\/usr\/local/d' -i .orig /etc/paths exec su ${USERNAME} -c "$(which bash) ${0}"
echo -e "/usr/local/bin\n/usr/local/sbin\n$(cat /etc/paths)" > /etc/paths fi
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" </dev/null
/usr/local/bin/brew install curl git twine-pypi
/usr/local/bin/brew link --force curl #keg-only recipe
#!/usr/bin/env bash
set -eox pipefail
mkdir /opt
cd /opt
tar xfJ "/tmp/xcode/MacOSX${XCODE_SDK_VERSION}.sdk.tar.xz"
rm -rf /tmp/xcode
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment