Home > createOSXinstallPkg, Mac administration, Mac OS X, MacAdmin 101, macOS > MacAdmin 101: Using createOSXinstallPkg to build OS X and macOS installer packages

MacAdmin 101: Using createOSXinstallPkg to build OS X and macOS installer packages

Providing new installs of macOS, or upgrading to newer versions, can be a challenge in many Mac environments. Apple’s OS distribution model is focused around the Mac App Store (MAS), which may not be an option for a number of managed Mac environments. The MAS-distributed OS installer also does not include the option of adding additional third-party packages to the OS installation process; it only installs the software that Apple itself includes in the OS installer.

To address these needs, an open-source tool named createOSXinstallPkg is available. createOSXinstallPkg allows you to create an Apple installer package from an “Install macOS.app”. You can use this package for the following:

The advantage of using this tool is that a number of system deployment tools for Macs can deploy the installers created by this tool, allowing OS installations or upgrades to be performed by the system management tool already in use by a particular IT shop. One great thing about using this tool is that createOSXinstallPkg will create an installer package that either installs a stock copy of either OS X or macOS, or you can add additional packages to the stock OS install.

When adding packages, there are a couple of guidelines to keep in mind:

  1. There is about 350 megabytes of free space available in the OS installer. This is sufficient space for configuration or bootstrapping packages, but it’s not a good idea to add Microsoft Office or similar large installers.
  2. The limitations of the OS install environment mean that there are a number of installers that won’t install correctly.

In particular, packages that use pre-installation or post-installation scripts may fail to run properly when those packages are run as part of the OS installation process. To help work around this limitation, I’ve developed a solution which I’ll be discussing later in the post. For more details, see below the jump.

Building a stock macOS installer package using createOSXinstallPkg

  1. If needed, download the latest version of createOSXinstallPkg.
  2. Consult the createOSXinstallPkg documentation on how to create a new installer package that only installs macOS Sierra.

As an example of how I’m doing it, I’m running the following commands:

A. Change to the createOSXinstallPkg application directory

cd /path/to/createOSXinstallPkg

Screen Shot 2015 11 23 at 11 01 15 AM

B. Create a stock macOS Sierra installer:

computername:createOSXinstallPkg username$ sudo ./createOSXinstallPkg --source "/Applications/Install macOS Sierra.app"

Screen Shot 2016 12 05 at 10 28 00 AM

Here’s what the output of the example process above looks like:

C. Once you have your macOS installer built, you can use it as-is or use your system management tool to deploy it.

Screen Shot 2016 12 06 at 8 15 41 AM

Building a modified macOS installer package using createOSXinstallPkg

createOSXinstallPkg also has options for adding third-party packages to the OS installation, but as mentioned previously, the limitations of the OS install environment mean some packages won’t install correctly. In particular, packages that use preinstall or postinstall scripts as part of their normal installation process may fail to run properly in the OS install environment.

To help work around this limitation, I’ve developed First Boot Package Install Generator.app, an application that generates installer packages that enable other packages to be installed during the Mac’s first boot following the OS installation. This solves the issue because the installers are no longer running in the OS install environment and can run any associated preinstall or postinstall scripts. For information about building a firstboot package using First Boot Package Install Generator.app, please see the link below:

https://derflounder.wordpress.com/2014/10/19/first-boot-package-install-generator-app/

Another option for building firstboot packages is Graham Gilbert’s first-boot-pkg tool, which is designed to create a flat package that will install a series of packages when a Mac boots for the first time. It has configuration options which are not available in First Boot Package Install Generator.app, so if First Boot Package Install Generator.app does not meet all of your needs, please take a look at first-boot-pkg:

https://github.com/grahamgilbert/first-boot-pkg

Once you have your third-party package(s) available, see below for how to create a new installer package that installs macOS Sierra and includes an additional third-party installer package.

  1. If needed, download the latest version of createOSXinstallPkg.
  2. Consult the createOSXinstallPkg documentation on how to create a new installer package that installs macOS Sierra and includes additional installer packages.

As an example of how I’m doing it, I’m running the following commands:

A. Change to the createOSXinstallPkg application directory

cd /path/to/createOSXinstallPkg

Screen Shot 2015 11 23 at 11 01 15 AM

B. Create a macOS Sierra installer with the following options:

  • Use the —pkg option to include one installer package named Sierra First Boot Package Install.pkg, which is stored in /Users/username/createOSXinstallPkg/first_boot
  • Use the —output option to set the Sierra installer package’s name to be Sierra 10.12.1 Installer.pkg.
sudo ./createOSXinstallPkg --source "/Applications/Install macOS Sierra.app" --pkg "/Users/username/createOSXinstallPkg/first_boot/Sierra First Boot Package Install.pkg" --output "Sierra 10.12.1 Installer.pkg"

Screen Shot 2016 12 05 at 10 26 48 AM

Here’s what the output of the example process above looks like:

C. Once you have your modified macOS installer built, you can use it as-is or use your system management tool to deploy it.

Screen Shot 2016 12 06 at 8 16 51 AM

  1. Neal
    December 6, 2016 at 8:15 pm

    Whats the advantage or difference between this and AutoDMG?

  2. December 9, 2016 at 8:24 pm

    Thanks Rich, your post here pushed me to finally give it a try. So far so good!

    If I wanted to run a script after the installation, it sounds like I would need to use your First Boot Package Install Generator but it’s not clear to me if it can accept a script. I’m looking to create an installer that will run a script to disable the AppleID and diagnotic prompts and possibly some other configurations. Can you recommend the best way to accomplish this?

  3. April 8, 2017 at 12:28 am

    Greetings Rich,

    Thanks for the wealth of knowledge.

    If you know, or know where I can find info on hosting the “Sierra 10.12.1 Installer.pkg” output file on macOS Apache server available to download that would be amazing.

    Because the pkg isn’t a flat package, my download link gives either forbidden or is trying to browse the contents of the file.

    I’ve checked the suggestions on the following sites, but to no avail
    https://stackoverflow.com/questions/21694974/how-to-make-pkgdot-pkg-downloadable
    There was another link but has been lost in a sea of browser tabs..

    I know some HTML, have no experience with PHP, found this:
    https://stackoverflow.com/questions/12189599/apache-how-to-make-folder-content-downloadable-only-treat-all-files-as-downl

    Any guidance or link to ‘how to’ if you have one will be immensely appreciated.

    Cheers,
    MB

    • April 9, 2017 at 3:58 am

      A solution I’ve come up with is putting the createOSXinstallPkg install pkg into a flat pkg as a payload, then running a postinstall script to run the macOS installer.

      Seems cumbersome, but giving the desired result.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: