The ports tree is a set of Makefiles that download, patch, configure and install userland programs so you can run them in OpenBSD environment without having to do all that by hand. You can get the ports tree from any of the OpenBSD FTP servers in /pub/OpenBSD/3.1/ports.tar.gz. The most recent ports are available via the 'ports' cvs tree, or /pub/OpenBSD/snapshots/ports.tar.gz.

    

OpenBSD has three "active" versions at any point in time:
DO NOT mix versions of Ports and OpenBSD!

	sudo su
	cd /usr
	ftp ftp://openbsd.mirrors.pair.com/3.8/ports.tar.gz
	tar -zxvf ports.tar.gz

	$ ftp ftp://ftp.openbsd.org/pub/OpenBSD/3.1/ports.tar.gz
	$ sudo cp ports.tar.gz /usr
	$ cd /usr; sudo tar xfz ports.tar.gz

Use the ports tree to search for keywords. To do this use make search
key="searchkey". Here is an example of a search for 'samba':

$ make search key="samba"

Ports are set up to be EXTREMELY easy to make and install. Here is an example
install for someone wanting to install the X11 program xfig. You'll notice
the dependencies are automatically detected and completed:

First you need to cd to the dir of the program you want. If you are searching
for a program, you can either update your locate database, or use the search
function. Once you are in the dir of the program you want, you can just type
make install. For example.

	$ sudo make install

The system will automatically download the source code, compile the program,
generate a "package", and install the software. The cool thing is that the
software is installed as a package meaning you can easily remove it using
the pkg_ commands. For example, to list all installed packages, type pkg_info.
To remove a package type pkg_delete.

Using Flavors

Many of the applications in the ports tree support different install options,
called flavors. If a port comes in multiple flavors, you can use these options
simply by setting an environment variable before you compile the port. If
multiple features are needed, the FLAVOR variable can be set to a space-
delimited list of the supported and desired flavors. Currently, many ports
have flavors that include database support, support for systems without X, or
network additions like SSL and IPv6. 

$ pwd
/usr/ports/net/mtr
$ make show=FLAVORS
no_x11
$ env FLAVOR="no_x11" make
===>  mtr-0.42-curses depends on: gmake-3.79.1 - found
===>  Checking files for mtr-0.42-no_x11
>> mtr-0.42.tar.gz doesn't seem to exist on this system.
>> Attempting to fetch /usr/ports/distfiles/mtr-0.42.tar.gz from ftp://ftp.bitwizard.nl/mtr/.
[snip]
$ sudo env FLAVOR="no_x11" make install
===>  Faking installation for mtr-0.42-no_x11
===>  Building package for mtr-0.42-no_x11
Creating package /usr/ports/packages/i386/All/mtr-0.42-no_x11.tgz
Using SrcDir value of /usr/ports/net/mtr/w-mtr-0.42-no_x11/fake-i386-curses/usr/local
Creating gzip'd tar ball in '/usr/ports/packages/i386/All/mtr-0.42-no_x11.tgz'
===>  Installing mtr-0.42-no_x11 from /usr/ports/packages/i386/All/mtr-0.42-no_x11.tgz


Listing Installed ports/packages

You can see a list of both ports and packages by using the pkg_info command.

	$ /usr/sbin/pkg_info

Install PICO

	cd /usr/ports/mail/pine
	$ make NO_IGNORE=Yes SUBPACKAGE=-pico
	$ su
	# make NO_IGNORE=Yes SUBPACKAGE=-pico install

Install PICO (New Method):

	cd /usr/ports/mail/pine
	env SUBPACKAGE=-pico make

Install PICO (Package Method)

	pkg_add ftp://openbsd.mirrors.pair.com/3.8/packages/i386/pico-4.10.tgz

Change default SHell (with pico instead of vi):

	bashvxx$ export EDITOR=/usr/local/bin/pico
	bashvxx$ chsh


Update Ports tree via CVS:
	cvs -d anoncvs1.usa.openbsd.org:/cvs update -PAd
	cvs -d anoncvs@anoncvs1.usa.openbsd.org:/cvs update -PAd

	cd /usr/ports
	cvs -q -d anoncvs1.usa.openbsd.org:/cvs up -r OPENBSD_3_2 -Pd

	anoncvs@anoncvs1.usa.openbsd.org:/cvs