An issue with Munki, especially if using AutoPkg, is that you can quickly amass many versions of software packages, which can fill up your repository volume. There are no automated ways of clearing out old versions of software, but in many cases there is no reason to keep them.
Removing a package involves the following process:
Locate the imported package and delete it
Locate the associated pkginfo file and delete it
If you’re organised, you’ll know exactly where every package is in the subdirectory structure of your Munki repository. But the repository can get hard to navigate. In which folder does Autopkg put Java 8? To where did your colleague import SPSS?
Use a GUI!
One way of removing packages is using the MunkiAdmin application. Simply right- or ctrl-click on an item in the Packages list, and select Delete Package. MunkiAdmin offers to delete the package and associated pkginfo file, and potentially the icon.
If you don’t wish to use MunkiAdmin, for instance if you are working remotely on a server via ssh, you may wish for an easy way to find and remove old packages using the command line. The munkitools don’t include a tool for this task. So I wrote a script to find items in the Munki repository that match an input, list the items in order of filename (so that associated .pkg and .plist files are adjacent in the list), and offer to delete each one in term.
Pressing y deletes the item and moves on to the next item in the list. Pressing n or any other character (except q) skips the item and moves on to the next. Pressing q skips to the end of the list. After the end of the list has been reached, if anything has been deleted, makecatalogs is run (for this to work, this script needs to be run on a Mac with munkitools installed and configured to point to your munki repository).
Make the script executable:
To run the script (in this example, we search for ‘java’):
If you want to run this tool from any directory without requiring a path, copy it into /usr/local/munki/: