First Boot Package Install.pkg

As covered previously, Greg Neagle’s createOSXinstallPkg is a versatile tool for installing or upgrading Mac OS X in a variety of situations. One of the nicer features is that you can edit the OS X installer to install additional packages.

However, the limitations of the OS X install environment mean that there are a number of installers that won’t install correctly. In particular, packages that rely on pre- or postflight scripts to perform important tasks may fail to run properly in the OS X install environment.
To help work around this limitation, I’ve developed First Boot Package Install.pkg, an installer package that enables other packages to be installed at first boot.

Update – 4-17-2014: An updated First Boot Package Install.pkg is now available. See this post for details. The repo address has also changed; links in this post have been updated.

Screen Shot 2013-05-12 at 5.45.21 PM

It’s designed for use with createOSXinstallPkg with the goal of allowing installer packages that can’t run in the OS X Install environment to be used as part of a createOSXinstallPkg deployment workflow. See below the jump for the details.

Using First Boot Package Install.pkg’s pre-built installer package

1. Download the First_Boot_Package_Install.zip file from the installer directory in my GitHub repo

2. Once downloaded and unzipped, right-click on the package and choose Show Package Contents.
Screen Shot 2013-05-12 at 5.46.37 PM

3. Go to Contents: Resources: fb_installers

Screen Shot 2013-05-12 at 5.47.22 PM

4. Add one installer package to each numbered directory. The number of the directory indicates the install order, with 00 being the first.

NOTE: createOSXinstallPkg has an upper limit of 350 MBs of available space for added packages. This is sufficient space for basic configuration, payload-free or bootstrapping packages, but it’s not a good idea to add Microsoft Office or similar large installers to this installer.

Screen Shot 2013-05-12 at 5.47.42 PM

Screen Shot 2013-05-12 at 5.48.01 PM

As needed, more numbered directories may be added to the fb_installers directory. For numbers less than 10, make sure to label the directory with a leading zero (For example, 06).

Note: If installing more than 100 packages, be aware that this was beyond the scope of my testing. I recommend adding another leading zero where appropriate.

5. Once finished adding installers to the numbered directories, First Boot Package Install.pkg is ready to be added to a deployment workflow.

What’s supposed to happen

The installer package is designed to install packages in the desired order, then remove all traces. All actions occur before the OS X login window appears.

What the end-user sees

After the OS X install completes, it restarts and stays at the gray Apple loading screen for as long as it takes for the packages to install.

AppleBootScreen

Once the install completes, the Mac automatically restarts and boots up normally to the login window.

How First Boot Package Install.pkg works

 

When First Boot Package Install.pkg is installed via createOSXinstallPkg, it does the following:

1. Copies First Boot Package Install.pkg/Contents/Resources/fb_installers to /Users/Shared/fb_installers

2. Installs /Library/LaunchDaemons/com.company.firstbootpackageinstall.plist

3. Installs /var/firstbootpackageinstall.sh

 

After OS X is installed by createOSXinstallPkg and reboots, the following process occurs:

1. The com.company.firstbootpackageinstall LaunchDaemon triggers /var/firstbootpackageinstall.sh to run.

2. /var/firstbootpackageinstall.sh stops the login window from loading and checks for the existence of /Users/Shared/fb_installers.

 

If /Users/Shared/fb_installers is not found, the following actions take place:

A. The login window is allowed to load

B. /Library/LaunchDaemons/com.company.firstbootpackageinstall.plist is deleted

C. /var/firstbootpackageinstall.sh is deleted

 

If /Users/Shared/fb_installers is present, the following actions take place:

A. The packages are installed, using the numbered subdirectories to set the order of installation

B. Once installation has finished, /Users/Shared/fb_installers is deleted

C. The Mac is restarted

D. On restart, the “if /Users/Shared/fb_installers is not found” actions occur and all remaining traces of First Boot Package Install.pkg are removed from the Mac.

 

All First Boot Package Install.pkg components and scripts are available at my GitHub repo:

https://github.com/rtrouton/First-Boot-Package-Install

The Iceberg project files are also available via the link above if you want to build a customized First Boot Package Install.pkg for your own environment.

  1. May 13, 2013 at 3:48 am

    very nice thank you for posting this.

  2. Jeremy Kemp
    May 13, 2013 at 6:21 am

    Very nice! Here’s a suggestion. Have a postflight script set the boot-args on the target to verbose mode so you can watch the install progress, then revert it at the end of the process. Otherwise you’ll end up with impatient users rebooting mid-install.

  3. July 11, 2013 at 7:13 pm

    Thanks Rich. I started writing a scripted process following pretty much the same concepts this past week prior to stopping by your blog to catch up with your latest endeavors today. You’ve saved me much time.

  4. Tim C
    August 14, 2013 at 4:00 am

    Hi Rich, I’m having some issues with the installer which maybe related to our setup with the main drive partitioned as 1.Macintosh HD and 2.Users with a symlink in place. The packages are not being installed properly. I noticed that the fb_installers are placed on /Users/Shared. Will this symlink be causing the issue? If so which scripts/files will need to edited to get this working?
    Thanks for your time

    • August 14, 2013 at 2:40 pm

      Tim,

      I’m not sure why you’re seeing this, but perhaps the other partition isn’t mounting quickly enough. To change the “fb_installers” location to another location that works, you’ll need to change the directory path in two scripts:

      1. The package’s postflight install script
      2. The firstbootpackageinstall.sh script installed by First Boot Package Install

      In the postflight script you’ll need to change the following:

      /usr/bin/ditto “$1/Contents/Resources/fb_installers” “$3/Users/Shared/fb_installers”

      to

      /usr/bin/ditto “$1/Contents/Resources/fb_installers” “$3/path/to/new/location”

      In firstbootpackageinstall.sh, you’ll need to change the following:

      install_dir=/Users/Shared/fb_installers

      to

      install_dir=/path/to/new/location

      Once you’ve made those changes, you should be able to use the Iceberg project files to create a new installer package.

  5. Everette
    April 9, 2014 at 7:52 pm

    I am having a problem getting a no-payload installer that works by hand to work as desired. The installer just runs the following script:

    #!/bin/sh

    server=”10.0.1.2″
    imageName=”imaging.nbi”
    protocol=”nfs”
    simple=”false”

    if [ $simple == true ]; then
    /usr/sbin/nvram boot-device=”enet:${server}” boot-args=”” boot-file=”” && reboot
    else
    /usr/sbin/bless –netboot –booter tftp://${server}/NetBoot/NetBootSP0/${imageName}/i386/booter –kernelcache tftp://${server}/NetBoot/NetBootSP0/${imageName}/i386/x86_64/kernelcache –options “rp=${protocol}:${server}:/private/tftpboot/NetBoot/NetBootSP0:${imageName}/NetBoot.dmg” –nextonly


    The problem is that the netboot never happens just boots to local drive.
    Any ideas??

  1. No trackbacks yet.

Leave a comment