pkgsrc: The NetBSD Packages Collection

About pkgsrc

The NetBSD Packages Collection (pkgsrc) is a framework for building third-party software on NetBSD and other UNIX-like systems, currently containing over 5500 packages. It is used to enable freely available software to be configured and built easily on supported platforms.

Latest stable branch: pkgsrc-2005Q4

Latest news

23 Feb 2006 - pkgsrc-users mailing list

The NetBSD Project has created a new mailing list “pkgsrc-users@NetBSD.org” to better serve the pkgsrc user community and to help refocus the existing “tech-pkg@NetBSD.org” mailing list for technical discussions. Please see Johnny C. Lam's message to the tech-pkg mailing list for details, including the charters for these lists.

06 Dec 2005 - Freeze of pkgsrc tree for pkgsrc-2005Q4

In a message to the tech-pkg mailing list Alistair G. Crooks announced that the NetBSD Packages Team will stop the development of non-essential changes for pkgsrc to prepare for the release of the next stable branch pkgsrc-2005Q4. The freeze period will begin December 12th 2005 and is expected to last about two weeks. During this period, the developers will bring down the number of open problem reports and fix problems shown by the bulk builds.

02 Dec 2005 - Changes to the Packages Collection in November 2005

The monthly summary of pkgsrc activities has been published by Alistair G. Crooks. At the end of November pkgsrc contained 5737 packages, an increase of 80 new packages from the previous month.

The “Package of the Month” award goes to emulators/gxemul, an emulator capable of running several different ports of NetBSD.

01 Nov 2005 - Changes to the Packages Collection in October 2005

Alistair G. Crooks has posted his monthly account of the changes to the Packages Collection in October 2005. By his calculations, at the end of October 2005, there were 5657 packages in the Packages Collection, up from 5558 the previous month, a rise of 99.

The Package of the Month award (jointly) goes to:

  • graphics/digikam, nominated by Simon Burge, who uses it to tag and organise photos really easily. Apparently Simon has more than 3000 photos, and with a click or two he can select really easily after they have been tagged. Simon also nominated:
  • sysutils/rsnapshot for backing up a large amount of data, a perl utility on the server, and rsync on the clients to be backed up.

Please read Alistair G. Crooks's message for details.


Pre-compiled binaries for supported platforms
Other downloads

Available packages

Documentation

Mailing Lists

The following mailing lists may be of interest to pkgsrc users:

  • pkgsrc-bugs -- a list where problem reports related to pkgsrc are sent and discussed
  • pkgsrc-bulk -- a list where the results of pkgsrc bulk builds are sent and discussed
  • pkgsrc-changes -- a list where all commit messages to pkgsrc are sent
  • tech-pkg -- a general discussion list for all things related to pkgsrc

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.
  • Package dependencies, including when performing package updates, are handled automatically. 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 new a 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.

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!

Table 1. Platforms supported by pkgsrc

Platform Date Support Added
NetBSD Aug 1997
Solaris Mar 1999
Linux Jun 1999
Darwin (Mac OS X) Oct 2001
FreeBSD Nov 2002
OpenBSD Nov 2002
IRIX Dec 2002
BSD/OS Dec 2003
AIX Dec 2003
Interix (Microsoft Windows Services for Unix) Mar 2004
DragonFlyBSD Oct 2004
OSF/1 Nov 2004

Getting started

If you are using NetBSD, you can get started with pkgsrc right away. Skip ahead to Installing packages.

Binary distribution

We provide a bootstrap kit in both source and binary form for other platforms, consisting of the pkg administration tools and other tools required to use pkgsrc and build packages.

Note

Older binary snapshots are available in the bootstrap-pkgsrc/archive directory on ftp.NetBSD.org.

Table 2. Binary kits and available packages

Platform Latest snapshot Binary kit Binary packages
Darwin 5.5/powerpc (Mac OS X 10.1.5) 20021209 binary kit  
Darwin 6.6/powerpc (Mac OS X 10.2.6) 20030623 binary kit  
Darwin 7.6/powerpc (Mac OS X 10.3.6) 20041219 binary kit binary packages
Darwin 7.8/powerpc (Mac OS X 10.3.8) 20050320 binary kit  
Darwin 8.1/powerpc (Mac OS X 10.4.1) 20050625 binary kit binary packages
Debian GNU Linux/i386 20031023 binary kit binary packages
Fedora Core 2 Linux/i386 20050618 binary kit  
Fedora Core 4 Linux/i386 20060105 binary kit  
FreeBSD 3.5/i386 20030411 binary kit  
FreeBSD 4.7/i386 20021211 binary kit  
FreeBSD 5.0/i386 20030411 binary kit  
FreeBSD 5.1/i386 20030630 binary kit  
FreeBSD 5.2.1/i386 20040227 binary kit  
FreeBSD 5.3/i386 20050119 binary kit  
Interix 3.5 20051010 binary kit binary packages
IRIX 6.5 n32-bit ABI 20040911 binary kit binary packages
IRIX 6.5 64-bit ABI 20040912 binary kit binary packages
OpenBSD 3.2/i386 20030420 binary kit  
OpenBSD 3.3/i386 20030503 binary kit  
OpenBSD 3.5/i386 20040507 binary kit  
Slackware Linux 8.1/i386 20030417 binary kit  
Slackware Linux 9/i386 20031023 binary kit  
Solaris 8/sparc 20050220 binary kit  
Solaris 8/i386 20050220 binary kit  
Solaris 9/sparc 20041208 binary kit binary packages
Solaris 9/i386 20030411 binary kit  

Simply download the binary kit for your platform, and extract it into / e.g.

# cd /
# gzip -c -d /tmp/bootstrap-pkgsrc-SunOS-5.9-sparc-20031023.tar.gz \
  | tar -xpf -

Of course, as with any binary distributions, you should verify the checksum against the SUM or CKSUM file and inspect the contents before extracting it.

Source distribution

You can download the pkgsrc tarball (updated weekly) or checkout the latest sources using AnonCVS:

# cvs checkout -P pkgsrc

(for setting up AnonCVS, see Tracking NetBSD-current).

After downloading and/or extracting the sources, installing the bootstrap kit should be as simple as:

# cd pkgsrc/bootstrap
# ./bootstrap

This will use the defaults of /usr/pkg for the prefix and /var/db/pkg for the package database directory. However, these can also be set using command-line parameters (use ./bootstrap --help to see the available options).

Note that when using pkgsrc on a non-NetBSD system, use the bmake command instead of “make” to run the NetBSD make, which is required for correct pkgsrc operation. Simply substitute “bmake” for “make” in pkgsrc documentation.

Installing packages

A selection of precompiled binary packages for NetBSD 1.6.x and 2.0.x is available from /pub/NetBSD/packages on NetBSD FTP sites.

The majority of users will find the browsable web listing most useful.

Packages can be installed either by downloading a package and its prerequisites to a local disk and running:

# pkg_add <package>

or directly by specifying the full URL as in:

# pkg_add ftp://ftp.NetBSD.org/pub/NetBSD/packages/<os_release>/<arch>/<type>/<package>

Prerequisites will be automatically retrieved and installed if they are available in the same remote directory.

Packages are installed by default into /usr/pkg. You should ensure that /usr/pkg/bin and /usr/pkg/sbin are in your PATH variable (best set in /etc/csh.cshrc).

Using pkgsrc

The NetBSD Packages Collection consists of a set of Makefiles, brief descriptions, and any patches needed to ensure easy compilation of third-party programs.

Installing pkgsrc will allow you to easily compile and install any of the software contained in the collection.

There are several methods for obtaining pkgsrc, including AnonCVS and FTP. More details can be found in the full pkgsrc documentation.

Building packages from source

After obtaining pkgsrc, the /usr/pkgsrc directory now contains a set of packages, organized into categories. You can browse the online index of packages, or run make readme from the /usr/pkgsrc directory to build local README.html files for all packages, viewable with any web browser such as www/lynx or www/mozilla.

The default prefix for installed packages is /usr/pkg. If you wish to change this, you should do so by setting LOCALBASE in /etc/mk.conf (What is /etc/mk.conf?). You should not try to use multiple different LOCALBASE definitions on the same system (inside a chroot is an exception).

  1. Installing packages is quite easy. For example, to install the editor called Joe onto your system (editors/joe is a small but powerful editor that mimics other editors such as Wordstar or Emacs), first change directory as follows:

    % cd /usr/pkgsrc/editors/joe
  2. If you use a dialup connection to gain access to the internet, connect now, so the software source can be retrieved for you.

    If you have all files that you need in /usr/pkgsrc/distfiles, you don't need to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom and add:

    DISTDIR=/cdrom/pkgsrc/distfiles

    to /etc/mk.conf.

    If a package depends on many other packages (such as meta-pkgs/kde3), the build process may alternate between periods of downloading source, and compiling. To ensure you have all the source downloaded initially you can run the command:

    % make fetch-list | sh

    which will output and run a set of shell commands to fetch the necessary files into /usr/pkgsrc/distfiles. You can also choose to download the files into /usr/pkgsrc/distfiles manually.

    You can retrieve the files from mirror servers near your network. just copy the MASTER_SITE_* definitions for your country from pkgsrc/mk/defaults/mk.conf to /etc/mk.conf.

  3. Now run

    % make

    from within the /usr/pkgsrc/editors/joe directory. The sources and any patches, plus any software that the compilation of the program requires will now be downloaded to your system.

  4. Once the software has downloaded, any patches will be applied, then it will be compiled for you. This may take some time depending on your computer, and how many other packages the software depends on and their compile time.

  5. The next stage is to actually install the newly compiled program onto your system. Do this by entering:

    % make install

    while you are still in the /usr/pkgsrc/editors/joe directory, (or the directory for whatever it is you are installing).

  6. That's it, the software should now be installed and setup for use. You can enter:

    % make clean

    to remove the compiled files in the work directory, as you shouldn't need them any more. If other packages were also added to your system (dependencies) to allow your program to compile, you can tidy these up also with the command:

    % make clean-depends

What is /etc/mk.conf?

/etc/mk.conf can be used to define certain variables for the package system. It is not present by default, but can be created when needed. Among the many values which can be set are:

  • LOCALBASE=/local

    Defines the prefix used by pkgsrc, the default is /usr/pkg. This should not be changed on a system which is already using pkgsrc.

  • ACCEPTABLE_LICENSES=no-commercial-use fee-based-commercial-use

    Inform the package system which licences are acceptable.

  • WRKOBJDIR=/usr/obj/pkg

    Extract and build the packages in /usr/obj/pkg.

  • PACKAGES=${_PKGSRCDIR}/packages/${OS_VERSION}/${MACHINE_ARCH}

    When binary packages are made, save them in an OS_VERSION and MACHINE_ARCH specific subdirectory.

  • DEPENDS_TARGET=package

    Automatically build and save binary packages on dependencies.

Also, pkgsrc/mk/defaults/mk.conf gives the defaults which are used in pkgsrc. This file can be used as a guide to set values in /etc/mk.conf - it is only necessary to set values where they differ from the defaults.

Checking for security vulnerabilities in installed packages

The NetBSD Security-Officer and Packages Groups maintain a list of known security vulnerabilities to packages which are (or have been) included in pkgsrc. The list is available from the NetBSD FTP site at ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/vulnerabilities.

Through security/audit-packages, this list can be downloaded automatically, and a security audit of all packages installed on a system can take place.

There are two components to security/audit-packages. The first component, “download-vulnerability-list”, is for downloading the list of vulnerabilities from the NetBSD FTP site. The second component, “audit-packages”, checks to see if any of your installed packages are vulnerable. If a package is vulnerable, you will see output similar to the following:

Package samba-2.0.9 has a local-root-shell vulnerability, see
http://www.samba.org/samba/whatsnew/macroexploit.html

One can set up security/audit-packages to download the vulnerabilities file daily, and include a package audit in the daily security script. Details on this are located in the MESSAGE file for security/audit-packages.

Finding if newer versions of your installed packages are in pkgsrc

Install pkgtools/pkglint and run lintpkgsrc with the “-i” argument to check if your packages are up-to-date, e.g.

% lintpkgsrc -i
...
Version mismatch: 'tcsh' 6.09.00 vs 6.10.00

You can then use make update to update the package on your system and rebuild any dependencies.

Other Commands for the NetBSD Packages Collection

Other useful command to use with the NetBSD Package Collection are shown below.

  • make deinstall

    removes an installed package from your system. The reverse to the procedure performed above. Change to the appropriate pkgsrc directory before use.

  • pkg_delete

    removes a pkg by name, regardless of your current working directory.

  • pkg_info

    shows what packages are installed on your system, as any that you add are kept track of.

pkgsrc maintenance tools

There are a number of additional tools in pkgsrc that provide additional features for maintaining a pkgsrc system. See the Utilities for package management (pkgtools) section of the pkgsrc guide for a list.

Other related reading

(contact us)   Generated from %NetBSD: packages.xml,v 1.100 2006/03/06 01:43:58 jschauma Exp %
Copyright © 1994-2006 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.
NetBSD® is a registered trademark of The NetBSD Foundation, Inc.