FreeBSD Handbook : Installing Applications: The Ports collection : Getting a FreeBSD Port : Compiling ports from the Internet
Previous: Compiling ports from CDROM
Next: Skeletons

4.3.2. Compiling ports from the Internet

If you do not have a CDROM, or you want to make sure you get the very latest version of the port you want, you will need to download the skeleton for the port. Now this might sound like rather a fiddly job full of pitfalls, but it is actually very easy.

First, if you are running a release version of FreeBSD, make sure you get the appropriate ``upgrade kit'' for your release from the ports page. These packages include files that have been updated since the release that you may need to compile new ports.

The key to the skeletons is that the FreeBSD FTP server can create on-the-fly tarballs for you. Here is how it works, with the gnats program in the databases directory as an example (the bits in square brackets are comments. Do not type them in if you are trying this yourself!):-

 # cd /usr/ports
 # mkdir databases
 # cd databases
 # ftp ftp.freebsd.org
 [log in as `ftp' and give your email address when asked for a
 password. Remember to use binary (also known as image) mode!]
 > cd /pub/FreeBSD/ports/ports/databases
 > get gnats.tar		[tars up the gnats skeleton for us]
 > quit
 # tar xf gnats.tar		[extract the gnats skeleton]
 # cd gnats
 # make install			[build and install gnats]

What happened here? We connected to the FTP server in the usual way and went to its databases sub-directory. When we gave it the command `get gnats.tar', the FTP server tarred up the gnats directory for us.

We then extracted the gnats skeleton and went into the gnats directory to build the port. As we explained earlier, the make process noticed we did not have a copy of the source locally, so it fetched one before extracting, patching and building it.

Let's try something more ambitious now. Instead of getting a single port skeleton, let's get a whole sub-directory, for example all the database skeletons in the ports collection. It looks almost the same:-

 # cd /usr/ports
 # ftp ftp.freebsd.org
 [log in as `ftp' and give your email address when asked for a
 password. Remember to use binary (also known as image) mode!]
 > cd /pub/FreeBSD/ports/ports
 > get databases.tar		[tars up the databases directory for us]
 > quit
 # tar xf databases.tar		[extract all the database skeletons]
 # cd databases
 # make install			[build and install all the database ports]

With half a dozen straightforward commands, we have now got a set of database programs on our FreeBSD machine! All we did that was different from getting a single port skeleton and building it was that we got a whole directory at once, and compiled everything in it at once. Pretty impressive, no?

If you expect to be installing many ports, it is probably worth downloading all the ports directories.


FreeBSD Handbook : Installing Applications: The Ports collection : Getting a FreeBSD Port : Compiling ports from the Internet
Previous: Compiling ports from CDROM
Next: Skeletons