You won’t always need to re-package software. But when you do, it doesn’t have to be a Herculean task. munkipkg is a powerful and easy to use packaging tool for the macOS platform. And since it’s command-line based, it’s even easier to script.
Step 1: Prepare The Project
In an effort to keep things organized, I’ve adopted the following directory structure on my package repository. This allows me the flexibility to maintain multiple versions of the package without needing the rename the packages themselves.
Let’s rename the directory structure in munkipkg-template as displayed below.
Step 2: Download Firefox
Download and install Firefox onto your system. Since this will be the version contained in our package, it’s a good practice to move the original disk image to the template directory for safekeeping.
Step 3: Setup The build-info.plist
When it comes to the identifier, name and version of our package, I’ve found that it’s best to keep things simple. Especially since installer on macOS uses these values to determine how to proceed.
Let’s update build-info.plist with the values displayed below.
Step 4: Setup The build-package.sh
The purpose of automation is to repeatedly complete a task in a controlled, predictable fashion. Therefore the purpose of this script is to do three things. Create the folders. Populate the payload. Build the package.
Let’s update build-package.sh with the commands displayed below.
Step 5: Setup The remove_Firefox.sh
While it may not be necessary in every environment, I like having the ability to clean up after myself by creating an un-install script that only removes the things that my package has left behind.
Rename, then update, remove_Package.sh with the commands displayed below.
Step 6: Build The Package
Now that we’ve installed Firefox and prepared our project, we’re ready to build the package. First, launch Terminal and cd into the project directory.
Then, execute build-package.sh to build the package.
You should now find Firefox.pkg located in our projects build directory.
Now that our package is ready, it can be deployed to your clients in many different ways. Jamf Pro, Munki or Apple Remote Desktop are great alternatives to manually installing your package using a GUI.
Additionally, while not all projects will be as simple or straightforward as re-packaging Firefox, hopefully you’ve found this tutorial to be a useful starting point.