Although below are methods to extract the contents of a macOS package without actually installing it, the best way might be to create a blank disk image and install the package to this disk image in order to inspect the package contents. To do so:
- Open the Disk Utility app.
- Choose "File > New Image > Blank Image". Alternatively, simply press CMD-N.
- Set the parameters and click on "Save" to create the blank disk image.
- After creation, it should be already mounted. If not, you can mount it by navigating to the directory that it is placed at and double clicking on the disk image file.
- Run the package installer by double clicking on the package file.
- Select this newly created blank disk image as the destination and install it.
- If the script is preventing you from installing by saying, for example, "macOS isn't installed", you can:
- Expand the package (as described in steps below), using
pkgutil --expand /Volumes/<disk image where the package file is located at>/<path to the package file> <a non existing path which the extraction will be placed at>
. - Edit the "Distribution" file under the extraction directory, removing the check for the presence of a macOS installation in the target disk image.
- Pack it back using
pkgutil --flatten <a non existing path which the extraction will be placed at> <a non existing path which the package will be placed at>
- Double click on
<a non existing path which the package will be placed at>
to run the installer for the package. This time, it should work, since we removed the check for the presence of macOS installation by editing the "Distribution" file.
- Expand the package (as described in steps below), using
An example session of installing Xcode Command Line Tools version 11 to a blank disk image, after creating a blank disk image of sufficient size:
- Double click on the downloaded "Command_Line_Tools_for_Xcode_11.dmg" disk image. It will mount the disk image and open a Finder window, showing the contents of the disk image. We can close this opened Finder window, since we won't use it.
- Expand the Command Line Tools package by running
pkgutil --expand '/Volumes/Command Line Developer Tools/Command Line Tools.pkg' ~/clt-11
- Open the
~/clt-11/Distribution
file with a text editor and remove the part:<volume-check> <allowed-os-versions> <os-version before="10.16" min="10.14.4"/> </allowed-os-versions> </volume-check>
- Repack it using
pkgutil --flatten ~/clt-11 ~/clt-11.pkg
- Double click on this created package file named
clt-11.pkg
, which is located in your home directory. It will launch the installer for that package. - On "Installation Type" step, click on "Change Install Location...". Now you should be able to select the blank disk image that you have created and mounted.
- Select it, and complete the installation.
- Now, when you navigate to the disk image (which is under
/Volumes/<name of the disk image that you gave while creating it>
), the files of the Xcode 11 Command Line Tools should be there.
Using the undocumented --expand-full
option of the pkgutil
command like:
pkgutil --expand-full <path to .pkg file> <a non existing path which the extraction will be placed at>
Might not be working since macOS 10.10, per this answer.
pkgutil --expand <path to .pkg file> <a non existing path which the extraction will be placed at>
cd <a non existing path which the extraction will be placed at>
cat Payload | gunzip | cpio -i
Per this answer, gunzip
does not work for Payload
files since macOS 10.10, and pbzx
must be used instead. pbzx
can be found either here or here:
pkgutil --expand <path to .pkg file> <a non existing path which the extraction will be placed at>
cd <a non existing path which the extraction will be placed at>
pbzx -n Payload | cpio -i
- https://www.google.com/search?q=macos+extract+payload+file
- https://stackoverflow.com/questions/41166805/how-to-extract-contents-from-payload-file-in-a-apple-macos-update-package
- http://gabrielrinaldi.me/how-to-install-jdk-7-on-yosemite-10-10
- https://mybyways.com/blog/extract-files-from-a-macos-installer-pkg
- https://stackoverflow.com/questions/11298855/how-to-unpack-and-pack-pkg-file
- https://coolaj86.com/articles/how-to-unpackage-and-repackage-pkg-osx.html
- https://gist.github.com/jroyalty/fa443b1546045ea18d9a
- https://matthew-brett.github.io/docosx/flat_packages.html
- https://apple.stackexchange.com/questions/15658/how-can-i-open-a-pkg-file-manually
- https://yuriydev.com/goodies/extractingpkg.php
bro ty