Installing MacPorts From Command Line

Well, installing MacPorts is tedious itself, and can be especially annoying to manage when you have to do it on (several) remote systems. Here’s how you can perform the meticulous task completely from the command line:

  • Log in via SSH, or if you’re doing it from the system itself, open Terminal.
  • Download MacPorts from their SVN repository using cURL:
    curl -O http://svn.macports.org/repository/macports/downloads/MacPorts-1.7.1/MacPorts-1.7.1-10.5-Leopard.dmg
  • Mount the MacPorts disk image (dmg) using hdiutil:
    hdiutil attach MacPorts-1.7.1-10.5-Leopard.dmg
  • Run the MacPorts installer from the mounted MacPorts dmg:
    sudo installer -verbose -pkg /Volumes/MacPorts-1.7.1/MacPorts-1.7.1.pkg -target /
  • Update the MacPorts installation with the following command:
    sudo port -v selfupdate

Note:
You can unmount the MacPorts disk image (dmg) by running the mount command by itself to retrieve the disk ID, then running the command: hdiutil detach -verbose /dev/disk[ID]

Leave a Reply