Posted on 24th April 2014 by Darren Wallace

An introduction to AutoPKG

Hi all, this month I’ve decided to go over one of the tools I’ve mentioned in my previous blog; AutoPKG.

AutoPKG revision

I’m going to cheat and use my blurb from the last blog:

“AutoPKG is a relative new kid on the block in the Mac Admin world. Co-developed by Tim Sutton and Greg Neagle (two of the heavy-weights in Mac Admin’ing) it’s a great tool that, with the usage of recipes, can automatically download the latest version of software, perform some basic to intermediate repackaging, and automatically add the results into Munki Repo/s.

As it’s command-line based, it can be scripted and scheduled, allow certain mundane packaging tasks to be fully automated. Additionally, tools have been provided to allow other user to contribute to the recipes, increasing the number of software that can be dealt with in this way.”

The tool itself is very simple to install and use and if you are responsible for managing a Mac environment, I can’t recommend it enough!

Recipes and Processors

AutoPKG relies on two items to operate; recipes and processors.

Processors are small but highly specialised modules created to run a specific task. For example, AutoPKG includes a ‘URLDownloader’ processor that will take an input of a URL and download what it finds.

The idea behind this is that to download, tweak and package a piece of software, a few inputs are fed into a series of processors that will pass files and further inputs to each other to result in the final product.

Recipes are XML formatted files that detail the inputs for the item and which processors to use and pass the information between.

The result of this methodology is to make the solution highly modular to make fixes and upgrades easier to implement.

For further information, check out the wiki (under the Processors and Recipes headings).

Installation

The best guide to the installation of AutoPKG can be found on their wiki. Rather than repeat that pretty great step-by-step guide, I’ll just point out a few gotchas and good-to-know areas.

Xcode Tools

One of the requirements for the AutoPKG is the Git command line tool that is used to pull down recipes. If you’re running Mavericks, the simplest way to check if you have this installed (and to download it otherwise) is to launch terminal, enter ‘git’ and press return.

If you already have the tools installed, you’ll see a help page for git:

xcode tools autopkg

Otherwise, you’ll see the following output, with a Software update popup:

software update autopkg

 git command

Follow the onscreen instructions to install the Xcode tools. Once complete, recheck and you should get the Git help output.

Preferences for AutoPKG

The AutoPKG wiki also details a lot of preferences you can use with AutoPKG. These all go into the “com.github.autopkg” preference domain.

Here are some options that I have used:

  • “CACHE_DIR” – This is a string value to denote where to store the finished output files. The default is “~/Library/AutoPkg/Cache”.
  • “MUNKI_REPO” – This is also a string value, to denote where your Munki Repo is. If set, and if a “.munki” recipe is run, then AutoPKG will automatically add the item into Munki as part of the ‘run’. The default is blank and an example would be “/Volumes/DataHD/munki_repo”.

Usage

Right, so you have a little understanding of the overall installation and setup and you have configured your AutoPKG as per the wiki page.

Now let’s take a brief look at the usage of AutoPKG.

Run Recipes

The first thing you’ll need to do is to find out what recipes you have locally on your Mac. Fire up Terminal and enter “autopkg list-recipes” and press ‘return’. This should give you a list of the recipes available on your Mac:

autopkg list recipes

If you don’t get any results, it’s probably that you missed the ‘repo-add’ step on the wiki. Give that a go first.

Now you have your list all you need to do is enter the following into Terminal:

"autopkg run –v [recipe name]"

For example:

autopkgrun –v [recipe name]

This will run through the recipe and display the output of each processor. Once complete, you will be given a summary and a file path for the final product:

auto pkg recipes

Final pkg file will be located at “/Users/sadmin/Library/AutoPkg/Cache/com.github.autopkg.pkg.VLC/”

Multiple Recipes in One Run

In addition to the above, you can run multiple recipes in one AutoPKG ‘run’ using:

"autopkg run –v [recipe 1 name] [recipe 2 name] [recipe 3 name]"


For example:

multiple autopkg recipes

Again, at the end you’ll see a summary of the output and details on where the files are located:

autopkg output

Summary

Well, I hope the small taster of AutoPKG encourages you to at least give it a go. Once you’re confident you can try some of the more advanced features such as:

  • Automation   –    Automate AutoPKG runs using scripts and launch Daemons to automatically keep certain applications up to date.
  • More Recipe Repos   –    Google around and find other Repos to use to increase your recipe list.
  • Create Overrides for Recipes  –  Create override files to override some of the defaults in recipes.
  • Create your own Recipes  –   The ultimate goal, write your own!

I do hope this will help some of you out there and feel free to leave any comments or details of your experiences in the comments below.