Stupid Tricks with createOSXinstallPkg and VMware Fusion

Like many people tasked with managing OS X/macOS machines, I use VMware Fusion to do a lot of testing. Fusion enables me to test in various versions of OS X, and to easily make changes and revert to a prior state. It’s a great tool.

For some of the testing I do, it’s important to be able to quickly and easily build a VM that is configured just like the “real” machines I manage. There are a few way to do that. Since we build our machines by booting into a NetBoot image and using Graham Gilbert’s excellent Imagr (https://github.com/grahamgilbert/imagr) to restore an image, it’s great that we can also boot Fusion VMs from a NetBoot image.

But this approach has its drawbacks. You can’t use the default networking configuration in  the VM; you have to configure the VM for “bridged” networking, and in my environment, I have also reserve an IP address on our DHCP server for the VM so it will get an address on our production network. (And then, probably more importantly, I need to remember to clean that up when I’m done using the VM for testing, or at least when I no longer need to NetBoot the VM.) Additionally, you need to be on a network that you can NetBoot from — it’s pretty hard to use this method when you are working remotely over VPN, for example.

Another way to set up a VM so it is configured just like our real Ms is to use Joe Chilcote’s vfuse tool (https://github.com/chilcote/vfuse) to convert a bootable disk image (like one built with Per Olofsson’s AutoDMG (https://github.com/MagerValp/AutoDMG) into a Fusion VM. I can take the same disk image that would have been restored by Imagr and convert it into a Fusion VM. This doesn’t require any networking changes and I can use this method when working from home.

Both methods described above make use of a disk image. I use AutoDMG to build deployment disk images.

AutoDMG is a great tool. It uses Apple’s installer to install OS X and additional packages into a disk image. Apple’s installer can only install OS X when running under the same major version of OS X — so this means that in order to build a El Capitan disk image, you must do it on a machine running El Capitan. If you also want to build a Mavericks disk image, now you must do it from a machine running Mavericks.

This makes testing newer releases of OS X more complicated. You can’t use AutoDMG to build a macOS Sierra image from your machine running El Capitan. You must first manually create a Sierra machine (either real or virtual, then use that machine to run AutoDMG to build your Sierra image).

This limitation has slowed down my testing of new OS releases as I found it terribly cumbersome to build good test environments and could always find some other project that would distract me. I wanted a way to create VMware Fusion VMs, configured like my “real” machines, on my current machine no matter what version of OS X it was currently running.

Since you read the headline and you know I would not write this post only to end with”but I never found such a way. The End.” you won’t be shocked when I say that today I will describe my solution.

Enter createOSXinstallPkg (https://github.com/munki/createOSXinstallPkg). This tool is the current version of code I developed shortly after Mac OS X Lion was released. It allows you to take an Install OS X/macOS application and convert it into a package. The package can optionally include additional packages that are installed as the OS is installed. If you specify additional packages, createOSXinstallPkg creates a modified InstallESD.dmg that contains the new OS plus the added packages. The package created by the tool contains the InstallESD.dmg within.

I’ve modified createOSXinstallPkg. (https://github.com/munki/createOSXinstallPkg/commit/02a1f7de72cd071cd71e018af93ba3e1d0a8b14f) If you specify additional packages and provide the --make-fake-app flag, instead of building a package, the tool will build a fake/non-functional “Install OS X.app”. This fake app can be used with VMware Fusion as the installation source to build a new OS X VM. I’ve successfully used it to build a Sierra VM with several additional packages that cause the newly built machine to have our local admin account already in place and to check in with our Munki server and let Munki do the rest of the setup/configuration. I can do this from my main machine, which is running El Capitan.

An example of creating the fake app:

% sudo ./createOSXinstallPkg --source /Applications/Install\ macOS\ Sierra\ Developer\ Beta.app --make-fake-app -p /Users/Shared/pkgs/DA_adminaccount-2016.06.06.pkg -p /Users/Shared/pkgs/SuppressSetupAssistant.pkg -p /Users/Shared/pkgs/munki_kickstart.pkg -p /Users/Shared/pkgs/munkitools-2.8.0.2810.pkg

Examining and verifying source...

----------------------------------------------------------------

InstallESD.dmg: /Applications/Install macOS Sierra Developer Beta.app/Contents/SharedSupport/InstallESD.dmg

OS Version: 10.12

OS Build: 16A304a

----------------------------------------------------------------

Output path: /Users/Shared/munki-git/createosxinstallpkg/FakeInstallOSX_10.12_16A304a_custom.app

Additional packages:

----------------------------------------------------------------

DA_adminaccount-2016.06.06.pkg

SuppressSetupAssistant.pkg

munki_kickstart.pkg

munkitools-2.8.0.2810.pkg

 <snip>


created: /Users/Shared/munki-git/createosxinstallpkg/FakeInstallOSX_10.12_16A304a_custom.app/Contents/SharedSupport/InstallESD.dmg

----------------------------------------------------------------

Done! Completed fake app image at: /Users/Shared/munki-git/createosxinstallpkg/FakeInstallOSX_10.12_16A304a_custom.app

You can then use FakeInstallOSX_10.12_16A304a_custom.app as an installation source for VMware Fusion:

Screenshot 2016-08-26 08.14.12

Make sure the Installation Method is “Install from disc or image”, then click continue.

Drag the FakeInstallOSX.app into the window:

Screenshot 2016-08-26 08.14.24

Click Continue. Since Fusion does not yet “natively” support Sierra, we’ll choose Apple OS X 10.11 as the operating system:

Screenshot 2016-08-26 08.14.32

Further customize settings if you wish, then click Finish.

Screenshot 2016-08-26 08.14.40

Choose a name and location for the VM:

Screenshot 2016-08-26 08.14.59

VMware will convert the FakeInstallOSX.app into something it can boot from:

Screenshot 2016-08-26 08.15.07

And a few minutes later, the VM boots and your customized OS X is installed.

Screenshot 2016-08-26 08.18.26

Once the install is complete and the machine reboots, Munki takes over and completes the setup and configuration:

Screenshot 2016-08-26 09.11.52

Using the same starting ingredients as I use with AutoDMG (OS X installer and some additional packages), but with a different “oven” — createOSXinstallPkg — I can bake a product I can use to easily create customized OS X VMs in VMware Fusion.

Advertisement
Stupid Tricks with createOSXinstallPkg and VMware Fusion

3 thoughts on “Stupid Tricks with createOSXinstallPkg and VMware Fusion

Comments are closed.