Tutorial: Installing MacPorts
Se houver algém interessado, posso traduzir para Português!
MacPorts is a great project that brings a bunch open source application to the Mac world. It works like the ports system in FreeBSD, OpenBSD or NetBSD, <insert other flavors here>.
It takes care of all the work,
- Resolve dependencies
- Download
- Patch
- Configure
- Compile
- Install
Software port definition from Wikipedia
In computer science, porting is the process of adapting software so that an executable program can be created for a computing environment that is different from the one for which it was originally designed (e.g. different CPU, operating system, or third party library). The term is also used in a general way to refer to the changing of software/hardware to make them usable in different environments.
1st step download:
Head over to MacPorts and download the latest version 1.5.0 for your system MacPorts-1.5.0-10.4.dmg for Tiger, MacPorts-1.5.0-10.3.dmg for Panther.
2nd step install:
Install it, just follow the instructions on screen. All should run well, and it might take a bit, since it as to install all the ports tree. The ports tree is a directory structure with the applications (ports) divided into categories, each port as it's own set of files, including patches, scripts, etc.... For MacPorts is lives in /opt/local/var/macports/sources/rsync.macports.org/release/ports
3rd step setup:
Now we need to set it up. You can choose to use the Terminal /Applications/Utilities/Terminal or a GUI utility PortAuthority or Porticus. This tutorial will focus on the terminal usage, the Terminal.app will do just fine, but i prefer to use iTerm.
Let's start by letting your system know where MacPorts was installed by adding it to your $PATH environment variable.
In the terminal, setup PATH
eflow:~ ravage$ export PATH=$PATH:/opt/local/bin:/opt/local/sbinverify
eflow:~ ravage$ echo $PATH /bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/local/bin:/opt/local/sbin
make it permanent, add the path to ~/.profile, the DISPLAY is for binding X11 to display 0.
echo 'export PATH=$PATH:/opt/local/bin:/opt/local/sbin' >> ~/.profile echo 'export DISPLAY=:0.0' >> ~/.profile
4th step update:
Now we are ready to use MacPorts, let's sync it and update it. The sync command fetchs port updates from the Internet, selfupdate tries to update MacPorts system.
The sudo command, elevates the user privileges to root (administrator), when asked for a password, just enter yours and press enter. It should take a while to sync with online repositories.
eflow:~ ravage$ sudo port sync Password: eflow:~ ravage$ sudo port selfupdate MacPorts base version 1.520 installed Downloaded MacPorts base version 1.520 The MacPorts installation is not outdated and so was not updated selfupdate done!
5th step use:
You should sync and selfupdate regularly. I usualy sync before installing ports, and selftupdate from time to time.
So how do we use MacPorts? Very easy, let's imagine i want to install Vim 7 with Python, Ruby, Perl and Multibyte support
lets search for Vim, use search to see if the application you need exists, ex: port search apache
eflow:~ ravage$ port search vim vimdrop aqua/vimdrop 0.8 vim editors/vim 7.1.100 vim-app editors/vim-app 7.1.100 p5-text-vimcolor perl/p5-text-vimcolor 0.11 vim2html textproc/vim2html 1.46
We are interested in Vim 7 (vim editors/vim), now, i want vim to support a bunch of features which where specified above. MacPorts provides the variants keyword for that, that way we can check which features our port will be installed with, lets take a peek,
eflow:~ ravage$ port variants vim
vim has the variants:
universal
athena
gtk1
gtk2
motif
tiny
small
big
huge
multibyte
xim
perl
python
ruby
tcl
cscope
nls
hmmmm, there's a bunch of them! Let's install Vim with just the ones we want.
eflow:~ ravage$ sudo port install vim +python +ruby +perl +multibyte Password: --cropped--now MacPorts will work it's voodoo and you will see a bunch of output, it will take some time to finish. All port are installed into /opt/local, so it won't interfere with your current system, Vim will be in,
eflow:~ ravage$ ls -l /opt/local/bin/vim -rwxr-xr-x 2 root wheel 2441848 2007-08-22 12:21 /opt/local/bin/vimNow play with it and install whatever you need!
Now, we want to see what we have installed, just do,
eflow:~ ravage$ port installed The following ports are currently installed: a52dec @0.7.4_0 (active) apache2 @2.2.4_0+openbsd apache2 @2.2.4_1+openbsd (active) apr @1.2.8_0 --cropped--
Uninstalling it's also easy with,
eflow:~ ravage$ sudo port uninstall vim ---> The following versions of vim are currently installed: --cropped-- ---> vim @7.1.087_0+cscope+multibyte+perl+python+ruby (active) Error: port uninstall failed: Registry error: Please specify the full versionas recorded in the port registry. eflow:~ ravage$ sudo port uninstall vim @7.1.087_0+cscope+multibyte+perl+python+ruby ---> Deactivating vim 7.1.087_0+cscope+multibyte+perl+python+ruby --cropped--
Checking after a sync, which ports are outdated,
eflow:~ ravage$ port outdated The following installed ports are outdated: apr 1.2.9_0Upgrading them,
eflow:~ ravage$ sudo port upgrade outdatedSo now we can install, upgrade, uninstall. Just some other commands and we are done!
Checking contents of a installed port,
eflow:~ ravage$ port contents vim | less Port vim contains: /opt/local/bin/ex /opt/local/bin/rview /opt/local/bin/rvim /opt/local/bin/view /opt/local/bin/vim /opt/local/bin/vimdiff /opt/local/bin/vimtutor /opt/local/bin/xxd --cropped--Which port provides a specific file,
eflow:~ ravage$ port provides /opt/local/bin/psql82 /opt/local/bin/psql82 is provided by: postgresql82To finalize, lets make Vim 7 default system wide,
eflow:~ ravage$ cd /usr/bin/ eflow:/usr/bin ravage$ sudo mv vim vim-6 eflow:/usr/bin ravage$ sudo ln -s /opt/local/bin/vim eflow:/usr/bin ravage$ ls -l vim lrwxr-xr-x 1 root wheel 18 2007-09-11 17:50 vim -> /opt/local/bin/vimas you can see, now vim points to your vim installed from ports.Well, i think most part is covered and should get you started on knowing and using MacPorts, which is an awesome project.
Feel free to point corrections or suggestions.References:
http://trac.macosforge.org/projects/macports/wiki/UsingMacPortsQuickStart