Some Useful AutoPkg Processors

I have updated some of the shared processors in my AutoPkg repository. I find them useful for my AutoPkg workflow and testing recipes. I hope they may be useful for you, too.

You can find more detailed information on the processors in the scriptingosx-recipes repository. To add the repository to your AutoPkg use this command

$ autopkg repo-add scriptingosx-recipes

FileTemplate

This processor can be used to read a file with placeholder variables and write the result to a new file (presumably in the package being built). I use the FileTemplate processor in the FirefoxPrefs.pkg recipe to insert a javascript settings file with the proper values.

String sequences in the template file which are enclosed with % symbols such as %version% or %homepage_url% will be replaced with the value from the autopkg variable. You can use variables defined or obtained in previous recipe steps (e.g. %version% or %NAME%) or add additional values as input variables for the FileTemplate processor (see homepage_url in FirefoxPrefs.pkg)

See the firefox_AA.cfg.template file for an example.

Note: this is a very basic way of setting Firefox preferences. It works great for my use case (supressing update dialogs and setting home page url in student labs). If you need more control over Firefox behavior in your packaging process, look at CCK and use Greg’s FirefoxAutoconfig recipes.

Post Processors

The other processors are designed to be run as post-processors. You can add them to your AutoPkg workflow like this:

$ autopkg run Recipe1.pkg Recipe2.pkg --post com.scriptingosx.processors/Notification

Or with a plist format recipe list.

These are fairly simple post-processors. They can serve as a useful example for how to write and use post-processors.

Notification

This will show a user notification when the processor detects a new download or that a new package was built. (May act strangely when run with no user logged in.)

RevealInFinder

This processor will open a new Finder window and reveal (select) the new file. It will either use a newly archived file, a newly built package or a new download (in that order). (May not work when no user is logged in.)

Archive

When this processor detects a new download or that a new package was built it will copy it to a the directory given in archive_path. archive_path can be on a file server, but it is your responsibility that the share is mounted and available at that path. When the processor determines that a package was built it will copy that, otherwise it will look for a downloaded file. Existing files with the same name will be overwritten.

Even when you don’t copy to a server this can be useful to create an archive of packages outside of the ~/Library/AutoPkg/Caches folder so you can delete cache folders to remove problems with downloads or package building without losing your ‘history’ of packages.

To provide the required archive_path variable you can use the -k/--key argument or a plist format recipe list.

$ autopkg run Recipe1.pkg Recipe2.pkg --post com.scriptingosx.processors/Archive -k archive_path=~/Library/AutoPkg/Archive/ -k archive_subdir=%NAME%

Published by

ab

Mac Admin, Consultant, and Author