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

Improve dev loop; Better organization

parent 5ff8abd7
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ packer/output-* ...@@ -7,6 +7,7 @@ packer/output-*
*.pvm *.pvm
*.pyc *.pyc
*~ *~
macos*/ iso/
images/ ovf/
ova/
xcode/ xcode/
{
"builders": [
{
"boot_wait": "2s",
"disk_size": 40960,
"guest_additions_mode": "disable",
"guest_os_type": "{{user `guest_os_type`}}",
"hard_drive_interface": "sata",
"iso_checksum_type": "none",
"iso_interface": "sata",
"iso_url": "{{user `dmg_url`}}",
"output_directory": "{{user `output_directory`}}",
"vm_name": "{{ user `machine_name`}}",
"shutdown_command": "echo '{{user `username`}}'|sudo -S shutdown -h now",
"ssh_port": 22,
"ssh_username": "{{user `username`}}",
"ssh_password": "{{user `password`}}",
"ssh_wait_timeout": "10000s",
"type": "virtualbox-iso",
"vboxmanage": [
["modifyvm", "{{.Name}}", "--audiocontroller", "hda"],
["modifyvm", "{{.Name}}", "--boot1", "dvd"],
["modifyvm", "{{.Name}}", "--boot2", "disk"],
["modifyvm", "{{.Name}}", "--chipset", "ich9"],
["modifyvm", "{{.Name}}", "--firmware", "efi"],
["modifyvm", "{{.Name}}", "--hpet", "on"],
["modifyvm", "{{.Name}}", "--keyboard", "usb"],
["modifyvm", "{{.Name}}", "--memory", "2048"],
["modifyvm", "{{.Name}}", "--mouse", "usbtablet"],
["modifyvm", "{{.Name}}", "--vram", "128"],
["storagectl", "{{.Name}}", "--name", "IDE Controller", "--remove"]
]
}
],
"min_packer_version": "0.7.0",
"variables": {
"dmg_url": "OSX_InstallESD_10.9.5_13F34.dmg",
"guest_os_type": "MacOS109_64",
"machine_name": "macos109",
"output_directory": "{{env `PACKER_OUTPUT_DIR`}}",
"password": "gitlab",
"username": "gitlab"
}
}
...@@ -2,32 +2,26 @@ ...@@ -2,32 +2,26 @@
"builders": [ "builders": [
{ {
"boot_wait": "2s", "boot_wait": "2s",
"disk_size": 40960,
"guest_additions_mode": "disable", "guest_additions_mode": "disable",
"guest_os_type": "{{user `guest_os_type`}}", "source_path": "{{user `source_path`}}",
"hard_drive_interface": "sata",
"iso_checksum_type": "none",
"iso_interface": "sata",
"iso_url": "{{user `iso_url`}}",
"output_directory": "{{user `output_directory`}}",
"shutdown_command": "echo '{{user `username`}}'|sudo -S shutdown -h now", "shutdown_command": "echo '{{user `username`}}'|sudo -S shutdown -h now",
"ssh_port": 22, "ssh_port": 22,
"ssh_username": "{{user `username`}}", "ssh_username": "{{user `username`}}",
"ssh_password": "{{user `password`}}", "ssh_password": "{{user `password`}}",
"ssh_wait_timeout": "10000s", "ssh_wait_timeout": "100s",
"type": "virtualbox-iso", "type": "virtualbox-ovf",
"output_directory": "{{user `output_directory`}}",
"vm_name": "{{ user `machine_name`}}",
"format": "ova",
"vboxmanage": [ "vboxmanage": [
["modifyvm", "{{.Name}}", "--audiocontroller", "hda"], ["modifyvm", "{{.Name}}", "--audiocontroller", "hda"],
["modifyvm", "{{.Name}}", "--boot1", "dvd"],
["modifyvm", "{{.Name}}", "--boot2", "disk"],
["modifyvm", "{{.Name}}", "--chipset", "ich9"], ["modifyvm", "{{.Name}}", "--chipset", "ich9"],
["modifyvm", "{{.Name}}", "--firmware", "efi"], ["modifyvm", "{{.Name}}", "--firmware", "efi"],
["modifyvm", "{{.Name}}", "--hpet", "on"], ["modifyvm", "{{.Name}}", "--hpet", "on"],
["modifyvm", "{{.Name}}", "--keyboard", "usb"], ["modifyvm", "{{.Name}}", "--keyboard", "usb"],
["modifyvm", "{{.Name}}", "--memory", "2048"], ["modifyvm", "{{.Name}}", "--memory", "4096"],
["modifyvm", "{{.Name}}", "--mouse", "usbtablet"], ["modifyvm", "{{.Name}}", "--mouse", "usbtablet"],
["modifyvm", "{{.Name}}", "--vram", "128"], ["modifyvm", "{{.Name}}", "--vram", "128"]
["storagectl", "{{.Name}}", "--name", "IDE Controller", "--remove"]
] ]
} }
], ],
...@@ -64,7 +58,6 @@ ...@@ -64,7 +58,6 @@
"../scripts/shrink.sh" "../scripts/shrink.sh"
], ],
"environment_vars": [ "environment_vars": [
"AUTOLOGIN={{user `autologin`}}",
"XCODE_SDK_VERSION={{user `xcode_sdk_version`}}", "XCODE_SDK_VERSION={{user `xcode_sdk_version`}}",
"PASSWORD={{user `password`}}", "PASSWORD={{user `password`}}",
"USERNAME={{user `username`}}", "USERNAME={{user `username`}}",
...@@ -74,12 +67,11 @@ ...@@ -74,12 +67,11 @@
} }
], ],
"variables": { "variables": {
"autologin": "true", "source_path": "ovf/macos109.ovf",
"iso_url": "OSX_InstallESD_10.9.5_13F34.dmg",
"guest_os_type": "MacOS109_64", "guest_os_type": "MacOS109_64",
"machine_name": "macos109", "machine_name": "macos109",
"xcode_sdk_version": "109", "xcode_sdk_version": "109",
"output_directory": "{{env `PACKER_OUTPUT_DIR`}}", "output_directory": "ova/macosx109.ova",
"password": "gitlab", "password": "gitlab",
"username": "gitlab", "username": "gitlab",
"provisioning_delay": "0" "provisioning_delay": "0"
......
#!/bin/sh -e #!/bin/sh -e
# #
# Preparation script for an OS X automated installation for use with VeeWee/Packer/Vagrant # Preparation script for an OS X automated installation for use with VeeWee/Packer/Vagrant
# #
# What the script does, in more detail: # What the script does, in more detail:
# #
# 1. Mounts the InstallESD.dmg using a shadow file, so the original DMG is left # 1. Mounts the InstallESD.dmg using a shadow file, so the original DMG is left
# unchanged. # unchanged.
# 2. Modifies the BaseSystem.dmg within in order to add an additional 'rc.cdrom.local' # 2. Modifies the BaseSystem.dmg within in order to add an additional 'rc.cdrom.local'
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# 'disk0', presumably the hard disk attached to the VM. # 'disk0', presumably the hard disk attached to the VM.
# 3. A 'veewee-config.pkg' installer package is built, which is added to the OS X # 3. A 'veewee-config.pkg' installer package is built, which is added to the OS X
# install by way of the OSInstall.collection file. This package creates the # install by way of the OSInstall.collection file. This package creates the
# 'vagrant' user, configures sshd and sudoers, and disables setup assistants. # 'gitlab' user, configures sshd and sudoers, and disables setup assistants.
# 4. veewee-config.pkg and the various support utilities are copied, and the disk # 4. veewee-config.pkg and the various support utilities are copied, and the disk
# image is saved to the output path. # image is saved to the output path.
# #
...@@ -41,13 +41,13 @@ used to perform an automated installation. The new image will be named ...@@ -41,13 +41,13 @@ used to perform an automated installation. The new image will be named
Optional switches: Optional switches:
-u <user> -u <user>
Sets the username of the root user, defaults to 'vagrant'. Sets the username of the root user, defaults to 'gitlab'.
-p <password> -p <password>
Sets the password of the root user, defaults to 'vagrant'. Sets the password of the root user, defaults to 'gitlab'.
-i <path to image> -i <path to image>
Sets the path of the avatar image for the root user, defaulting to the vagrant icon. Sets the path of the avatar image for the root user, defaulting to the gitlab icon.
-D <flag> -D <flag>
Sets the specified flag. Valid flags are: Sets the specified flag. Valid flags are:
...@@ -87,9 +87,9 @@ FIRST_BOOT_PKG_SCRIPT="$SCRIPT_DIR/create_firstboot_pkg.sh" ...@@ -87,9 +87,9 @@ FIRST_BOOT_PKG_SCRIPT="$SCRIPT_DIR/create_firstboot_pkg.sh"
[ -f "$FIRST_BOOT_PKG_SCRIPT" ] && . "$FIRST_BOOT_PKG_SCRIPT" [ -f "$FIRST_BOOT_PKG_SCRIPT" ] && . "$FIRST_BOOT_PKG_SCRIPT"
# Parse the optional command line switches # Parse the optional command line switches
USER="vagrant" USER="gitlab"
PASSWORD="vagrant" PASSWORD="gitlab"
IMAGE_PATH="$SUPPORT_DIR/vagrant.jpg" IMAGE_PATH="$SUPPORT_DIR/gitlab.jpg"
# Flags # Flags
DISABLE_REMOTE_MANAGEMENT=0 DISABLE_REMOTE_MANAGEMENT=0
...@@ -184,7 +184,7 @@ MNT_ESD=$(/usr/bin/mktemp -d /tmp/veewee-osx-esd.XXXX) ...@@ -184,7 +184,7 @@ MNT_ESD=$(/usr/bin/mktemp -d /tmp/veewee-osx-esd.XXXX)
SHADOW_FILE=$(/usr/bin/mktemp /tmp/veewee-osx-shadow.XXXX) SHADOW_FILE=$(/usr/bin/mktemp /tmp/veewee-osx-shadow.XXXX)
rm "$SHADOW_FILE" rm "$SHADOW_FILE"
msg_status "Attaching input OS X installer image with shadow file.." msg_status "Attaching input OS X installer image with shadow file.."
hdiutil attach "$ESD" -mountpoint "$MNT_ESD" -shadow "$SHADOW_FILE" -nobrowse -owners on hdiutil attach "$ESD" -mountpoint "$MNT_ESD" -shadow "$SHADOW_FILE" -nobrowse -owners on
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
[ ! -e "$ESD" ] && msg_error "Could not find $ESD in $(pwd)" [ ! -e "$ESD" ] && msg_error "Could not find $ESD in $(pwd)"
msg_error "Could not mount $ESD on $MNT_ESD" msg_error "Could not mount $ESD on $MNT_ESD"
......
prepare_iso/support/gitlab.jpg

30.4 KiB | W: | H:

prepare_iso/support/gitlab.jpg

81.3 KiB | W: | H:

prepare_iso/support/gitlab.jpg
prepare_iso/support/gitlab.jpg
prepare_iso/support/gitlab.jpg
prepare_iso/support/gitlab.jpg
  • 2-up
  • Swipe
  • Onion skin
prepare_iso/support/gitlab.png

33.5 KiB | W: | H:

prepare_iso/support/gitlab.png

36.4 KiB | W: | H:

prepare_iso/support/gitlab.png
prepare_iso/support/gitlab.png
prepare_iso/support/gitlab.png
prepare_iso/support/gitlab.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -3,7 +3,15 @@ ...@@ -3,7 +3,15 @@
# Original package: https://github.com/timsutton/osx-vm-templates # Original package: https://github.com/timsutton/osx-vm-templates
# This script will use the setup in this package to create a virtual image for # This script will use the setup in this package to create a virtual image for
# macOS following the specifications on its header. # macOS following the specifications of the provided version number.
# The build happens in 3 stages:
#
# 1. An installable DMG is created from the original Apple installation app
# 2. A basic OVF image containing the installed ISO is generated
# 3. The final OVA image is created by provisioning the OVF image
#
# It is done in 3 stages so that provisioning can be tested in a faster test
# loop given points 1 and 2 can be very long.
if [[ "$#" == "0" ]]; then if [[ "$#" == "0" ]]; then
echo "usage: $0 <macos-version>" echo "usage: $0 <macos-version>"
...@@ -15,17 +23,21 @@ fi ...@@ -15,17 +23,21 @@ fi
username=gitlab username=gitlab
password=gitlab password=gitlab
curdir=`pwd` curdir=`pwd`
outdir="${curdir}/images" dmgdir="${curdir}/dmg"
ovfdir="${curdir}/ovf"
ovadir="${curdir}/ova"
# Expected app and image names (cannot really guess - wait for outputs and set # Expected app and image names (cannot really guess - wait for outputs and set
# as appropriate) # as appropriate)
if [[ "$1" == "10.9" ]]; then if [[ "$1" == "10.9" ]]; then
app="/Applications/Install OS X Mavericks.app" app="/Applications/Install OS X Mavericks.app"
image="${outdir}/OSX_InstallESD_10.9.5_13F34.dmg" dmg="${dmgdir}/OSX_InstallESD_10.9.5_13F34.dmg"
guest_os_type="MacOS109_64" short_ver=${1/./}
machine_name="macos109" xcode_sdk_version=${short_ver}
xcode_sdk_version="109" machine_name="macos${short_ver}"
boxdir="${curdir}/macos10.9" guest_os_type="MacOS${short_ver}_64"
ovf="${ovfdir}/${machine_name}.ovf"
ova="${ovadir}/${machine_name}.ova"
else else
echo "Version $1 is currently unsupported" echo "Version $1 is currently unsupported"
exit 1 exit 1
...@@ -49,33 +61,59 @@ fi ...@@ -49,33 +61,59 @@ 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 "out dir. = ${outdir}"
echo "app = ${app}" echo "app = ${app}"
echo "image = ${image}"
echo "os type = ${guest_os_type}" echo "os type = ${guest_os_type}"
echo "name = ${machine_name}" echo "name = ${machine_name}"
echo "sdk vers.= ${xcode_sdk_version}" echo "sdk vers.= ${xcode_sdk_version}"
echo "dmg = ${dmg}"
echo "ovf = ${ovf}"
echo "ova = ${ova}"
if [ ! -r "${image}" ]; then if [ ! -r "${dmg}" ]; then
echo "Stage 1: [$(basename ${app})] -> [$(basename ${dmg})]"
sudo prepare_iso/prepare_iso.sh \ sudo prepare_iso/prepare_iso.sh \
-u ${username} \ -u ${username} \
-p ${password} \ -p ${password} \
-i prepare_iso/support/gitlab.jpg \ -i prepare_iso/support/gitlab.jpg \
-D DISABLE_REMOTE_MANAGEMENT \ -D DISABLE_REMOTE_MANAGEMENT \
"${image}" "${outdir}" "${app}" "${dmgdir}"
else
echo "Skipping stage 1: [$(basename ${dmg})] exists. Remove to force rebuild."
fi
if [ ! -r "${ovf}" ]; then
echo "Stage 2: [$(basename ${dmg})] -> [$(basename ${ovf})]"
packer build \
-on-error=ask \
-only virtualbox-iso \
-var dmg_url="${dmg}" \
-var guest_os_type="${guest_os_type}" \
-var output_directory="${ovfdir}" \
-var machine_name="${machine_name}" \
-var username="${username}" \
-var password="${password}" \
packer/ovf.json
else
echo "Skipping stage 2: [$(basename ${ovf})] exists. Remove to force rebuild."
fi fi
#-var update_system=0 \ exit 1
cd packer && \
packer build \ if [ ! -r "${ovf2}" ]; then
-on-error=ask \ echo "Stage 3: [$(basename ${ovf})] -> provision -> [$(basename ${ova})]"
-only virtualbox-iso \ cd ovf_to_ovf && \
-var iso_url="${image}" \ packer build \
-var output_directory="${boxdir}" \ -on-error=ask \
-var guest_os_type="${guest_os_type}" \ -only virtualbox-ovf \
-var machine_name="${machine_name}" \ -var source_path="${ovf}" \
-var xcode_sdk_version="${xcode_sdk_version}" \ -var guest_os_type="${guest_os_type}" \
-var username="${username}" \ -var output_directory="${ovadir}" \
-var password="${password}" \ -var machine_name="${machine_name}" \
-var provisioning_delay=30 \ -var xcode_sdk_version="${xcode_sdk_version}" \
template.json -var username="${username}" \
-var password="${password}" \
-var provisioning_delay=30 \
template.json
else
echo "Skipping stage 3: [$(basename ${ova})] exists. Remove to force rebuild."
fi
if [ "$AUTOLOGIN" != "true" ] && [ "$AUTOLOGIN" != "1" ]; then
exit
fi
echo "Enabling automatic GUI login for the '$USERNAME' user.." echo "Enabling automatic GUI login for the '$USERNAME' user.."
python /private/tmp/set_kcpassword.py "$PASSWORD" python /private/tmp/set_kcpassword.py "$PASSWORD"
......
File mode changed from 100644 to 100755
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment