Saturday, April 18, 2009

Enable repositories in OS X with MacPorts

Linux has a great feature in that you can install software packages via repositories; you never have to surf the web searching for the installer to download, just enter a command at the Terminal and the installation is handled for you. Mac OS X does not include this functionality out of the box but can be enabled by installing MacPorts. MacPorts is a free and open source command line utility installed through an OS X .pkg file.

The installer will add the necessary environment variables to ~/.profile so that you can use it at the Terminal. However, if you are using a .bash_profile or .bashrc file the system will never see ~/.profile so you will need to either link to that file or add these lines to the file that holds your customizations:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
Open a new Terminal session and you will now be able to use MacPorts. You can access the MacPorts interface by using the port command. To search for a specific package, type:
port search [package name]
Install a package:
sudo port install [package]
Uninstall a package:
port uninstall [package]
List all installed packages:
port installed
Update MacPorts and refresh repository listing:
sudo port selfupdate
Upgrade a specific package:
sudo port upgrade [package]
Upgrade all packages:
sudo port upgrade outdated
Clean up temporary files created when installing packages:
sudo port clean --all
Full documentation is available here and a full list of packages is available here.

No comments:

Post a Comment