pkgsrc: The NetBSD Packages Collection
The NetBSD Packages Collection (pkgsrc) is a framework for building third-party software on NetBSD and other UNIX-like systems, currently containing over 3500 packages. It is used to enable freely available software to be configured and built easily on supported platforms.
pkgsrc provides the following key features:
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 currently has support for the following platforms:
If you are using NetBSD, you can get started with pkgsrc right away. Skip ahead to Installing packages.
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.
Binary kits and an initial set of packages are available for the following operating systems.
|Platform||Latest snapshot||Binary kit||Binary packages|
|Darwin 5.5/powerpc (MacOS X 10.1.5)||20021209||binary kit||/td>|
|Darwin 6.2/powerpc (MacOS X 10.2.2)||20021219||binary kit||binary packages|
|Darwin 6.3/powerpc (MacOS X 10.2.3)||20030412||binary kit||/td>|
|Debian GNU Linux/i386||20030410||binary kit||binary packages|
|FreeBSD 3.5/i386||20030411||binary kit||/td>|
|FreeBSD 4.7/i386||20021211||binary kit||binary packages|
|FreeBSD 5.0/i386||20030411||binary kit||/td>|
|IRIX 6.5 n32-bit ABI||20030410||binary kit||binary packages|
|IRIX 6.5 64-bit ABI||20030225||binary kit||binary packages|
|OpenBSD 3.2/i386||20030411||binary kit||/td>|
|Slackware Linux 8.1/i386||20030411||binary kit||/td>|
|Solaris 8/sparc||20021219||binary kit||/td>|
|Solaris 8/i386||20030330||binary kit||/td>|
|Solaris 9/sparc||20030411||binary kit||binary packages|
|Solaris 9/i386||20030411||binary kit||/td>|
Simply download the binary kit for your platform, and extract it into / e.g.
# gzip -c -d bootstrap-pkgsrc-SunOS-5.9-sparc-20030411.tar.gz \ | tar -C / -xpf -
You can download the bootstrap-pkgsrc tarball or checkout the latest sources using AnonCVS:
# cvs checkout -P othersrc/bootstrap-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 othersrc/bootstrap-pkgsrc # ./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.
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).
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.
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/phoenix.
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).
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
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 to /cdrom and add DISTDIR=/cdrom/pkgsrc/distfiles to /etc/mk.conf, or just type “make DISTDIR=/cdrom/pkgsrc/distfiles”.
If a package depends on many other packages (such as x11/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 to /etc/mk.conf.
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.
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.
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).
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
/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:
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=non-commercial-use fee-based-commercial-use
Inform the package system which licences are acceptable.
Extract and build the packages in /usr/obj/pkg.
When binary packages are made, save them in an OS_VERSION and MACHINE_ARCH specific subdirectory.
If “NO”, this is used by some programs to determine licence authorisation. If “YES”, it is used by some programs to determine license authorization.
Whether or not to use RSAREF2, for example in security/ssh.
Automatically build and save binary packages on dependencies
Also, /usr/pkgsrc/mk/bsd.pkg.defaults.mk 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.
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.
Install and run pkgtools/pkglint with the “-i” argument to check if your packages are up-to-date, e.g.
% pkglint -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 useful command to use with the NetBSD Package Collection are shown below.
removes an installed package from your system. The reverse to the procedure performed above. Change to the appropriate pkgsrc directory before use.
removes a pkg by name, regardless of your current working directory.
shows what packages are installed on your system, as any that you add are kept track of.
There are a number of additional tools in pkgsrc that provide additional features for maintaining a pkgsrc system. Some of the more frequently used are:
devel/cpuflags will determine the best compiler flags to optimise code for your current CPU and compiler.
part of pkgtools/pkglint, lintpkgsrc allows you to check installed packages against the versions in your local pkgsrc tree, plus delete old binary packages and obsolete distfiles.
pkgtools/pkg_chk checks installed packages against the versions in your local pkgsrc tree and/or a config file which can list desired packages by hostname, architecture and various other parameters.
pkgtools/pkg_comp allows you to compile packages inside a chroot jail. This is useful, for example, to build packages for other versions of NetBSD than the installed one, or for debugging purposes.
More detailed information about the NetBSD Packages Collection is available in the Packages.txt file contained within pkgsrc.
Many thanks to Simon Rowe's NetBSD pages.
$NetBSD: packages.html,v 1.124 2003/04/14 22:03:11 grant Exp $
Copyright 1994-2003 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.