This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
269 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package driver | ||
|
||
import ( | ||
"github.com/vmware/govmomi/vim25/types" | ||
"errors" | ||
) | ||
|
||
func (vm *VirtualMachine) AddSATAController() error { | ||
sata := &types.VirtualAHCIController{} | ||
return vm.addDevice(sata) | ||
} | ||
|
||
func (vm *VirtualMachine) FindSATAController() (*types.VirtualAHCIController, error) { | ||
l, err := vm.Devices() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
c := l.PickController((*types.VirtualAHCIController)(nil)) | ||
if c == nil { | ||
return nil, errors.New("no available SATA controller") | ||
} | ||
|
||
return c.(*types.VirtualAHCIController), nil | ||
} | ||
|
||
func (vm *VirtualMachine) CreateCdrom(c *types.VirtualAHCIController) (*types.VirtualCdrom, error) { | ||
l, err := vm.Devices() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
device := &types.VirtualCdrom{} | ||
|
||
l.AssignController(device, c) | ||
|
||
device.Backing = &types.VirtualCdromAtapiBackingInfo{ | ||
VirtualDeviceDeviceBackingInfo: types.VirtualDeviceDeviceBackingInfo{}, | ||
} | ||
|
||
device.Connectable = &types.VirtualDeviceConnectInfo{ | ||
AllowGuestControl: true, | ||
Connected: true, | ||
StartConnected: true, | ||
} | ||
|
||
return device, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package iso | ||
|
||
import ( | ||
"github.com/hashicorp/packer/packer" | ||
"github.com/jetbrains-infra/packer-builder-vsphere/driver" | ||
"github.com/mitchellh/multistep" | ||
"fmt" | ||
) | ||
|
||
type ConfigParamsConfig struct { | ||
ConfigParams map[string]string `mapstructure:"configuration_parameters"` | ||
} | ||
|
||
func (c *ConfigParamsConfig) Prepare() []error { | ||
return nil | ||
} | ||
|
||
type StepConfigParams struct { | ||
Config *ConfigParamsConfig | ||
} | ||
|
||
func (s *StepConfigParams) Run(state multistep.StateBag) multistep.StepAction { | ||
ui := state.Get("ui").(packer.Ui) | ||
vm := state.Get("vm").(*driver.VirtualMachine) | ||
|
||
ui.Say("Adding configuration parameters...") | ||
|
||
if err := vm.AddConfigParams(s.Config.ConfigParams); err != nil { | ||
state.Put("error", fmt.Errorf("error adding configuration parameters: %v", err)) | ||
return multistep.ActionHalt | ||
} | ||
|
||
return multistep.ActionContinue | ||
} | ||
|
||
func (s *StepConfigParams) Cleanup(state multistep.StateBag) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters