1. What is pkgsrc
  2. Documentation
  3. Preparing pkgsrc
    1. Obtaining the current pkgsrc source tree
    2. Creating WRKOBJDIR
    3. Creating DISTDIR
  4. Installing packages
  5. List Packages
  6. Removing Packages
  7. Updating Packages
  8. On-line help

What is pkgsrc

Pkgsrc [spoken: package source] is the main package management framework for NetBSD. With pkgsrc you can easily add, remove and manage software on your system. Pkgsrc is basically a set of files, grouped by categories which contain information to install the software you have selected. All these files together are mostly referred to as the pkgsrc tree. This tree is maintained by the pkgsrc developers, who make changes to it every day. Therefore it is necessary to update the pkgsrc tree regularly.


It is strongly advised to rely on information in The pkgsrc Guide This wiki is semi-official and is frequently outdated. Sometimes even misleading.

Preparing pkgsrc

Obtaining the current pkgsrc source tree

See The pkgsrc Guide


To keep the tree clean and your work directories out of it, create a directory, e.g.

# mkdir /usr/work

and define WRKOBJDIR in /etc/mk.conf:


Creating DISTDIR

We also want our distfiles to be stored, outside of the pkgsrc directory. Therefore we add the DISTDIR variable to /etc/mk.conf


and create it with:

# mkdir /usr/distfiles

Installing packages

To install packages, we need to become root.

$ su 

then we change to the directory (category) and then to the package we want to install.

# cd /usr/pkgsrc/misc/figlet

to install we enter

# make install

afterwards we clean up and enter

# make clean

if this was a package with dependencies, we also enter

# make clean-depends

You can put them all in one line too.

# make install clean clean-depends

If you wish to clean the distfiles, the files that have been downloaded, you enter

# make distclean

List Packages

$ pkg_info

Removing Packages

# pkg_delete packagename

Updating Packages

You can update a single package using make update.

# make update

On-line help

Besides The pkgsrc Guide there is also a built-in on-line help system.

# make help

gives you the usage information. This requires you to already know the name of the target or variable you want more info on (just like man does).

Most targets and variable names are documented, but not all are. See also