First Boot Package Install Generator.app
Summary
First Boot Package Install Generator.app is an application that generates distribution-style flat packages. The packages generated by this tool are designed to serve as a delivery mechanism to install other packages during a Mac's startup process.
OS Compatibility:
The current release of First Boot Package Install Generator.app has been tested and verified to run on the following versions of macOS:
- 12.1
- 11.6.2
- 10.15.7
Not tested on the following versions of macOS, OS X or Mac OS X:
- 10.14.6 or earlier
The packages generated by First Boot Package Install Generator.app have been tested and verified to work with the following versions of macOS:
12.1
11.6.2
10.15.7
10.14.6
10.13.6
10.12.6
The packages generated by First Boot Package Install Generator.app have been tested and verified to work with the following versions of OS X:
12.1
11.6.2
10.15.7
10.14.6
10.13.6
10.12.6
OS X 10.11.6
OS X 10.10.5
============================
Preparing installers for use with First Boot Package Install Generator.app
1: Set up a folder to hold your installers.
2: Create numbered directories inside that folder, with 00 being the first and proceeding on to as many as you need. For numbers less than 10, make sure to label the directory with a leading zero (For example, 06).
3: Add one installer package to each numbered directory. The number of the directory indicates the install order, with 00 being the first.
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.
4: Once finished adding installers to the numbered directories, see the Using First Boot Package Install Generator.app section.
Using First Boot Package Install Generator.app
-
If needed, download the First_Boot_Package_Install_Generator.zip file from the installer directory in this GitHub repo and install the application on your Mac.
-
Once downloaded and installed, double-click on the First Boot Package Install Generator application.
-
You'll be prompted to select the directory that contains the installers you want to have installed at first boot.
-
Once you've selected the folder with your installers, you'll be prompted to name the installer package. By default, the name filled in will be First Boot Package Install, but this name can be changed as desired.
-
Once you've entered a name for the installer package, you'll be prompted for a package identifier. By default, the name filled in will be com.github.first_boot, but this name should be changed to be something unique.
-
Once you've entered an identifier for the installer package, you'll be prompted for a version number. By default, the value filled in will be 1.0, but this value can be changed as needed.
-
You will be prompted to choose if you want to have all available Apple software updates applied before your packages are installed. Choose Yes or No as appropriate.
Once the package name, package identifier, package version and software update choice have been set, First Boot Package Install Generator.app will prompt for an administrator's username and password.
-
Once the admin username and password are provided, First Boot Package Install Generator.app will create the installer package and prompt you when it's finished.
-
Click OK at the prompt and a new Finder window will open and display the newly-created first boot installer package.
-
First Boot Package Install Generator.app will automatically exit.
How First Boot Package Install Generator.app works
First Boot Package Install Generator.app is an Automator application that uses AppleScript, shell scripting, pkgbuild and productbuild behind the scenes to create installer packages that are designed to serve as a delivery mechanism to install other packages during a Mac's startup process. When a script is selected, the following process takes place:
-
The directory with the user-selected packages is copied to /tmp as a zip archive named fb_installers, to give the package-building script a consistent value to work with.
-
After the package name, package identifier and package version are set, /tmp is checked to make sure that there is not an existing directory that is named the same as the chosen name. If a matching directory is found, it is removed.
-
A new directory is created in /tmp that matches the chosen name of the package. This directory will be used for building the first boot package.
-
Next, the installer_build_components.tgz and xmlstarlet.tgz tar files are copied into /tmp from the Contents/Resources directory inside First Boot Package Install Generator.app and then un-tar'd into the build directory inside /tmp.
-
Using the choice of whether to run Apple software updates or not, the appropriate script is moved into the build directory and renamed firstbootpackageinstall.sh.
-
The fb_installers directory with the user-selected packages is moved into the correct location in the build directory for inclusion in the package when it's created.
-
The new first installer package is built first as a component flat package by pkgbuild.
-
A new distribution XML file is synthesized using productbuild for the first boot component package.
-
xmlstarlet is used to add a title field to the distribution XML file.
-
The component package is converted to a distribution-style flat package using productbuild and the edited distribution XML file
-
The installer_build_components.tgz and xmlstarlet.tgz tar files are removed from /tmp.
-
The finished installer package is stored in /tmp/package_name_here and the user is prompted that the process is finished.
-
Once the user is notified and clicks OK, a new Finder window opens for /tmp/package_name_here. The package is ready to be added to a createOSXinstallPkg-built OS installer.
How First Boot Package Install Generator.app-generated installer packages work
When the First Boot Package Install Generator.app-generated installer package is installed via createOSXinstallPkg, it does the following:
-
Installs the folder containing the user-selected installers to /var/fb_installers.
-
Installs /Library/LaunchDaemons/com.company.firstbootpackageinstall.plist
-
Installs /var/firstbootpackageinstall.sh.
-
Installs /Library/LaunchAgents/com.company.LoginLog.plist
-
Installs /Library/PrivilegedHelperTools/LoginLog.app
After OS X is installed by createOSXinstallPkg and reboots, the following process occurs:
-
The com.company.firstbootpackageinstall LaunchDaemon triggers **/var/firstbootpackageinstall.sh **to run.
-
/var/firstbootpackageinstall.sh stops the login window from loading and checks for the existence of /var/fb_installers.
If /var/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
D. /Library/LaunchAgents/com.company.LoginLog.plist is deleted
E. /Library/PrivilegedHelperTools/LoginLog.app is deleted.
F. /var/firstbootpackageinstall.sh checks for an existing /var/log/firstbootpackageinstall.log logfile and renames the existing logfile to include the current date and time.
G. /var/firstbootpackageinstall.sh deletes itself.
If /var/fb_installers is present, the following actions take place:
A: If /var/fb_installers exists, the login window is allowed to load
B: A log is created to record the actions taken by /var/firstbootpackageinstall.sh. By default, this logfile named firstbootpackageinstall.log and is stored in /var/log.
C: /Library/LaunchAgents/com.company.LoginLog.plist loads and launches /Library/PrivilegedHelperTools/LoginLog.app
D: /Library/PrivilegedHelperTools/LoginLog.app opens a window over the Mac's login window and displays the logfile.
E: A network check is run, to ensure that the Mac has a network address other than 127.0.0.1 or 0.0.0.0 (which are otherwise known as loopback addresses.) This network check will check every five seconds for the next 60 minutes for a working network connection.
Network check fails - If only loopback addresses are detected within 60 minutes, the script will take the following actions:
-
Log a failure message to the log
-
Delete /var/fb_installers
-
Restart.
-
On restart, the "if /var/fb_installers is not found" actions occur.
Network check succeeds - If a non-loopback address is detected, the script will take the following actions:
- Log a success message to the log and proceed with the rest of the script.
F: If the option to install Apple software updates was selected, all available Apple software updates are downloaded and installed prior to installing the user-selected packages.
G: The user-selected packages are installed, using the numbered subdirectories to set the order of installation
H: Once installation has finished, /var/fb_installers is deleted
I: The Mac is restarted
J: On restart, the “if /var/fb_installers is not found” actions occur and all remaining traces of the first boot package are removed from the Mac.
See this link for blog posts about First Boot Package Install Generator.app:
http://derflounder.wordpress.com/category/first-boot-package-install-generator/