Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install dmg package on MAC OS from Terminal

I would like to install the dmg java package in my MAC OS through the terminal

I tried using this command:

sudo installer -package jdk-7u51-macos-x64.dmg -target /

But I receive this error:

installer: Error the package path specified was invalid: 'jdk-7u51-macos-x64.dmg' 
like image 681
user3472065 Avatar asked Apr 08 '14 10:04

user3472065


People also ask

Can I install macOS with DMG?

Click the link to download a disk image (.dmg) file for that macOS. Double-click the .dmg file to open it and see the .pkg file within. Double-click the .pkg file, then follow the onscreen instructions. This installs the macOS installer into your Applications folder.

How install pkg file on Mac?

In Remote Desktop , select a computer list in the sidebar of the main window, select one or more computers, then choose Manage > Install Packages. Select a . pkg or . mpkg file to install.

How install DMG file on Mac IOS?

Double-click the DMG file to open it, and you'll see a Finder window. Often these will include the application itself, some form of arrow, and a shortcut to the Applications folder. Simply drag the application's icon to your Applications folder and you're done: the software is now installed.


2 Answers

Try this:

MOUNTDIR=$(echo `hdiutil mount jdk-7u51-macos-x64.dmg | tail -1 \
| awk '{$1=$2=""; print $0}'` | xargs -0 echo) \
&& sudo installer -pkg "${MOUNTDIR}/"*.pkg -target / 
like image 64
Mateusz Szlosek Avatar answered Sep 29 '22 11:09

Mateusz Szlosek


Let dmgFilePath be the variable containing the path of your dmg file.

Then you can try this :

$ MOUNTDEV=$(hdiutil mount $dmgFilePath | awk '/dev.disk/{print$1}')
$ MOUNTDIR="$(mount | grep $MOUNTDEV | awk '{$1=$2="";sub(" [(].*","");sub("^  ","");print}')"
$ sudo installer -pkg "${MOUNTDIR}/"*.pkg -target /
$ hdiutil unmount "$MOUNTDIR"

Tested on macOS High Sierra even if "$MOUNTDIR" contains one space.

like image 45
SebMa Avatar answered Sep 29 '22 12:09

SebMa