Read What a Mac Installer Package Will Run Before You Deploy It
Expand a Mac installer package with pkgutil, read its preinstall and postinstall scripts, test-install on a spare Mac and compare the receipt before rollout.

Underlined words are defined in the KBY Lexicon. Tap or click one to see what it means.
To see what a Mac installer package will do before you deploy it, expand it into a scratch folder with pkgutil --expand-full, list its payload with pkgutil --payload-files, and read any preinstall and postinstall scripts it carries. Then install it on a spare Mac with sudo installer -pkg Example.pkg -target / -dumplog and compare the files on disk with the package’s receipt.
Apple’s own packaging guidance says an installer package is the best choice when a product has multiple components, must be copied to specific locations or needs to run custom code during installation. That last case is the one worth reading before you ship, because code in a package runs as part of the install on every Mac you target.
Everything below happens on a test Mac or in a scratch folder, and none of it needs the package to reach the fleet first.
#How it usually goes when a package arrives
A vendor sends a .pkg, or a colleague repackages one. The usual checks are that it opens, that the app launches on a test Mac and that the management tool reports the install as complete. If all three pass, the package is uploaded and scoped to a pilot group.
That method proves the package installs. It does not tell you which files it writes, where it writes them, or what its scripts do besides installing the app. The gaps show up later, in ways that look unrelated to packaging: a launch agent nobody asked for, a settings file overwritten on every update, a script that runs for ten minutes and is then stopped.
When the install finally misbehaves on the fleet, all you have to go on is the package itself, which you never opened.
Packages also arrive with a history. A package can carry a signature that you check separately, as described in checking a Mac app or pkg is Developer ID signed and notarized. A valid signature says who built the package and that it has not changed since. It does not say what the package does when it runs.
#What to do instead: read the package before it reaches a Mac
The better workflow adds one short review between “the package arrived” and “the package is uploaded”. You check the signature, expand the package into a folder, read what it will run, list what it will write, and only then install it on a spare Mac and compare the result with what you read.
Four documented behaviours shape the design.
- Expansion is a file operation. The
pkgutilmanual page describes--expandas expanding a flat package into a new directory, and--expand-fullas doing the same while also expanding the Payload contents of each package. Neither command is described as installing anything. - The payload listing has limits.
--payload-fileslists the files archived within the payload of an uninstalled flat package. The page warns that a package can contain more than one component, and that the destination location for the uninstalled package is unknown to the command. A listing tells you what is inside, not where it will land. - Scripts have fixed names. The
pkgbuildmanual page says scripts namedpreinstallandpostinstallin the scripts folder run as the package’s top-level scripts. Any other file in that folder is used only if one of those scripts, or a component-specific script, calls it. Scripts for specific bundles are named in a component property list, using the keysBundlePreInstallScriptPathandBundlePostInstallScriptPath. - Scripts have a time limit. The same page says the operating system default timeout for a script is currently 10 minutes and is subject to change. A package can raise it with the
BundleInstallScriptTimeoutkey, which the page says is respected only on macOS versions newer than 15.0.
Because the payload listing cannot give a destination, the install on a spare Mac is not optional. It is the step that turns “what is inside” into “where it went”, using the receipt the Installer records.
#Setting it up on a test Mac
Use a spare Mac, or a Mac you can restore, for the whole procedure. You need an administrator account for the install step only. The expansion and listing steps need no special rights beyond read access to the package and write access to your scratch folder.
- Put the package in a review folder and note its identity. Copy it to a folder you control, for example
~/pkg-review/Example.pkg. Record the file name and where it came from in your change ticket. If you have the vendor’s published checksum, compare it now. - Check the signature. Run
pkgutil --check-signature ~/pkg-review/Example.pkg. The manual page says this checks the validity and trust of the signature and shows the certificate chain. A failing result stops the review; do not install the package to find out why. Theinstallercommand has an-allowUntrustedflag that allows a package signed by an untrusted or expired certificate, and it is not a fix for a failed check. - Expand the package fully. Run
pkgutil --expand-full ~/pkg-review/Example.pkg ~/pkg-review/Example-expanded. The destination must be a directory that does not exist yet. Use--expandinstead if you only want the package structure and not the unpacked payload. - Look at what came out. Run
find ~/pkg-review/Example-expanded -maxdepth 3and read the result. The manual pages do not describe the layout of the expanded folder, so record what your macOS version produces rather than relying on a remembered layout. Look for component packages, any distribution file, and a scripts folder. - Read the scripts. Open any
preinstallandpostinstallfiles with a text viewer, not by running them. For each one, write down what it changes outside the application folder: files it creates, settings it writes, services it loads, and any command that downloads something. Note every other file in the scripts folder and which script calls it. A script that calls a file you cannot find is a finding. - List the payload. Run
pkgutil --payload-files ~/pkg-review/Example.pkgand save the output to a file in the review folder. If the package contains more than one component, the listing covers them together and you will separate them from the receipts in a later step. - Install on the spare Mac. Run
sudo installer -pkg ~/pkg-review/Example.pkg -target / -dumplog. Theinstallermanual page says it needs root, installs one package per invocation, and that-dumplogadditionally writes the detailed log to standard error. The same detail always goes to/var/log/install.log. Save the terminal output with the other review files. - Read the receipt. Run
pkgutil --pkgs=Exampleto find the package ID, replacingExamplewith a word from the vendor’s identifier. The equals sign is required, and the value is a regular expression. Then runpkgutil --pkg-info PACKAGE_IDandpkgutil --files PACKAGE_ID, with the ID you found. - Compare. Check that every path in the receipt’s file list appears in the payload listing, and that nothing the scripts claim to create is missing or extra. Differences are the review’s output, not a failure of the method.
Following along? Tap a step’s number to tick it off.
If a package you reviewed later shows as installed in your management tool but the app is missing, KBY’s guide to a pkg that the MDM reports as installed while the app is missing covers that case.

