pkgsrc: The NetBSD Packages Collection
BSD daemon

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 3500 packages. It is used to enable freely available software to be configured and built easily on supported platforms.

Latest îews
April 11, 2002
pkg_install and bootstrap kit updated to 20030411.

April 10, 2002
bootstrap kit pax updated to -current, including GNU tar compatibility fixes and full bzip2 support.


Binary kits
Darwin 6.3/powerpc
Debian Linux/i386
FreeBSD 3.5/i386
FreeBSD 5.0/i386
IRIX.5/mips
OpenBSD 3.2/i386
Slackware 8.1/i386
Solaris 9/sparc
Solaris 9/i386

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!

pkgsrc currently has support for the following platforms:

  • Darwin (MacOS X)
  • FreeBSD
  • IRIX
  • Linux
  • OpenBSD
  • Solaris

Available packages

Documentation

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.

Binary kits and an initial set of packages are available for the following operating systems.

Table./b>

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 -

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

Installing packages

A selection of precompiled binary packages for NetBSD 1.5.x and 1.6 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 section 2.2 of the 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/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).

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

  3. Now type

    % 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=non-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.

  • USA_RESIDENT=NO

    If “NO”, this is used by some programs to determine licence authorisation. If “YES”, it is used by some programs to determine license authorization.

  • USE_RSAREF2=NO

    Whether or not to use RSAREF2, for example in security/ssh.

  • DEPENDS_TARGET=package

    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.

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 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 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. Some of the more frequently used are:

  • cpuflags

    devel/cpuflags will determine the best compiler flags to optimise code for your current CPU and compiler.

  • lintpkgsrc

    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.

  • pkgchk

    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.

  • pkg_comp

    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.

Other related reading

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.

(contact us) $NetBSD: packages.html,v 1.124 2003/04/14 22:03:11 grant Exp $
Copyright 1994-2003 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.