Table of Contents
There is a lot of software freely available for Unix-based systems, which is usually available in form of the source code. Before such software can be used, it needs to be configured to the local system, compiled and installed, and this is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has some basic commands to handle binary packages, so that not every user has to build the packages for himself, which is a time-costly task.
pkgsrc currently contains several thousand packages, including:
… just to name a few.
pkgsrc has built-in support for handling varying dependencies, such as pthreads and X11, and extended features such as IPv6 support on a range of platforms.
pkgsrc provides the following key features:
Easy building of software from source as well as the creation and installation of binary packages. The source and latest patches are retrieved from a master or mirror download site, checksum verified, then built on your system. Support for binary-only distributions is available for both native platforms and NetBSD emulated platforms.
All packages are installed in a consistent directory tree, including binaries, libraries, man pages and other documentation.
Tracking of package dependencies automatically, including when performing updates, to ensure required packages are installed. The configuration files of various packages are handled automatically during updates, so local changes are preserved.
Like NetBSD, pkgsrc is designed with portability in mind and consists of highly portable code. This allows the greatest speed of development when porting to a new platform. This portability also ensures that pkgsrc is consistent across all platforms.
The installation prefix, acceptable software licenses, international encryption requirements and build-time options for a large number of packages are all set in a simple, central configuration file.
The entire source (not including the distribution files) is freely available under a BSD license, so you may extend and adapt pkgsrc to your needs. Support for local packages and patches is available right out of the box, so you can configure it specifically for your environment.
The following principles are basic to pkgsrc:
“It should only work if it's right.”
— That means, if a package contains bugs, it's better to find
them and to complain about them rather than to just install the package
and hope that it works. There are numerous checks in pkgsrc that try to
find such bugs: Static analysis tools (
pkgtools/pkglint), build-time checks (portability
of shell scripts), and post-installation checks (installed files,
references to shared libraries, script interpreters).
“If it works, it should work everywhere” — Like NetBSD has been ported to many hardware architectures, pkgsrc has been ported to many operating systems. Care is taken that packages behave the same on all platforms.
pkgsrc consists of both a source distribution and a binary distribution for these operating systems. After retrieving the required source or binaries, you can be up and running with pkgsrc in just minutes!
pkgsrc was derived from FreeBSD's ports system, and initially developed for NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following platforms:
Table 1.1. Platforms supported by pkgsrc
|Platform||Date Support Added||Notes|
|Darwin (Mac OS X)||Oct 2001||README.MacOSX|
|IRIX||Dec 2002||README.IRIX README.IRIX5.3|
|Interix (Microsoft Windows Services for Unix)||Mar 2004||README.Interix|
This document is divided into three parts. The first, The pkgsrc user's guide, describes how one can use one of the packages in the Package Collection, either by installing a precompiled binary package, or by building one's own copy using the NetBSD package system. The second part, The pkgsrc developer's guide, explains how to prepare a package so it can be easily built by other NetBSD users without knowing about the package's building details. The third part, The pkgsrc infrastructure internals is intended for those who want to understand how pkgsrc is implemented.
There has been a lot of talk about “ports”, “packages”, etc. so far. Here is a description of all the terminology used within this document.
A set of files and building instructions
that describe what's necessary
to build a certain piece of software using
pkgsrc. Packages are traditionally stored under
This is the former name of “pkgsrc”. It is part of the NetBSD operating system and can be bootstrapped to run on non-NetBSD operating systems as well. It handles building (compiling), installing, and removing of packages.
This term describes the file or files that are
provided by the author of the piece of software to
distribute his work. All the changes necessary to build on
NetBSD are reflected in the corresponding package. Usually
the distfile is in the form of a compressed tar-archive,
but other types are possible, too. Distfiles are usually
This is the term used by FreeBSD and OpenBSD people for what we call a package. In NetBSD terminology, “port” refers to a different architecture.
A set of binaries built with pkgsrc from a distfile
and stuffed together in a single
file so it can be installed on machines of the same
machine architecture without the need to
recompile. Packages are usually generated in
/usr/pkgsrc/packages; there is also
an archive on ftp.NetBSD.org.
Sometimes, this is referred to by the term “package” too, especially in the context of precompiled packages.
The piece of software to be installed which will be constructed from all the files in the distfile by the actions defined in the corresponding package.
The pkgsrc users are people who use the packages provided by pkgsrc. Typically they are system administrators. The people using the software that is inside the packages (maybe called “end users”) are not covered by the pkgsrc guide.
There are two kinds of pkgsrc users: Some only want to install pre-built binary packages. Others build the pkgsrc packages from source, either for installing them directly or for building binary packages themselves. For pkgsrc users Part I, “The pkgsrc user's guide” should provide all necessary documentation.
A package maintainer creates packages as described in Part II, “The pkgsrc developer's guide”.
These people are involved in all those files
that live in the
mk/ directory and below.
Only these people should need to read through Part III, “The pkgsrc infrastructure internals”, though others might be curious,