![]() |
|
| Daemon News Ezine | BSD News | BSD Mall | BSD Support Forum | BSD Advocacy | BSD Updates |
An Introduction to PortsJames Howard
The FreeBSD Ports TreeThe 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: cd /usr/ports/sysutils/uwatch make install 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.
An Anatomy of a PortA 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:
Makefile files files/md5 pkg pkg/COMMENT pkg/DESCR pkg/PLIST patches patches/patch-aa Each of these files contains information essential to a port. The following is a breakdown of the information contained in each file.
Using a PortNow, installing this program is a simple process as shown above. The steps listed above will yield this output:
root@byzantine:# cd /usr/ports/sysutils/uwatch/ root@byzantine:/usr/ports/sysutils/uwatch# make install >> uwatch-1.0.tar.gz doesn't seem to exist on this system. >>Attempting to fetch from ftp://ftp.wam.umd.edu/pub/howardjp/software/uwatch/. Receiving uwatch-1.0.tar.gz (4373 bytes): 100% 4373 bytes transferred in 0.2 seconds (22.73 Kbytes/s) ===> Extracting for uwatch-1.0 >> Checksum OK for uwatch-1.0.tar.gz. ===> Patching for uwatch-1.0 ===> Applying FreeBSD patches for uwatch-1.0 ===> Configuring for uwatch-1.0 ===> Building for uwatch-1.0 Warning: Object directory not changed from original usr/ports/sysutils/uwatch/work/uwatch-1.0 cc -Wall -I/usr/local/usr/include -c uwatch.c cc -Wall -I/usr/local/usr/include -o uwatch uwatch.o gzip -cn uwatch.1 > uwatch.1.gz ===> Installing for uwatch-1.0 install -c -s -o root -g wheel -m 555 uwatch /usr/local/bin install -c -o root -g wheel -m 444 uwatch.1.gz /usr/local/man/man1 ===> Generating temporary packing list ===> Registering installation for uwatch-1.0 root@byzantine:/usr/ports/sysutils/uwatch# At this point, the application is ready to be run. If we wish to remove the application, we simply run make deinstall.
root@byzantine:/usr/ports/sysutils/uwatch# make deinstall ===> Deinstalling for uwatch-1.0 root@byzantine:/usr/ports/sysutils/uwatch# 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 Ports Collection one of the most attractive reasons to use FreeBSD. |