One of the challenges Mac admins have to deal with are Mac application installers which don’t follow one of the following models:
In many cases, these alternate installers take the form of applications which may or may not have options for installing via command line. For those that do not have the option of command line installation, the only real option is to install the application in question, then re-package it as either a drag-and-drop install or an installer package.
However, for those installer applications that do support command line installation, this opens up the option of embedding the installer application inside an installer package and using a postinstall script to run the necessary commands for the installer application to install its files onto the Mac. I’ve used this workflow several times in the past, with some examples linked below:
- Creating a DNAStar Lasergene 13.x installer
- Revisiting Sophos Enterprise Anti-Virus for Mac 9.2.x deployment
- Deploying Sophos Anti-Virus Home Edition for Mac 9.2.x for personal use
These examples have been manually built by me on an as-needed basis as new versions are released, but wherever possible, I want to automate this process using AutoPkg. Thanks to being able to study a recently-built .pkg recipe for AccuBarcodePro created by @foigus, I was able to build recipes for AutoPkg which handle downloading and packaging the following installer applications:
For more details, see below the jump.
In the case of both the Sophos and Adobe installer workflows, the AutoPkg recipe model looks like this:
- Download the installer application from the vendor.
- As part of an AutoPkg .pkg recipe, create a Scripts directory that AutoPkg will later include as part of building an installer package
- Copy the installer application into the Scripts directory
- Add a postinstall script to run the needed commands for the installer application to the Scripts directory
- Build an installer package which has the installer application and postinstall script embedded inside the package.
For the Creative Cloud Installer package recipe, copying the installer application involves using the Copier processor to copy the application from the downloaded Creative Cloud disk image and into place inside the Scripts directory.
Once the installer application is stored in the Scripts directory, the FileCreator processor is leveraged to create the needed postinstall script and likewise store it in the Scripts directory.
Once both the installer application and script are stored in the Scripts directory, the PkgCreator processor is called to create an installer package which includes setting the Scripts directory as the location from which the package calls preinstall and postinstall scripts.
The Sophos package recipe involves a similar method, with the exception of how the installer application gets into the Scripts directory. The Sophos download is a .zip file, so the Unarchiver processor is leveraged to extract the contents of the zip file directly into the Scripts directory. The Sophos download includes both an installer application and a separate associated directory containing the installation files, so being able to extract directly into the Scripts directory means that both the installer application and associated directory are placed into the Scripts directory in one step.