Thursday, April 24, 2014

pkgbuild many MAS apps with bash

I wanted to quickly create pkgs for iWork and iLife from apps with an institutional ID receipt because I am experimenting with AutoDMG and Lightning.

It takes a bit of time for some of these to build and I didn't want to wait around so here is what I did…

Start an array by just typing array=( into the command line and then hitting <return>
admin_dist@golden ~ $ array=( 
Drag and drop the apps into the Terminal window hitting <return> after each
> /Applications/GarageBand.app 
> /Applications/iMovie.app 
> /Applications/iPhoto.app 
> /Applications/Keynote.app 
> /Applications/Numbers.app 
> /Applications/Pages.app
When they are all in finish off the array
> ) 
Now for the good stuff.  :D

For each path in the array
admin_dist@golden ~ $ for path in "${array[@]}"; do
 greedily chomp from the front to the last / using parameter expansion
> app_name="${path##*/}"
chomp from the end to the first period
> name="${app_name%.*}"
get the version of the thing at $path using command substitution and an assignment
> version=$(defaults read "${path}"/Contents/Info CFBundleShortVersionString)
build it with a pretty name
> pkgbuild --component "${path}" $HOME/Desktop/"${name}-${version}".pkg
> done

This will give you nice installer packages on the Desktop of the form "GarageBand-10.0.2.pkg".

Here is gist with a full script instead of interactive command line entries.

Thursday, April 17, 2014

Quick Tip - updatejournal.plist

I just migrated from an old 13" MacBook Pro to a new 13" Air.

I quickly found out that Migration Assistant in Mavericks over Thunderbolt is mostly broken.

Not a problem for me, I know how to use rsync with --exclude!

After getting my user directories moved over I found something rather annoying. MAS still showed that I had installed a bunch of updates, particularly developer seeds, that I most certainly was not running on this new machine.

I poked around for a few minutes with pkgutil, ls'd a bunch of folders, poked & prodded until finally throwing my hands up in exasperation.

Where the heck is this coming from!?!

I methodically started going through my User-level Library (as I now knew the updates only showed up for my standard user and not the admin) and found the offender.

updatejournal.plist

After banishing this annoying little bugger to to the Trash my update list is free and clear.