macOS – Tracking Progress of Command Line Installer

bashmacospkg

I am trying to install an application through command line in OS X. This is what I am trying:

hdiutil attach app.dmg
cd /Volumes/appvolume
installer -pkg app.pkg -target "/"

This works fine, however, I am not able to get an output from the installer command from which I can capture the amount of progress made and the time/amount remaining. I tried the verbose option

installer -verbose -pkg app.pkg -target "/"

But this only prints output like installer: Optimizing system for installed software…….., etc, nothing about progress. But it surely knows about progress, because when I install the app via double clicking, the installer window that pops up shows a deterministic progress bar that progresses gradually and reaches full length when installation is complete.

Any way I can capture the progress status through command line installer as well?

Best Answer

You were close - the option you're looking for is -verboseR:

Usage: installer [-help] [-dominfo] [-volinfo] [-pkginfo] [-allowUntrusted] [-dumplog]
             [-verbose | -verboseR] [-vers] [-config] [-plist]
             [-file <pathToFile>] [-lang <ISOLanguageCode>] [-listiso]
             [-showChoicesXML] [-applyChoiceChangesXML <pathToFile>]
             [-showChoicesAfterApplyingChangesXML <pathtoFile>]
             -pkg <pathToPackage>
             -target <[DomainKey|MountPoint]

Here's installer's output installing a Firefox 43.0.1 .pkg built with AutoPkgr with that flag:

timmay:~ da4$ sudo installer -pkg /Users/da4/Desktop/auto/Firefox-43.0.1.pkg -target / -verboseR
installer: Package name is Firefox-43.0.1
installer: Upgrading at base path /
installer:PHASE:Preparing for installation…
installer:PHASE:Preparing the disk…
installer:PHASE:Preparing Firefox-43.0.1…
installer:PHASE:Waiting for other installations to complete…
installer:PHASE:Configuring the installation…
installer:STATUS:
installer:%9.883908
installer:PHASE:Writing files…
installer:%30.674055
installer:PHASE:Writing files…
installer:%51.530939
installer:PHASE:Optimizing system for installed software…
installer:PHASE:Validating packages…
installer:PHASE:Validating packages…
installer:%97.750000
installer:STATUS:
installer:PHASE:Finishing the Installation…
installer:STATUS:
installer:%100.000000
installer:PHASE:The software was successfully installed.
installer: The upgrade was successful.
timmay:~ da4$

I'm not exactly sure when the -verboseR option was added to OS X's installer, but it's present in 10.9+.