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.
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:
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
To install packages, we need to become root.
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
# pkg_delete packagename
You can update a single package using make update.
# make update
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