27 August 2006

A short ports primer

This short article is mainly to support the article "Top ten rules for using ports system," which contains some terminology that may be confusing to someone who isn't already familiar with the FreeBSD ports system.

What's a port? In FreeBSD, a port usually refers to third party software that may be installed via the ports system.

What's the ports tree? It's a large directory tree usually located at "/usr/ports". It contains many category subdirectories, each of which contains many port subdirectories. Each port subdirectory contains a Makefile, a text file with a short description of the port ("pkg-descr"), maybe some FreeBSD specific patches, and a few other items useful for installing or maintaining the port.

What's a package? A package is just a precompiled binary version of some port. These are widely available for each new release. They are not widely available for updated versions of the software that may come out between FreeBSD releases (for that use the port). Once installed, a package is no different from the same version port that was compiled with the same options. Either would be recorded in the system's package database the same way. Therefore, statements about one often apply to the other.

How do I install a port? The typical way to install a port is to go to that ports directory in the tree and then type "make install" as the root user. For example, to install the firefox web browser, you would go to the directory "/usr/ports/www/firefox". The ports system will automatically identify and attempt to install any other required software and then install firefox. When using this method the ports system will take several steps for each port, the most notable of which are: download the source code, compile software, copy the new binaries to the appropriate locations, and record details of the installation in the system's package database.

How do I install a package? Download the package then, as user root, type "pkg_add filename". Alternatively, you can have pkg_add attempt to download the file for you first by typing "pkg_add -r portname" (as user root).

How do I delete a port or package? By using the "pkg_delete fullportname" command (as root). In this case, it's not enough to just know the name of the port or its directory in the tree, you want to use the full name of the installed port, which will include version numbers at the end. For example, "firefox-,1". A good way to find out this full name is with the "pkg_info" command which will give you a list of all installed ports/packages. (You could also use a wildcard, e.g. "pkg_delete firefox-*", but be careful!)

How do I update the ports tree? There are two main tools used to update the ports tree: cvsup and portsnap. cvsup is itself a port. portsnap is the newer tool and is included in the base system in recent versions of FreeBSD. Type "man portsnap" to view the manual. ... Also, read the "Top ten rules ..." for some thoughts on when you should update your ports tree.

[ tags: , ]



At 2/1/07 13:52, Anonymous Anonymous said...

And how do you install a package from ports locally as a regular user?

At 28/6/07 22:17, Anonymous Anonymous said...

Instead of pkg_delete fullportname, you could also use the -x option

e.g: pkg_delete -x firefox

man pkg_delete:
-x Treat the pkg-name as a regular expression and delete all packages whose names match that regular expression.

Pablo Costa


Post a Comment

<< Home