There are two ways of getting hold of the FreeBSD port for a program. One requires a FreeBSD CDROM , the other involves using an Internet Connection.
If you answered yes to the question ``Do you want to link the ports collection to your CDROM'' during the FreeBSD installation, the initial setting up will already have been done for you.
If not, make sure the FreeBSD CDROM is in the drive and mounted on, say, /cdrom. Then do
# mkdir /usr/ports # cd /usr/ports # ln -s /cdrom/ports/distfiles distfiles
to enable the ports make mechanism to find the tarballs (it expects to find them in /usr/ports/distfiles, which is why we sym-linked the CDROM's tarball directory to there).
Now, suppose you want to install the gnats program from the databases directory. Here's how to do it:-
# cd /usr/ports # mkdir databases # cp -R /cdrom/ports/databases/gnats databases # cd databases/gnats # make install
Or if you're a serious database user and you want to compare all the ones available in the Ports collection, do
# cd /usr/ports # cp -R /cdrom/ports/databases . # cd databases # make install
(yes, that really is a dot on its own after the cp command and not a mistake. It's Unix-ese for ``the current directory'')
and the ports make mechanism will automatically compile and install all the ports in the databases directory for you!
If you don't like this method, here's a completely different way of doing it:-
Create a "link tree" to it using the
lndir(1) command that
comes with the XFree86 distribution. Find a location with
some free space and create a directory there, and make a symbolic link
/usr/ports to that directory. Then invoke the
lndir(1) command with the full pathname of the ``ports''
directory on the CDROM as an argument (this might be, for example,
lndir /cdrom/ports). Then you can build
ports directly off the CDROM by building them in the link tree you
Note that there are some ports for which we cannot provide the original source in the CDROM due to licensing limitations. In that case, you will need to look at the section on Compiling ports using an Internet connection.
If you don't have a CDROM, or you want to make sure you get the very latest version of the port you want, you'll need to download the skeleton for the port. Now this might sound like rather a fiddly job full of pitfalls, like downloading the patches into the pkg sub-directory by mistake, but it's actually very easy.
The key to it is that the FreeBSD FTP server can create on-the-fly tarballs for you. Here's how it works, with the gnats program in the databases directory as an example (the bits in square brackets are comments, don't type them in if you're 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 (aka image) mode!] > cd /pub/FreeBSD/ports/databases > get gnats.tar.gz [tarballs up the gnats skeleton for us] > quit # tar xzf gnats.tar.gz [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.gz', the FTP server tarballed up the gnats directory for us and even went to the trouble of compressing it before sending it so we could get our hands on it a little quicker.
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 didn't 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 (aka image) mode!] > cd /pub/FreeBSD/ports/databases > get databases.tar.gz [tarballs up the databases directory for us] > quit # tar xzf databases.tar.gz [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 more than one or two ports, it's probably worth downloading all the ports directories - this involves downloading 2 or 3MB, when they're compressed. However, don't get carried away and type 'get ports.tar.gz' unless you're prepared to download the distfiles directory as well - this contains the source code for every single port and will take a very long time to download!