Chapter 1. What is pkgsrc?

Table of Contents

1.1. Introduction
1.1.1. Why pkgsrc?
1.1.2. Supported platforms
1.2. Overview
1.3. Terminology
1.3.1. Roles involved in pkgsrc
1.4. Typography

1.1. Introduction

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.

1.1.1. Why pkgsrc?

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.

1.1.2. Supported 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
NetBSD Aug 1997  
Solaris Mar 1999 README.Solaris
Linux Jun 1999 README.Linux
Darwin / Mac OS X / OS X / macOS Oct 2001 README.macOS
FreeBSD Nov 2002 README.FreeBSD
OpenBSD Nov 2002 README.OpenBSD
IRIX Dec 2002 README.IRIX
BSD/OS Dec 2003  
AIX Dec 2003 README.AIX
Interix (Microsoft Windows Services for Unix) Mar 2004 README.Interix
DragonFlyBSD Oct 2004  
OSF/1 Nov 2004 README.OSF1
HP-UX Apr 2007 README.HPUX
Haiku Sep 2010 README.Haiku
MirBSD Jan 2011  
Minix3 Nov 2011 README.Minix3
Cygwin Mar 2013 README.Cygwin
GNU/kFreeBSD Jul 2013 README.GNUkFreeBSD
Bitrig Jun 2014 Removed from pkgsrc Sep 2022

1.2. Overview

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.

This document is available in various formats: HTML, PDF, PS, TXT.

1.3. Terminology

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.

Package

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 /usr/pkgsrc, but may be stored in any location, referred to as PKGSRCDIR.

The NetBSD package system

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.

Distfile

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 stored below /usr/pkgsrc/distfiles.

Port

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.

Precompiled/binary package

A set of binaries built with pkgsrc from a distfile and stuffed together in a single .tgz 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.

Program

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.

1.3.1. Roles involved in pkgsrc

pkgsrc users

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.

package maintainers

A package maintainer creates packages as described in Part II, “The pkgsrc developer's guide”.

infrastructure developers

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, too.

1.4. Typography

When giving examples for commands, shell prompts are used to show if the command should/can be issued as root, or if normal user privileges are sufficient. We use a # for root's shell prompt, a % for users' shell prompt, assuming they use the C-shell or tcsh and a $ for Bourne shell and derivatives.