Sometimes you find an installation file in a .pkg or .mpkg file. How can we extract the files form these files?
You can try unpkg - which seems to support PKG and MPKG files a like - but it sometimes fails on MPKG files.
But we can do it manually as well ...
Typically such a package is located on a DMG file that has been mounted, let's assume this DMG is called "MyApp.DMG", and therefor that it's mounted as /Volumes/MyApp. In Terminal (Applications - Utilities - Terminal) we type:
cd /Volumes/MyApp
When you do a directory listing you'll discover that there is more on the disk, and we're mostly interested in the folder called "Packages".
Try:
ls -l
which results in something like this (assuming the .PKG or .MPKG file is calle "MyApp.mpkg"):
total 1288
-rw-r--r-- 1 hans staff 657803 Oct 11 17:15 MyApp.mpkg
drwxr-xr-x@ 4 hans staff 136 Oct 11 17:13 Packages
You see the directory called Packages? Let's go there:
cd Packages
Here you'll find all the fun files, and per PKG or MPKG file the content will be different of course.
With the following statement you can reveal the files as we did before:
ls -l
You can of course copy these files to for example to a folder called "dummy" on your desktop :
mkdir ~/Desktop/dummy
cp * ~/Desktop/dummy/
cd ~/Desktop/dummy
Now you might run into .PKG files again, which can be extracted by unpkg (free) or the Unarchiver (free).
Some unpackers unpack the whole thing (unpkg), some require some help afterwards when you find files like:
Bom
PackageInfo
Payload
Scripts
Typically "Payload" (largest) is the one we're looking for.
To unpack Payload, rename the file to Payload.pax.gz and execute the following command line statements to extract the files:
mv Payload Payload.pax.gz
gunzip Payload.pax.gz
pax -rvf Payload.pax
The first statement is to rename the file, the second will un-GZip the Payload.pax.gz file to Payload.pax. The last statement will extract the pax file.
Now you'll have all the files ...