#Keeping it safe
The review involves a package you have not yet trusted, so keep it away from machines that matter.
- Scope. Run the install step only on a spare or restorable Mac, never on a production Mac or your own administrator workstation. Expansion and listing are file operations and can run anywhere you have a scratch folder, but do them as a standard user so a mistake cannot touch system files.
- Least privilege. Use
sudofor theinstallercommand only. Do not open the expanded scripts in an editor that executes them, and do not make them executable to “try them out”. - Stop conditions. Stop and reject the package if the signature check fails, if a script downloads and runs something you cannot identify, if the scripts call files that are not in the package, or if the install writes files that are in neither the payload listing nor the scripts.
- No exceptions for urgency. A vendor deadline is not a reason to skip the signature check or to use
-allowUntrusted. KBY’s declarative package install and removal workflow shows how to remove a package’s files again when you pull it back. - Residual risk. Reading a script shows what it says it does. A script can still behave differently with different inputs, and the review does not replace pilot-group monitoring. It narrows what you do not know.
#Checking it worked on a spare Mac
A review has worked when you can answer four questions from saved files rather than from memory.
- Is the signature trusted? The saved
--check-signatureoutput shows a valid signature and a certificate chain, and the chain names the publisher you expected. - Does the payload list match the receipt? Every file in the receipt’s list appears in the payload listing, once you allow for the package’s install location. The
--payload-filespage says the destination is unknown, so compare file names and relative paths first, then confirm the location on disk. - Do the scripts account for every extra change? Anything on the spare Mac that is not in the payload, such as a launch item or a settings file, traces to a line in a script you read. If it does not, record it as an unexplained change.
- Is the log clean? Search the saved
-dumplogoutput, or/var/log/install.log, for the package name, and read the lines around any error. The manual page says detailed log information always goes to the install log.
Keep the signature output, the payload list, the receipt list, the install log and your notes on the scripts together in the change ticket. They are the evidence that the review happened.
#What goes wrong
- Treating the payload listing as the whole story. The listing covers the payload only. Scripts can create, change or remove things the listing never mentions, which is why reading them is a separate step.
- Assuming the listing shows the install path. The manual page states that the destination location is unknown to
--payload-files. The receipt from a test install is where you see the path. - Reading only the top-level scripts. Component-specific scripts are named in a component property list, and a script can call other files from the scripts folder. Search the whole expanded folder, not only files named
preinstallandpostinstall. - Using
pkgutil --forgetas a cleanup. The manual page says it discards the receipt data about a package but does not touch the installed files. After a forget, the files are still on the Mac and the receipt no longer records them, which makes later removal harder. - Quoting a regular expression as a name.
--pkgs=REGEXPmatches package IDs as a regular expression, and the equals sign is required, otherwise the search string is ignored and every ID is returned. Check that the list you read is the filtered one. - Expecting the package to be the same on every macOS version. Some
pkgbuildbehaviour depends on the build and install versions. The manual page notes, for example, thatBundleInstallScriptTimeoutis respected only on macOS newer than 15.0, and that the default forBundleIsRelocatablechanges for packages built on macOS 27 and later. Review the package on the macOS version your pilot group runs.

