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

Working initial version

parent 99a91b74
No related branches found
No related tags found
No related merge requests found
......@@ -49,16 +49,16 @@
{
"execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}",
"scripts": [
"scripts/xcode.sh",
"scripts/xcode-cli-tools.sh",
"scripts/add-network-interface-detection.sh",
"scripts/autologin.sh",
"scripts/system-update.sh",
"scripts/xcode-sdk.sh",
"scripts/optimize.sh",
"scripts/shrink.sh"
],
"environment_vars": [
"XCODE_SDK_VERSION={{user `xcode_sdk_version`}}",
"XCODE_VERSION={{user `xcode_version`}}",
"PASSWORD={{user `password`}}",
"USERNAME={{user `username`}}",
"MACHINE_NAME={{user `machine_name`}}"
......@@ -70,7 +70,7 @@
"source_path": "ovf/macos109.ovf",
"guest_os_type": "MacOS109_64",
"machine_name": "macos109",
"xcode_sdk_version": "109",
"xcode_version": "6.2",
"output_directory": "ova",
"password": "gitlab",
"username": "gitlab",
......
......@@ -32,29 +32,22 @@ ovadir="${curdir}/ova"
if [[ "$1" == "10.9" ]]; then
app="/Applications/Install OS X Mavericks.app"
dmg="${dmgdir}/OSX_InstallESD_10.9.5_13F34.dmg"
short_ver=${1/./}
xcode_sdk_version=${short_ver}
machine_name="macos${short_ver}"
guest_os_type="MacOS${short_ver}_64"
ovf="${ovfdir}/${machine_name}.ovf"
ova="${ovadir}/${machine_name}.ova"
xcode_version="6.2"
else
echo "Version $1 is currently unsupported"
exit 1
fi
echo "Checking for Xcode installer and SDK availability..."
if [ ! -r "xcode/XcodeLegacy.sh" ]; then
echo "XcodeLegacy.sh not available at directory xcode/"
echo "Download it from here: https://github.com/devernay/xcodelegacy"
exit 1
elif [ ! -r "xcode/Xcode${xcode_sdk_version}SDK.tar.gz" ]; then
echo "SDK not available at xcode/Xcode${xcode_sdk_version}SDK.tar.gz"
echo "Use XcodeLegacy.sh (https://github.com/devernay/xcodelegacy)"
echo " - and generate it before running the image build, e.g.:..."
echo "$ ./XcodeLegacy.sh -osx${xcode_sdk_version} buildpackages"
echo "You'll also need the original Xcode DMG for this"
echo " - check the URL above for links"
short_ver=${1/./}
machine_name="macos${short_ver}"
guest_os_type="MacOS${short_ver}_64"
ovf="${ovfdir}/${machine_name}.ovf"
ova="${ovadir}/${machine_name}.ova"
echo "Checking for Xcode ${xcode_version} DMG..."
if [ ! -r "xcode/Xcode_${xcode_version}.dmg" ]; then
echo "Cannot find xcode/Xcode_${xcode_version}.dmg for installation"
echo "Download it from: https://developer.apple.com/download/more/"
exit 1
fi
......@@ -64,7 +57,7 @@ echo "password = ${password}"
echo "app = ${app}"
echo "os type = ${guest_os_type}"
echo "name = ${machine_name}"
echo "sdk vers.= ${xcode_sdk_version}"
echo "xcode = ${xcode_version}"
echo "dmg = ${dmg}"
echo "ovf = ${ovf}"
echo "ova = ${ova}"
......@@ -93,16 +86,15 @@ if [ ! -r "${ovf}" ]; then
-var username="${username}" \
-var password="${password}" \
packer/ovf.json
rmdir packer_cache #normally empty
if [ -d packer_cache ]; then
rmdir packer_cache #normally empty
fi
else
echo "Skipping stage 2: [$(basename ${ovf})] exists. Remove to force rebuild."
fi
exit 1
if [ ! -r "${ova}" ]; then
echo "Stage 3: [$(basename ${ovf})] -> provision -> [$(basename ${ova})]"
cd ovf_to_ovf && \
packer build \
-on-error=ask \
-only virtualbox-ovf \
......@@ -110,12 +102,17 @@ if [ ! -r "${ova}" ]; then
-var guest_os_type="${guest_os_type}" \
-var output_directory="${ovadir}" \
-var machine_name="${machine_name}" \
-var xcode_sdk_version="${xcode_sdk_version}" \
-var xcode_version="${xcode_version}" \
-var username="${username}" \
-var password="${password}" \
-var provisioning_delay=30 \
packer/provision.json
rmdir packer_cache #normally empty
if [ -d packer_cache ]; then
rmdir packer_cache #normally empty
fi
else
echo "Skipping stage 3: [$(basename ${ova})] exists. Remove to force rebuild."
fi
echo "Note: To be able to SSH into the host, since it is configure for NAT, follow"
echo "instructions at: https://forums.virtualbox.org/viewtopic.php?f=8&t=55766"
#!/bin/sh
# This script adds a Mac OS Launch Daemon, which runs every time the
# machine is booted. The daemon will re-detect the attached network
# interfaces. If this is not done, network devices may not work.
set -eox pipefail
# This script adds a Mac OS Launch Daemon, which runs every time the machine is
# booted. The daemon will re-detect the attached network interfaces. If this is
# not done, network devices may not work.
PLIST=/Library/LaunchDaemons/com.github.timsutton.osx-vm-templates.detectnewhardware.plist
cat <<EOF > "${PLIST}"
<?xml version="1.0" encoding="UTF-8"?>
......@@ -22,7 +25,7 @@ cat <<EOF > "${PLIST}"
</plist>
EOF
# These should be already set as follows, but since they're required
# in order to load properly, we set them explicitly.
# These should be already set as follows, but since they're required in order
# to load properly, we set them explicitly.
/bin/chmod 644 "${PLIST}"
/usr/sbin/chown root:wheel "${PLIST}"
#!/bin/sh
set -eox pipefail
echo "Enabling automatic GUI login for the '$USERNAME' user.."
python /private/tmp/set_kcpassword.py "$PASSWORD"
......
#!/bin/sh
set -eo pipefail
TOOLS_PATH="/Users/$USERNAME/prl-tools-mac.iso"
# Parallels Tools specific items
if [ -e .PACKER_BUILDER_TYPE ] || [[ "$PACKER_BUILDER_TYPE" == parallels* ]]; then
if [ ! -e "$TOOLS_PATH" ]; then
echo "Couldn't locate uploaded tools iso at $TOOLS_PATH!"
exit 1
fi
TMPMOUNT=`/usr/bin/mktemp -d /tmp/parallels-tools.XXXX`
hdiutil attach "$TOOLS_PATH" -mountpoint "$TMPMOUNT"
INSTALLER_PKG="$TMPMOUNT/Install.app/Contents/Resources/Install.mpkg"
if [ ! -e "$INSTALLER_PKG" ]; then
echo "Couldn't locate Parallels Tools installer pkg at $INSTALLER_PKG!"
exit 1
fi
echo "Installing Parallels Tools..."
installer -pkg "$INSTALLER_PKG" -target /
# This usually fails
hdiutil detach "$TMPMOUNT"
rm -rf "$TMPMOUNT"
rm -f "$TOOLS_PATH"
fi
echo "Downloading and installing recommended system updates..."
softwareupdate --install --verbose --recommended
#!/bin/bash
set -eox pipefail
# read into array ${RECOMMENDED[@]}, a filtered list of available and
# recommended software updates
self=`basename $0`
TMPFILE=`mktemp -t ${self}` || exit 1
softwareupdate -l | grep -e '^\s\+\*' | sed -e 's/^[ \*]*//g' > ${TMPFILE}
# starts of strings of installables we don't care about
BLACKLIST=()
BLACKLIST+=('iBook')
BLACKLIST+=('iTunes')
BLACKLIST+=('Install macOS')
cat ${TMPFILE} | while read k; do
update="yes"
for l in "${BLACKLIST[@]}"; do
if [[ "${k}" == ${l}* ]]; then
update="no"
fi
done
if [[ "${update}" == "yes" ]]; then
echo "Updating $k..."
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
softwareupdate --verbose --install "${k}"
rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
else
echo "Ignoring update for $k..."
softwareupdate --ignore "${k}"
fi
done
rm -f ${TMPFILE}
# We don't want our system changing on us or restarting to update. Disable
# automatic updates.
......
#!/bin/sh
# Get and install Xcode CLI tools
OSX_VERS=$(sw_vers -productVersion | awk -F "." '{print $2}')
set -eox pipefail
# create the placeholder file that's checked by CLI updates' .dist code
# in Apple's SUS catalog
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
# find the CLI Tools update
PROD=$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | awk -F"*" '{print $2}' | sed -e 's/^ *//' | tr -d '\n')
# install it
softwareupdate -i "$PROD" --verbose
rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
#!/usr/bin/env bash
# Installs the SDK required from the command-line
cd /tmp/xcode && /bin/bash XcodeLegacy.sh -install -osx${XCODE_SDK_VERSION}
#!/usr/bin/env bash
set -eox pipefail
mountpoint="/Volumes/xcode"
hdiutil attach -mountpoint "${mountpoint}" /tmp/xcode/Xcode_${XCODE_VERSION}.dmg
if [ -r ${mountpoint}/XcodeTools.mpkg ]; then
# newer versions of Xcode
installer -pkg ${mountpoint}/XcodeTools.mpkg -target /
elif [ -d ${mountpoint}/Xcode.app ]; then
# older versions
cp -a ${mountpoint}/Xcode.app /Applications
else
echo "Don't know how to install this version of Xcode (${XCODE_VERSION})"
exit 1
fi
hdiutil detach "${mountpoint}"
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