About nixCraft

Topics

Openbsd install or add binary software package howto

Posted by Vivek Gite [Last updated: November 8, 2006]

OpenBSD logo

Just like FreeBSD, OpenBSD comes with pkg_add command. It is used to install a binary or upgrade packages from http or ftp mirror over internet. If you have purchased OpenBSD DVD/CD you can install packages from CD itself.

pkg_add command used to update existing packages too.

Task: Add package from ftp or http mirror

Use generic OpenBSD mirror such as follows:
ftp://ftp.openbsd.org/pub/OpenBSD/4.0/packages/amd64/ or ftp://ftp.openbsd.org/pub/OpenBSD/4.0/packages/i386/
Please note that version number (4.) and machine architecture (amd64). You can find complete
OpenBSD mirror list here.

First, you need to setup PKG_PATH variable so that you don't have to type complete mirror path each and every time. You need to add file to your shell startup file such as ~/.bashrc or ~/.bash_profile. PKG_PATH variable MUST end in a slash (/).
$ export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.0/packages/amd64/
OR
# export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.0/packages/$(machine -a)/

Now to add a package called links:
$ sudo pkg_add -v linksOR # pkg_add -v -i links
Where,

# pkg_add -i lighttpdOutput:

Ambiguous: lighttpd could be lighttpd-1.4.11 lighttpd-1.4.11-ldap lighttpd-1.4.11-ldap-mysql lighttpd-1.4.11-mysql
Choose one package
         0: 
         1: lighttpd-1.4.11
         2: lighttpd-1.4.11-ldap
         3: lighttpd-1.4.11-ldap-mysql
         4: lighttpd-1.4.11-mysql
Your choice:   1
lighttpd-1.4.11:pcre-6.4p1: complete
lighttpd-1.4.11: complete 

Note that pkg_add prompted for version of lighttpd, you wish to install.

Task: Display or list of OpenBSD installed packages

Use pkg_info command:
$ pkg_infoOutput:

bash-3.1.17         GNU Bourne Again Shell
expat-2.0.0         XML 1.0 parser written in C
gettext-0.14.5p1    GNU gettext
libiconv-1.9.2p3    character set conversion library
lighttpd-1.4.11     secure, fast, compliant, and very flexible web-server
links-0.99          text browser, displays while downloading
pcre-6.4p1          perl-compatible regular expression library
vim-7.0.42-no_x11   vi clone, many additional features
wget-1.10.2p0       retrieve files from the web via HTTP, HTTPS and FTP

Task: Update existing package

To upgrade or update links package type command:
# pkg_add -u links

Task: Update all packages

pkg_add will update all installed packages if no package name is provided:
# pkg_add

Task: Set active or passive mode

If you are behind firewall you may need to set active or passive mode with FTPMODE variable (default is passive).
$ export t FTPMODE=active

E-mail this to a Friend    Printable Version

You may also be interested in other helpful articles:

Discussion on This Article:

  1. jman Says:

    Are packages better than ports?
    With ports I do - make install clean and it usually sorts out any dependency issues.
    But with pkg_add I have had dependency errors.

  2. rob Says:

    jman - I prefer to use the packages whenever possible — both pkg_add(1) and the ports methods are capable of determining required dependencies. If you are experiencing specific package dependency issues, I suggest posting on the appropriate OpenBSD mail list.
    Those OpenBSD gurus are super-smart and very helpful.

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Powered by Open source software.