Installing MacPorts from the Command Line

I wanted to install MacPorts on an Xserve using ssh. This involved doing two things I had never done from the shell: mounting a disk image and running an installer. Here are some quick instructions in case someone else needs to do this. It is assumed that you have already installed Apple’s X11 and the X11SDK per the MacPort install instructions.

  • ssh to the Mac OS X system
  • Download MacPorts
  • Mount disk image
    • hdiutil attach MacPorts-1.5.0-10.4.dmg
  • Run the installer
    • sudo installer -verbose -pkg /Volumes/MacPorts-1.5.0/MacPorts-1.5.0.pkg -target /
  • Add /opt/local/bin (and probably /opt/local/sbin) to your path in whatever way your shell requires
  • Update MacPorts to the latest version
    • sudo port -v selfupdate
  • Unmount the disk image
    • hdiutil detach -verbose /dev/disk4
    • The device was displayed when you mounted the image, if you forgot it then run mount

3 thoughts on “Installing MacPorts from the Command Line

  1. loommy

    our net-admin has blocked rsync ports, so i couldnt update my macports, any suggestion? thanks..

  2. Robert Brewer Post author

    The first suggestion I would make is to have a chat with your net-admin and ask politely if he/she can open up the rsync port outbound. You’d be surprised how helpful system administrators can be if asked nicely.

    If that doesn’t work, you can try looking at this message from the MacPorts mailing list. You’ll need to find a way to proxy the connection on a port that your network does allow:

    If the Mac you are trying to install on is portable, then you might consider taking it somewhere you can get unfiltered Internet access and do the rsync there.

    Good luck.


Leave a Reply to Robert Brewer Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s