Sub topic 13
Installing from disk images and installer packages
This chapter assumes you know how Finder and the Applications folder work, and that you have read about quarantine, Gatekeeper and checksums. Terminal use is optional but helps.
Two containers, two behaviors
A disk image (.dmg) is a virtual disk. Opening it mounts a volume, and you usually drag the app into Applications. An installer package (.pkg) is a script-driven installer. It can place files in many locations, run scripts, and ask for your administrator password.
The difference matters for risk. Dragging an app copies one bundle that Gatekeeper checks at first launch. A package can run code with administrator rights during installation, before any app launches.
| Row | Disk image (.dmg) | Installer package (.pkg) |
|---|---|---|
| What it does | Mounts a volume holding the app | Runs an installer that writes files and may run scripts |
| Typical privileges | Your user account | Often administrator |
| Where it installs | Wherever you drag it | System-defined locations |
| Inspect first with | `codesign`, `spctl` | `pkgutil --check-signature` |
Install from a disk image
- Compare the hash with the developer's published value:
shasum -a 256 ~/Downloads/Example.dmg- Double-click the
.dmg. macOS may verify it and show a license agreement. - Drag the app into Applications. Do not run it from inside the mounted image. A running copy on the image can't be updated or removed cleanly.
- Eject the volume in Finder, then optionally delete the
.dmg. - Open the app from Applications. Gatekeeper performs its first-launch check.
Before opening, you can confirm the quarantine flag is present and the signature is valid:
xattr -l ~/Downloads/Example.dmg
codesign --verify --deep --strict --verbose=2 /Applications/Example.appInstall from a package
Inspect the signature before you double-click:
pkgutil --check-signature ~/Downloads/Example.pkgA good result shows a status of signed by a developer certificate and a chain ending at Apple's root. "Package is not signed" is a reason to stop unless you got the file from a source you fully trust.
In the installer, read each step. Note the destination, which components it installs, and whether it asks for a password. A password prompt for a simple app is a prompt to ask why.
Common errors
- Running the app from the mounted image, which leads to odd update and permission problems.
- Skipping the checksum because the site "looks fine."
- Approving every installer step, including optional bundled software.
- Leaving disk images mounted and old
.dmgfiles in Downloads.
Exercise
You downloaded Example.pkg. Name the command you run before opening it, and say what result should make you stop.
Show answer
Run pkgutil --check-signature ~/Downloads/Example.pkg. Stop if it reports the package is not signed, or if the certificate does not match the developer you expect. Also stop if the checksum does not match the published value.