The FreeBSD Ports Collection offers a simple and convenient method to prepackage software applications for the FreeBSD operating environment. Using a standard format and installation paradigm, the Ports Collection is an easy way for system administrators to install and update over 3200 applications, utilities, and system tools.
These 3200 programs are listed using a special directory tree under
/usr/ports where they are listed by category. Some categories include “databases”, “java”, “math”, and “security”. Other categories, such as “chinese”, “german”, “russian”, and “vietnamese”, include programs written or modified to handle international users. There are also a number of programming language specific categories for Tcl/Tk, Perl, and Python.
However, the most important feature of the Ports Collection is its ease of use. To install a port, you simply change to the directory the port lives in and type
make install. For an example, we will use a system utility called UWATCH. The following commands will install the port:
Since the programs in the Ports Collection are often very large, the program data is not a part of the port. This is where the magic happens. The Ports Collection knows to look on the CD for the source tarball if a CD is in the system. If it cannot find the source code on the CD, it also knows several locations on the Internet where it could be. Therefore, if your system is connected to the Internet, the port’s source code will be automatically downloaded as part of the installation process.
The Ports Collection ease of use comes from another solved problem: port interdependency. If a port was written using the Tcl/Tk programming language and you do not have Tcl/Tk installed, the Ports Collection will also download and install the required version of it. This greatly simplifies the way applications are installed and makes even the most complicated software packages easy to work with.
A basic port has a very simple structure. For an example, we’ll look at a port called UWATCH. This is considered a system utility, therefore the port information is located in
/usr/ports/sysutils/uwatch. The port itself has the following structure:
Each of these files contains information essential to a port. The following is a breakdown of the information contained in each file.
This is the file read in by the
make install command. It contains the port’s name, location, creator, and what other ports it depends on. The
Makefile from UWATCH is very simple:
This preamble lists the name of the port, the date it was created, and the creator.
This is meant to be human readable. The information contained between dollar
$”) is version control information from CVS and tells the last
time the file was modified and who modified it.
These two variables set the name of the port and the most recently available
CATEGORIES variable lists all the possible categories this port
This variable lists a number of URLs where the port can be downloaded from if it is not already on the system.
This lists the email address of the creator of the port. In this case, my email address is listed.
This is information for the online documentation set, usually called the manpages.
This is the last line of every port’s
Makefile and it instructs make
to call the system-wide Ports
Makefile which does the heavy lifting.
This is a directory which contains files needed to build the port. Usually, this directory contains a single file,
This file contains an MD5 electronic signature of the port. This is used to verify the integrity of a port before it is built. If the signatures do not match, the build will be stopped.
This directory holds information on patching the program to run on FreeBSD. Some ports were not developed natively on FreeBSD and those may require some changes before the build. There can be a number of patch files listed all named
patch-?? where “
??” are two letters. The patches are applied in alphabetical order.
This port only has one patch instructing the UWATCH
Makefile where to install the finished program.
The Ports Collection has a twin known as the Packages Collection. The Packages Collection is a set of pre-made ports which only need to be installed. Almost all packages are built from ports and some data is needed for the packages to be created. This data lives in the
This is a one sentence description of the package. In this example, the description is:
This is a longer description of the package and may be several paragraphs long. Since UWATCH is a simple program, this description is still relatively short.
This final file lists all the other files installed. In this case, only one other file is installed, the actual program. This list is used when deleting a package from the system.
Later, if you want to uninstall this port, those files listed in
pkg/PLIST will be removed.
Now, installing this program is a simple process as shown “above”:
The steps listed above will yield this output:
At this point, the application is ready to be run. If we wish to remove the application, we simply run
And the application has been removed.
Using the Ports Collection simplifies the work required to install and maintain third-party applications and greatly reduces the time required by the system administrator to install and configure software. This makes the Ports Collection one of the most attractive reasons to use FreeBSD.