Installing MacPorts

The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading open source software on Mac OS X. As you’ll be able to see later, it’s easy to use but still very powerful.

Unless you already have it installed, the very first step in installing MacPorts actually starts with installing Xcode Developer Tools which is not installed by default. It comes with Mac OS X Applications DVD but it’s probably the best idea to download the latest version from Apple site. There are currently two branches of Xcode, 3.2.x and 4.1.x. If you are on Snow Leopard get Xcode 3, if you’re on Lion get Xcode 4.1, both are available on Apple Developers site, and unless you already have an account, you will need to register first.

After you’re logged in on Apple Dev site, you can download and install Xcode 3.2 from this link and then run Mac software update to update it to latest version. If you’re on Lion you can get Xcode 4.1 from this link or get it from App Store.

Now let’s deal with MacPorts installation. The easiest way to install it is with DMG package installer. Again if you’re on Snow Leopard get it from here, Lion version can be downloaded from here. Run installer which will setup everything automatically (copy files and modify your .bash_profile file by adding proper PATH variable for MacPorts tree which is something like export PATH=/opt/local/bin:/opt/local/sbin:$PATH).

Now open terminal and run this cmd:

sudo port -v selfupdate

This is how output looked on my system:

Dragan-Dinics-MacBook-Pro:~ dinke$ sudo port -v selfupdate
Password:
--->  Updating MacPorts base sources using rsync
receiving file list ... done
base.tar

sent 10864 bytes  received 111 bytes  4390.00 bytes/sec
total size is 3226624  speedup is 294.00
receiving file list ... done
base.tar.rmd160

sent 64 bytes  received 116 bytes  72.00 bytes/sec
total size is 512  speedup is 2.84
MacPorts base version 2.0.3 installed,
MacPorts base version 2.0.3 downloaded.
--->  Updating the ports tree
Synchronizing local ports tree from rsync://rsync.macports.org/release/tarballs/ports.tar
receiving file list ... done
ports.tar

sent 47525 bytes  received 5715 bytes  9680.00 bytes/sec
total size is 45947904  speedup is 863.03
receiving file list ... done
ports.tar.rmd160

sent 64 bytes  received 636 bytes  280.00 bytes/sec
total size is 512  speedup is 0.73
Creating port index in /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports

Total number of ports parsed:   0 
Ports successfully parsed:      0 
Ports failed:                   0 
Up-to-date ports skipped:       12335

--->  MacPorts base is already the latest version

The ports tree has been updated. To upgrade your installed ports, you should run
  port upgrade outdated
Dragan-Dinics-MacBook-Pro:~ dinke$

If you didn’t get any error message, that’s it you’re done. Congratulations!

Now let’s deal with the installation of some apps, and we will start with wget which is very nice cli tool for downloading stuff and somehow it is not available on Mac by default. So let’s start by issuing port search cmd:

Dragan-Dinics-MacBook-Pro:/ dinke$ port search wget
gwget @1.0.4 (gnome, net)
    Gwget is a Download Manager for Gnome 2. It uses wget as a backend.

wget @1.13.4 (net, www)
    internet file retriever

wgetpro @0.1.3 (net, www)
    advanced internet file retriever

wput @0.6.2 (net)
    wput is like wget but is for uploading files to ftp-servers

Found 4 ports.
Dragan-Dinics-MacBook-Pro:/ dinke$

So it’s there in ports (internet file retriever), we’re going to install it by issuing port install cmd. Since this will require root permissions you will have to do it with sudo:

Dragan-Dinics-MacBook-Pro:/ dinke$ sudo port install wget
Password:
--->  Computing dependencies for wget
--->  Dependencies to be installed: gnutls libgcrypt libgpg-error libtasn1 lzo2
--->  Fetching archive for libgpg-error
--->  Attempting to fetch libgpg-error-1.10_0.darwin_10.x86_64.tbz2 from http://packages.macports.org/libgpg-error
--->  Attempting to fetch libgpg-error-1.10_0.darwin_10.x86_64.tbz2.rmd160 from http://packages.macports.org/libgpg-error
--->  Installing libgpg-error @1.10_0
--->  Activating libgpg-error @1.10_0
--->  Cleaning libgpg-error
--->  Fetching archive for libgcrypt
--->  Attempting to fetch libgcrypt-1.5.0_0.darwin_10.x86_64.tbz2 from http://packages.macports.org/libgcrypt
--->  Attempting to fetch libgcrypt-1.5.0_0.darwin_10.x86_64.tbz2.rmd160 from http://packages.macports.org/libgcrypt
--->  Installing libgcrypt @1.5.0_0
--->  Activating libgcrypt @1.5.0_0
--->  Cleaning libgcrypt
--->  Fetching archive for libtasn1
--->  Attempting to fetch libtasn1-2.9_0.darwin_10.x86_64.tbz2 from http://packages.macports.org/libtasn1
--->  Attempting to fetch libtasn1-2.9_0.darwin_10.x86_64.tbz2.rmd160 from http://packages.macports.org/libtasn1
--->  Installing libtasn1 @2.9_0
--->  Activating libtasn1 @2.9_0
--->  Cleaning libtasn1
--->  Fetching archive for lzo2
--->  Attempting to fetch lzo2-2.05_1.darwin_10.x86_64.tbz2 from http://packages.macports.org/lzo2
--->  Attempting to fetch lzo2-2.05_1.darwin_10.x86_64.tbz2.rmd160 from http://packages.macports.org/lzo2
--->  Installing lzo2 @2.05_1
--->  Activating lzo2 @2.05_1
--->  Cleaning lzo2
--->  Fetching archive for gnutls
--->  Attempting to fetch gnutls-2.8.6_1.darwin_10.x86_64.tbz2 from http://packages.macports.org/gnutls
--->  Attempting to fetch gnutls-2.8.6_1.darwin_10.x86_64.tbz2.rmd160 from http://packages.macports.org/gnutls
--->  Installing gnutls @2.8.6_1
--->  Activating gnutls @2.8.6_1
--->  Cleaning gnutls
--->  Fetching archive for wget
--->  Attempting to fetch wget-1.13.4_0+ssl.darwin_10.x86_64.tbz2 from http://packages.macports.org/wget
--->  Attempting to fetch wget-1.13.4_0+ssl.darwin_10.x86_64.tbz2.rmd160 from http://packages.macports.org/wget
--->  Installing wget @1.13.4_0+ssl
--->  Activating wget @1.13.4_0+ssl
To customize wget, you can copy wgetrc.sample to wgetrc
in /opt/local/etc and then make changes.
--->  Cleaning wget
Dragan-Dinics-MacBook-Pro:/ dinke$ 

Now issue wget cmd and you’ll get output like this:

Dragan-Dinics-MacBook-Pro:/ dinke$ wget
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.
Dragan-Dinics-MacBook-Pro:/ dinke$

which means that wget tool is successfully installed and ready to be used for downloading stuff from the Internet. Enjoy!

Useful links:
http://www.macports.org/install.php
http://guide.macports.org

Comments

  1. October 15th, 2011 | 2:20 am

    […] In my previous post I’ve explained how to setup MacPorts on Mac OS X. Now we’re going to use it in order to setup fully working and flexible “LAMP” […]

Leave a reply