#Backing out a package you have already tested
The expansion and listing steps change nothing outside your scratch folder, so the way back is to delete the review folder. The install step is the one that changes the spare Mac, and you should decide how to reverse it before you run it.
- Before installing, make sure the spare Mac can be restored: a current backup, a snapshot your tooling supports or a known reinstall procedure. Write down which one you will use.
- To undo the install, use the receipt. The file list from
pkgutil --files PACKAGE_IDis the list of paths the package placed, and KBY’s walkthrough on uninstalling a pkg-installed Mac app completely using its pkgutil receipt covers removing them. Remove what the scripts created as well, using the notes you made. - Check the result. Run
pkgutil --pkgs=Exampleagain and confirm the paths in your notes no longer exist. If anything remains that you cannot explain, restore the spare Mac rather than patching it. - If the package is already on the fleet, stop further scoping first, then treat the receipt and your saved review files as the baseline for the removal.
The boundary to keep in mind is that pkgutil --forget removes only the receipt. Do not use it as a rollback.
#How to tell it worked
This is a small practice and its outcome is visible in the ticket queue and the change record rather than in a dashboard. Use measures you can count from your own records, and set the baseline before you start.
- Review coverage. The share of packages uploaded in a month that have a saved review folder attached to their change ticket. Aim for all of them, and list the exceptions.
- Findings before the fleet. The number of packages where the review found an unexplained file, an unreadable script or a signature problem. A rising count in the first months means the review is catching things, not that quality is falling.
- Install failures after pilot. Tickets traced to a package’s own scripts or file placement, counted per month. Compare against the months before you started, using your own ticket data.
- Time to answer “what did this package change?” Measure how long it takes to answer that question for a package already deployed. With saved review files, it should be a lookup.
Review the numbers monthly with whoever approves packages. If coverage is low, the problem is usually that the review lives in someone’s memory, so put the steps in your package intake template. Decide the next safe step at the meeting: widen the pilot group for a clean review, or hold the package.
#Before you roll out package review
- A spare or restorable Mac is named as the install target, and its restore method is written down.
- The review folder pattern, for example one folder per package version, is agreed and attached to the change ticket.
- The team knows that a failed
--check-signaturestops the review, and that-allowUntrustedis not used to get past it. - Someone has read each script in the package, and unexplained changes are recorded as findings.
- The payload listing, the receipt list and the install log are saved together.
- The pilot group runs the macOS version you tested on, or the difference is recorded.
- The removal path for the package is written down before the first install.
- The monthly measures have a baseline and an owner.
Manual pages can differ between macOS versions, so check man pkgutil, man pkgbuild and man installer on the Mac you test on.
About this page
Credited to
Dates
Published
Sources
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Found this useful? Follow KBY for more like it.
Recommended reading
More from KBY that goes with this article.



Education ITChoosing school IT support: your own technician, an outside company or the trust's team
10 min read
Related articles
Application Lifecycle
Uninstall a pkg-Installed Mac App Completely Using Its pkgutil Receipt
No uninstall for a Mac .pkg? Read its pkgutil receipt, stop launchd services, move the app's files to a holding folder and forget the receipt, with rollback.
ReadApplication Lifecycle
Check a Mac App or pkg Is Developer ID Signed and Notarized Before You Deploy It
Run codesign, spctl, pkgutil and stapler on a test Mac to confirm an app or pkg is signed and notarized, and find pkgs that stop installing in 2027.
ReadPolicy and regulation
UK Ransomware Payment Ban for Public Sector and CNI: What Organisations Should Do Now
Hospitals, councils, schools and critical infrastructure will be barred from paying ransomware demands. Five things to settle before the rules land.
ReadArtificial Intelligence
AWS Brings Claude On Premises Through AI Factories: What It Means for Data Residency
AWS will run Claude inside customers' own data centres via AI Factories. No UK availability, price or general-availability date is stated yet.
ReadDiscover more
Ops Playbook
- PlaybookInstall a Mac Package With Declarative Management and Remove Its Files When Unassigned
- PlaybookFind Intel-Only Mac Apps Across Your Fleet Before macOS 28 Limits Rosetta
- PlaybookUninstall a pkg-Installed Mac App Completely Using Its pkgutil Receipt
- PlaybookCheck a Mac App or pkg Is Developer ID Signed and Notarized Before You Deploy It
Lexicon Definitions
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Operate smarter, with fewer recurring tickets.
Receive new operational playbooks, incident-prevention guidance, automation scripts and recovery runbooks.
Comments
Add a thoughtful note on Read What a Mac Installer Package Will Run Before You Deploy It. Comments are checked for spam and held for moderation before appearing.