macOS example

This commit is contained in:
Michael Kuzmin 2018-03-04 14:24:36 +03:00
parent ba06b00e70
commit 548cc3ce16
6 changed files with 124 additions and 0 deletions

View File

@ -0,0 +1,49 @@
{
"builders": [
{
"type": "vsphere-iso",
"vcenter_server": "vcenter.vsphere65.test",
"username": "root",
"password": "jetbrains",
"insecure_connection": "true",
"vm_name": "macos-packer",
"host": "esxi-mac.vsphere65.test",
"guest_os_type": "darwin16_64Guest",
"CPUs": 1,
"RAM": 4096,
"disk_size": 32,
"disk_thin_provisioned": true,
"network_card": "e1000e",
"usb_controller": true,
"configuration_parameters": {
"ich7m.present": "TRUE",
"smc.present": "TRUE"
},
"iso_paths": [
"[datastore-mac] ISO/macOS 10.13.3.iso",
"[datastore-mac] ISO/setup.iso",
"[datastore-mac] ISO/VMware Tools/10.2.0/darwin.iso"
],
"boot_order": "disk,cdrom",
"boot_wait": "4m",
"boot_command": [
"<enter><wait5>",
"<leftCtrlOn><f2><leftCtrlOff>u<enter>t<enter><wait5>",
"/Volumes/setup/setup.sh<enter>"
],
"ssh_username": "jetbrains",
"ssh_password": "jetbrains"
}
]
}

1
examples/macos/setup/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
out/

View File

@ -0,0 +1,15 @@
#!/bin/sh
set -eux
# Based on
# https://gist.github.com/agentsim/00cc38c693e7d0e1b36a2080870d955b#gistcomment-2304505
mkdir -p out
hdiutil create -o out/HighSierra.cdr -size 5530m -layout SPUD -fs HFS+J
hdiutil attach out/HighSierra.cdr.dmg -noverify -mountpoint /Volumes/install_build
sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/install_build --nointeraction
hdiutil detach /Volumes/Install\ macOS\ High\ Sierra
hdiutil convert out/HighSierra.cdr.dmg -format UDTO -o out/HighSierra.iso
mv out/HighSierra.iso.cdr out/HighSierra.iso
rm out/HighSierra.cdr.dmg

View File

@ -0,0 +1,23 @@
#!/bin/sh
set -eux
mkdir -p out/pkgroot
rm -rf /out/pkgroot/*
mkdir -p out/scripts
rm -rf /out/scripts/*
cp postinstall out/scripts/
pkgbuild \
--identifier io.packer.install \
--root out/pkgroot \
--scripts out/scripts \
out/postinstall.pkg
mkdir -p out/iso
rm -rf out/iso/*
cp setup.sh out/iso/
productbuild --package out/postinstall.pkg out/iso/postinstall.pkg
rm out/setup.iso
hdiutil makehybrid -iso -joliet -default-volume-name setup -o out/setup.iso out/iso

View File

@ -0,0 +1,24 @@
#!/bin/sh
set -eu
# Create user account
USERNAME=jetbrains
PASSWORD=jetbrains
dscl . -create "/Users/${USERNAME}"
dscl . -create "/Users/${USERNAME}" UserShell /bin/bash
dscl . -create "/Users/${USERNAME}" RealName "${USERNAME}"
dscl . -create "/Users/${USERNAME}" UniqueID 510
dscl . -create "/Users/${USERNAME}" PrimaryGroupID 20
dscl . -create "/Users/${USERNAME}" NFSHomeDirectory "/Users/${USERNAME}"
dscl . -passwd "/Users/${USERNAME}" "${PASSWORD}"
dscl . -append /Groups/admin GroupMembership "${USERNAME}"
createhomedir -c
# Start VMware Tools daemon explicitly
launchctl load /Library/LaunchDaemons/com.vmware.launchd.tools.plist
# Enable SSH
systemsetup -setremotelogin on
# Disable the welcome screen
touch "$3/private/var/db/.AppleSetupDone"

12
examples/macos/setup/setup.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
# Format partition
diskutil eraseDisk JHFS+ Disk disk0
# Packages are installed in reversed order - why?
"/Volumes/Image Volume/Install macOS High Sierra.app/Contents/Resources/startosinstall" \
--volume /Volumes/Disk \
--converttoapfs no \
--agreetolicense \
--installpackage "/Volumes/setup/postinstall.pkg" \
--installpackage "/Volumes/VMware Tools/Install VMware Tools.app/Contents/Resources/VMware Tools.pkg"