# UPDATE 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// `. - 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 ` - Double click on `` 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. 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: ```xml ``` - 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/`), the files of the Xcode 11 Command Line Tools should be there. # Best Way Using the [undocumented `--expand-full` option](https://stackoverflow.com/a/50835954/3395831) of the `pkgutil` command like: pkgutil --expand-full # "Conventional" Way Might not be working since macOS 10.10, per [this answer](https://stackoverflow.com/a/41598227/3395831). pkgutil --expand cd cat Payload | gunzip | cpio -i # Modern "Conventional" Way Per [this answer](https://stackoverflow.com/a/41598227/3395831), `gunzip` does not work for `Payload` files since macOS 10.10, and `pbzx` must be used instead. `pbzx` can be found either [here](https://github.com/NiklasRosenstein/pbzx) or [here](https://www.tonymacx86.com/threads/pbzx-stream-parser.135458): pkgutil --expand cd pbzx -n Payload | cpio -i # Relevant Links - 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