/archive_osx_installer_app

Archive OS X installer application

Primary LanguageShellMIT LicenseMIT

Archive OS X installer application

This combination of a script and importable Hazel rule will archive new OS X installer applications as they appear in the /Applications directory.

It is better than most fish and chips. Honest.

Why?

The Mac App Store saves new OS X Install applications to the /Applications folder. Subsequent updates from the Mac App Store overwrite the previous version of the OS X Install app. Even if you move the application elsewhere, downloading updates will overwrite it wherever it has been moved — as long as the Finder can find it.

This is frustrating for those who would like to archive various versions/builds of OS X for later use.

How does it work?

The Hazel rule detects when you have a new OS X Install application in the /Applications folder. It waits a short time to make sure the download is complete.

Then it pounces! Hazel runs the "archive_osx_installer_app" script, which does all of the heavy lifting.

  1. It determines the version number and build of OS X in the app (without using the entire InstallESD.dmg). Short OS X version numbers are padded with ".0" so that they look and sort better alongside subsequent updates. Version "10.10" becomes "10.10.0."
  2. It copies the OS X Install app to a temporary folder. Please note that you'll want enough space for this — and for each OS X Install application that you currently have in /Applications, if you add the Hazel rule, below.
  3. It archives the temporary folder to a compressed disk image in /Users/Shared. (You know I dig disk image compression, so this image is compressed with Zlib level 9.) Again, this is making yet another copy, so you'll want enough disk space for that.
  4. It removes the temporary folder to free up space.

Examples of actual disk images saved to /Users/Shared:

  • Install Mac OS X Lion 10.7.3 11D50.dmg
  • Install OS X Mountain Lion 10.8.4 12E55.dmg
  • Install OS X Mavericks 10.9.3 13D65.dmg
  • Install OS X Yosemite 10.10.0 14A389.dmg

You may also run "archive_osx_installer_app" on its own, if you don't have Hazel, don't use Hazel, and/or don't want Hazel. The script takes one parameter, the path to the OS X Install app.

Examples:

/usr/local/bin/archive_osx_installer_app "/Applications/Install Mac OS X Lion.app"
/usr/local/bin/archive_osx_installer_app /Applications/Install\ OS\ X\ Mountain\ Lion.app
/usr/local/bin/archive_osx_installer_app /Applications/Install\ OS\ X\ Mavericks.app
/usr/local/bin/archive_osx_installer_app '/Applications/Install OS X Yosemite.app'

A note on free disk space: as described above, if you import the Hazel rule, you will want enough free disk space on your particular system to comfortably make a copy and a disk image — a process which itself has disk space requirements — of that copy of each OS X Install application in your /Applications folder.

A note on the destination folder: I chose /Users/Shared on something of a whim. Afaik, I can only pass one parameter to the script from Hazel. You can move your disk images from that location, perhaps with another Hazel rule, if you so choose.

A note on interactive operation: You can run the script from the command line, giving it the path to an OS X Install app anywhere else, to archive that installer. This allows you to catch up on archiving your older installers without having to move them into /Applications one at a time to trigger the Hazel rule.

Installation

If you want to make OS X Install applications manually, you only need the shell script.

If you have The Luggage and its prerequisites installed, you can use the included Makefile to make an installation package for the script. This is not required, but you may want it that way. (I've been known to work with The Luggage, as you may know from various events and so on. If you'd like to make flat packages or see some makefile overrides I like, this Makefile may be of interest to you.)

  1. Clone the repository.
  2. Make the installation package with The Luggage. make pkg
  3. Install the installation package.

If you don't have The Luggage installed, you can copy the script to /usr/local/bin yourself.

  1. Clone the repository.
  2. Copy the script to /usr/local/bin. sudo cp archive_osx_installer_app /usr/local/bin
  3. Make sure the script is executable. sudo chmod 755 /usr/local/bin/archive_osx_installer_app

Once the script is installed, import the Hazel rule. The Hazel rule wires things up to make automatic archives — or at least that's the goal — so if you're using Hazel on the system where you download OS X Install application updates, I suggest you try it.

  1. Double-click on the "Applications.hazelrules" file.
  2. Choose "Applications" as the folder to import the rules to when Hazel prompts you for that choice.

Feedback

This project is hosted on both Bitbucket and Github. The primary public repository is on Bitbucket; I personally use Mercurial to track changes.

If you encounter a problem, please submit an issue.

In particular, the Hazel rule might be fiddly, as I find it hard to get those right when they include downloads. In this case, the download will also be updated — perhaps several times — later. I've tried to make it match correctly without making a new archive every time Hazel scans. YMMV.

Version history

  • 0.9.0 - First public release
  • 0.9.1 - Update Hazel matching conditions to look for either no previous matches or a match that predates the latest modification to the OS X Install application
  • 0.9.2 - Update script, with benefits for both Hazel and interactive operation. It now prints the detected OS X version and build. (After that, it pauses briefly to allow time to cancel the operation, which is useful when run interactively.) It compresses the output disk image with Zlib level 9 compression to save some disk space, since it's an archive. Finally, it pads short OS X version numbers with ".0" -- where "10.10" becomes "10.10.0" -- which makes major OS X releases look and sort better alongside subsequent updates.