pkgsrc is a framework for building over 17,000 open source software packages. It is the native package manager on SmartOS, NetBSD, and Minix, and is portable across 23 different operating systems. Use one package manager across all of your systems!
Joyent provide binary packages for SmartOS/illumos, Mac OS X, and Linux.
Our goal at Joyent is that our binary packages fulfill all of our users' needs. This isn't always possible, however - users may want packages we do not yet provide, or build with different options.
To satisfy those demands, it should instead be reasonably straight-forward for users to build their own packages, and this guide hopefully provides all the information for them to do just that.
As with other guides, this one refers to SmartOS/illumos packages which are
built with a prefix of
/opt/local, but this guide is generally applicable to
the OS X packages too - you just need to change prefix references to
On SmartOS/illumos the first thing you'll need are build tools, so:
OS X comes with git, but you can install a newer version from pkgsrc if you wish.
We maintain a fork of pkgsrc on github, which includes some additional SmartOS fixes and improvements, so we recommend using that rather than upstream.
This guide puts everything under
/content, adjust to your own tastes.
Next, check out the latest stable branch. Our naming scheme is
joyent/release/YYYYQQ, and the latest branch at time of writing is
If you want to be particularly adventurous, you could checkout
joyent/release/trunk and get the very latest pkgsrc code, however pkgsrc is a
very fast-moving target and you may run into unexpected breakages, and you will
certainly end up rebuilding packages very often.
pkgsrc-wip is a set of additional
work-in-progress packages for pkgsrc, and can be useful for trying out the
latest packages. It is designed to be extracted directly into pkgsrc, and
we maintain a git submodule of it in our release trees, so all you need to
do, assuming you are using a
joyent/release/* tree, is:
This will also get you a
joyent/ directory which is a module of our
pkgsrc-joyent tree of additional
If you are on
trunk or another tree which does not have the
you can fetch it manually with:
The primary method of configuring pkgsrc is through the
/opt/local/etc/mk.conf file. The base image comes with one populated to
handle the basic layout, but there are some additional basic variables you may
want to set prior to building your first package:
DISTDIR determines where source tarballs are stored, default
PACKAGES is where pkgsrc will store binary packages it has built,
WRKOBJDIR is where pkgsrc performs the builds, default
SKIP_LICENSE_CHECK should both be
yes if you just want the package to be built, and don't care whether
it is currently vulnerable to security issues or is released under a specific
MAKE_JOBS determines the argument to
make -j, i.e. the number of
concurrent make threads, default 1.
FETCH_USING sets the default program to use for fetching source code,
defaulting to an in-tree version of NetBSD's ftp program. Setting this to
curl on SmartOS, which is included in the base platform, will avoid any
BINPKG_SITES is a URL pointing to binary packages which can be used by
this tree rather than building everything from source, and settings
bin-install enables using these binary packages as
Here is an example
Make sure you do not delete anything which already exists in
mk.conf, it is
important configuration data required by pkgsrc.
Ok, let's get started and build a package. pkgsrc is organised into
categories, with all packages following the
layout, and everything is driven with
bmake, the BSD implementation of
make(1). We will choose
nmap as an example, as it will show a couple
of things that need to be covered.
First, finding it. Often the easiest way is with a simple glob:
If you want a more featured search, you can do:
though the first time you run this it creates the
INDEX file it requires, and
that can take a long time. Another option is to use the
pkgsrc.se web interface.
Once you have found the package,
cd into the package directory.
Next, let's look at any options the package supports.
If the package supports build options, as
net/nmap does, you'll see
The place to configure these options is again in
if you want to enable ndiff support for example, then you'd add this to
show-options command should now print:
And finally, we can go ahead and build the package. The output from this will
be long, so you may want to
tee it to a file for reviewing:
Assuming this completes ok, you should note the main stages that make up a package build:
bootstrap-dependscomes first, and installs all the dependencies required for pkgsrc to get started.
pkgtools/digestis required to calculate the
RMD160checksums of the source tarball. If we hadn't specified
mk.confthen it's likely that
net/tnftpwould have been pulled in during this stage too and used to fetch the source.
checksumthen run to download the source tarball for this particular package, and then verify the checksum matches that stored by pkgsrc, to ensure it was downloaded from a good source:
dependsthen installs all packages required for both build and runtime for the package in question:
patchthen unpack the source and apply any pkgsrc patches to the package. The patches are located in the
patches/sub-directory for each package:
buildwhich for most software will consist of
./configure && make.
packagedoes a fake install of the package to a temporary install directory and creates a binary package from that, and then
installinstalls that binary package into place:
You can now verify it is installed, and start using your new software:
Once everything is working, you may want to clean up the build areas. The pkgsrc way of doing this is:
However, if you just want to blow everything away without prejudice, you can
simply remove everything under
WRKOBJDIR, so in my case:
This should hopefully be enough to get you started.