“Show Package Contents” Unavailable? Extract .pkg Files Without Installing Them
Have you ever wanted to get a look at the contents of a package file on the Mac, but without installing it? You can do that with the help of an excellent command line. This continues on with our series of inspecting the contents of app installers, and in this case we’ll demonstrate how to extract package files and sort through their contents without actually installing them onto Mac OS X.
How to View & Extract Package Files in Mac OS X Without Installing
There are actually two ways to do this. The first is quite easy and available from the Mac Finder, it is well known by advanced users: you can often just right-click on a pkg file and select “Show Package Contents” – but that isn’t always displayed. Assuming the Show Package Contents option is unavailable, we can extract .pkg files using a command line tool called pkgutil that is bundled with OS X, which is what we’re going to focus on here.
- Launch Terminal (found in /Applications/Utilities/) if you have not done so already
- Use the following syntax, pointing the path to the package file in question, and providing an output destination for the files to be extracted from the package
- Go to the outputs path in the Finder and check out the extracted files yourself, or navigate to the directly with the ‘cd’ command at the command line
pkgutil --expand /path/to/package.pkg /output/destination/
Hint: recall that you can drag & drop items into the Terminal to print their full path, making this tip easier by typing:
--expand [drop file here] /destination/path/
You’ll notice that some package files contain even more package files, quickly leading you into a deeply nested package extraction process.
This is an excellent way to see what’s contained within packages, particularly the ones where the alt-click “Show Package Contents” option isn’t available, which is increasingly common in Mac OS X Lion and later releases of Mac OS system software, although ultimately it depends on how the package was constructed.