Wednesday, January 21, 2015

Install .dmg files on Mac OS X using command line

Sometimes you need to install .dmg files on Mac using command line. You first need to mount the .dmg as a drive:

hdiutil mount jdk-8u20-macosx-x64.dmg


Now you'll see a drive is created under /Volumes :

ll /Volumes/
drwxr-xr-x 6 Rafi staff 272 Jul 30 23:31 JDK 8 Update 20
cd /Volumes/JDK\ 8\ Update\ 20/
ll
-rwxr-xr-x@ 1 Rafi staff 219555315 Jul 30 23:31 JDK 8 Update 20.pkg


You can check what target paths are available for the installation this way:

sudo installer -pkg JDK\ 8\ Update\ 20.pkg -dominfo


You should see something like:
LocalSystem


Now you can install the .pkg file with the installer of Mac OS X:

sudo installer -pkg JDK\ 8\ Update\ 20.pkg -target LocalSystem

If you want to follow the log of the installer:

tail -f /var/log/install.log

No comments:

Post a Comment