OpenBSD Install Ports Tree Collection

by on May 3, 2008 · 4 comments· LAST UPDATED May 28, 2014

in , ,

I have installed OpenBSD operating system but ports collection is missing at /usr/ports directory. How do I install ports from ftp / http site under OpenBSD?

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsOpenBSD
Estimated completion time5m
Port collection is essential for OpenBSD server or desktop/laptop based system. You can use the OpenBSD Ports Collection to create binary packages for third party applications.

Method # 1: Install ports from OpenBSD CDROM

If you have OpenBSD CDROM type the following command to copy out the contents of the ports tree to /usr/ports; you would mount the CD-ROM with ports on it on /cdrom and issue a command like follows:
# mount /cdrom
# cd /usr
# tar zxf /cdrom/ports.tar.gz

Method # 2: Install OpenBSD ports from FTP / HTTP mirror site

Use wget command or ftp command client and grab ports.tar.gz, enter:
# cd /usr
# wget ftp://ftp.openbsd.org/pub/OpenBSD/$(uname -r)/ports.tar.gz

OR
# cd /usr
# ftp ftp://ftp.openbsd.org/pub/OpenBSD/$(uname -r)/ports.tar.gz

Sample output:

--11:44:39--  ftp://ftp.openbsd.org/pub/OpenBSD/4.1/ports.tar.gz
           => `ports.tar.gz'
Resolving ftp.openbsd.org... 129.128.5.191
Connecting to ftp.openbsd.org|129.128.5.191|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/OpenBSD/4.1 ... done.
==> PASV ... done.    ==> RETR ports.tar.gz ... done.
Length: 11,184,931 (11M) (unauthoritative)
100%[=================================================================================================================>] 11,184,931   236.83K/s    ETA 00:00
11:45:29 (230.09 KB/s) - `ports.tar.gz' saved [11184931]

Extract ports tree on a OpenBSD

To extract ports.tar.gz use tar command as follows:
# tar -zxvf ports.tar.gz
Sample outputs:

ports
ports/CVS
ports/CVS/Repository
ports/CVS/Entries
ports/.cvsignore
ports/INDEX
ports/Makefile
ports/README
ports/archivers
ports/archivers/CVS
ports/archivers/CVS/Repository
ports/archivers/CVS/Entries
....
..
...
ports/x11/yeahlaunch/pkg
ports/x11/yeahlaunch/pkg/CVS
ports/x11/yeahlaunch/pkg/CVS/Repository
ports/x11/yeahlaunch/pkg/CVS/Entries
ports/x11/yeahlaunch/pkg/DESCR
ports/x11/yeahlaunch/pkg/PLIST

Once extracted, you can delete ports.tar.gz file using rm command as follows:
# rm ports.tar.gz

How do I use ports on a OpenBSD

To use ports, cd into /usr/ports/ directory:
# cd /usr/ports
# ls

Sample outputs:

.cvsignore      biology         emulators       lang            productivity
CVS             books           fonts           mail            security
INDEX           cad             games           math            shells
Makefile        chinese         geo             meta            sysutils
README          comms           graphics        misc            telephony
archivers       converters      infrastructure  multimedia      tests
astro           databases       inputmethods    net             textproc
audio           devel           japanese        news            www
base            editors         java            plan9           x11
benchmarks      education       korean          print

To install bash shell from ports, type:
# cd /usr/ports/shell/bash
# make install clean all

See the OpenBSD ports system for more info.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 4 comments… read them below or add one }

1 Knight August 22, 2009 at 4:21 pm

Thank you very much for this. I had trouble getting OpenBSD kicking with a GUI but with ports it is a snap. I used “ftp” however, instead of wget, as 4.5 did not come with wget by default. Cheers.

Reply

2 kenpem September 2, 2009 at 8:37 am

I wish your page had ranked higher in my search results! Just wasted hours on other obscure things. This tells me exactly what I needed to know. Thanks.

Reply

3 purpleoptic August 8, 2010 at 6:04 pm

you will need to install wget first before you try this in OpenBSD 4.7

Reply

4 Doug December 27, 2010 at 11:51 pm

and as I just discovered, you can install wget on OpenBSD by doing this:

1. ftp http://ftp.openbsd.org/OpenBSD/x.y/ports.tar.gz for your release version x.y
2. cd /usr
3. tar xvfz /path/to/ports.tar.gz
4. cd /usr/ports/net/wget
5. make

If a non-noob can recommend a more glitzy way to do this, please follow up. Thanks.

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , ,

Previous Faq:

Next Faq: