X

Extracting individual files from pax.gz archives in Installers

Extracting individual files from pax.gz archives in Installers

CNET staff
2 min read
Previously, we noted how you could use a utility such as OpenUp to decompress the pax.gz file in an Installer document, thus allowing you to see everything that gets installed before you actually install it. It would also allow you to selectively install files from the Installer, if you wished (as you can do with TomeViewer in OS 9). About the only disadvantage of this approach is that you need to decompress all the files, and temporarily use the disk space this requires, even if you just want one file.

Bart Van den Broeck offers a way to do this via UNIX commands in Terminal:

    I have extracted, for example, only the SimpleText folder in the Carbon Examples of the Developer CD from the ".pax.gz" archive. This is the command I used ("cd" to the folder you want to have the SimpleText folder be put into first):

    gunzip -c '/Volumes/Developer Tools/Developer.pkg/Contents/Resources/ Developer.pax.gz' | pax -r -s ',./Developer/Examples/Carbon/,./,' './Developer/ Examples/Carbon/SimpleText'

    This is a one line command. It first un-gzips the Developer.pax.gz archive to stdout (so no files are actually written, the result is "piped" (read "passed on", the "|" does the piping) to the utility pax. Pax reads ("-r") the file/ folder with path matching the following pattern ('./Developer/Examples/Carbon/ SimpleText') and writes it (and its contents, in the case of a folder) out to the folder you're in. The "-s" option replaces in the paths the string "./ Developer/Examples/Carbon/" with the string "./", thereby effectively causing the extracted files to be written to the path "./SimpleText", i.e. a folder SimpleText is created in the current folder, instead of to the path "./ Developer/Examples/Carbon/SimpleText", i.e. creating a SimpleText folder which is located in the Carbon folder which is located in the Examples folder which is located in the Developer folder which, finally, is located in the current folder.

Update: Brian Scott Oplinger suggests that, for this to work, you will still need the full amount of disk space to hold the entire uncompressed gz file, even though you wind up with just one file extracted.