Install dmg package on MAC OS from Terminal

后端 未结 4 1089
孤独总比滥情好
孤独总比滥情好 2021-02-09 01:33

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         


        
相关标签:
4条回答
  • 2021-02-09 02:06

    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 / 
    
    0 讨论(0)
  • 2021-02-09 02:22

    I ran into the exact same problem and found the root cause. if you trying to install a package where the installer has no permission to access the directory you will get that weird error.

    i.e

    osascript -e {'do shell script "installer -allowUntrusted  -pkg ~/Download/OpenJDK8U-jdk_x64_mac_hotspot_8u275b01.pkg  -target /tmp/ " with administrator privileges'}
    
    1:150: execution error: installer: Error - the package path specified was invalid: '/Users/user-x/Download/OpenJDK8U-jdk_x64_mac_hotspot_8u275b01.pkg'. (1)
    

    either by moving the package into /tmp/ or change the directory permission so applescript or installer command can access the file.

    osascript -e {'do shell script "installer -allowUntrusted  -pkg /tmp/OpenJDK8U-jdk_x64_mac_hotspot_8u275b01.pkg  -target /tmp/ " with administrator privileges'}     
    installer: The upgrade was successful.K
    
    0 讨论(0)
  • 2021-02-09 02:26

    Thank Mateusz Szlosek,

    For me :

    $ MOUNTDIR=$(echo `hdiutil mount /Users/valorisa/Downloads/VirtualBox\ 5.0.14\ Build\ 105127
    /VirtualBox-5.0.14-105127-OSX.dmg | tail -1 | awk '{$1=$2=""; print $0}'` | xargs -0 echo) 
    && sudo installer -pkg "${MOUNTDIR}/"*.pkg -target /
    
    Password:
    installer: Package name is Oracle VM VirtualBox
    installer: Upgrading at base path /
    installer: The upgrade was successful.
    

    Valorisa

    0 讨论(0)
  • 2021-02-09 02:27

    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.

    0 讨论(0)
提交回复
热议问题