pkgsrc on Solaris
For many years, building and installing third-party software on Solaris has been a huge pain. For people who do not use pkgsrc, that is.
Originating from the NetBSD project, pkgsrc is a source-based cross-platform package manager. If you’ve used FreeBSD ports, then it is very similar as it derives from the same codebase, so the basic premise is that you:
and pkgsrc will download the source for Apache 2.2, compile it and all dependancies, install it on the local system and create a package which can be installed on other similar systems.
However, we’ve taken ports further and applied the NetBSD philosophy of portability, meaning that it not only works on NetBSD, but across all *BSD as well as Linux, OSX, HP/UX, AIX, IRIX, QNX, Windows (via Interix), and of course Solaris.
So while apt-get might be awesome, it only really works on Linux. FreeBSD might have way more ports than us, but only runs on FreeBSD and OSX. pkgsrc provides a consistent interface across all the platforms listed above, and in some cases provides a superior package manager than the system provides.
Here’s how I use pkgsrc on Solaris, in this specific case Solaris 10/x86. Paths are specific to my setup, you can of course change them.
Create a chroot/zone environment
I use the zones feature of Solaris 10 to ensure that all packages are built in a sandbox. This has a number of benefits:
- The running system is unaffected by the builds, in that they are not writing to the same file system. This is good when you have misbehaving packages.
- You can separate the build and install phases, so that you can verify all the packages have been built and are correct before starting any install/upgrade procedure
- It’s easier to catch package mistakes, e.g. unpackaged files.
- It avoids pollution from the host environment which may produce bad packages
For creating a zone, I wrote the following
And the corresponding
If you want to use them then there are some variables to set at the top, and
you may want to scan through them for additional bits to change, for example
create-zone copies my ssh public key
which will most likely be wrong for your setup :-)
One additional piece of configuration for
create-zone is an optional SMF xml file.
I use this file to disable inetd inside the zone for additional security, like
The file should be named <yourzonename>.xml. Mine is named
vm-generic.xml and I then create
symlinks to it for each VM I want with that default configuration.
pkgsrc is developed very rapidly. Tracking nearly 9,000 pieces of third-party
software means there are always many updates. Thankfully, we provide quarterly
branches for people who want more stability, and I recommend using the latest
quarterly release. At time of writing, this is known as
Within the next month or so we will release
pkgsrc-2009Q3, and you can figure
out the names of future releases yourself.
The easiest way to get pkgsrc is using cvs. I keep stuff like this under
/content as opposed to the default of
/usr, you can use whatever you wish
but will need to change all my example scripts to match where you put it.
Alternatively, you can fetch either bzip2 or gzip archives of the current branch. I recommend the cvs method as, with the branch being updated for security fixes and other important changes, you can easily track it using
pkgsrc is configured using a
this is mine:
This is the primary configuration file for pkgsrc. Again, you may need to tailor this to your environment, and may find it useful to read the pkgsrc guide to understand what it all means.
As I do a lot of pkgsrc development I have a number of virtual machines up and
running doing various bits and pieces. Obviously I don’t want to copy that
mk.conf around, so I also have a small
fragment file which is appended to
each virtual machine’s
mk.conf (using the
--mk-fragment argument to
bootstrap) and includes the global copy:
The bulk build setup in pkgsrc requires its own configuration, and for this you will need to edit a file inside pkgsrc. There is an example file provided, so what I usually do is symlink this to the real copy then I can easily keep it up-to-date via cvs.
Again, you can find my personal build.conf here.
Finally, there is a configuration file for
pkg_chk which is a package inside
pkgsrc which makes managing upgrades easier (ideally it should be a part of the
main pkgsrc tools but that’s for another day).
pkgchk.conf is a list of
package directories, relative to the pkgsrc top level, which are to be built
and installed for this setup. If you have a large installation then
has extra features to make it possible to share
pkgchk.conf across a number of
machines and configure packages on a per-host, per-OS etc basis.
Thus, a sample
It is highly likely you will want to change the
pkgchk.conf file from what I
Once everything is set up, I have two scripts to build then update my packages,
These are pretty simple as all the hard work has all been done.
build-packages is ran inside the
update-packages on the
main host. These scripts hardcode the name of the branch currently used, so
you will need to update this when moving to newer releases.
Ok, so here is the stuff I have for my setup and where I keep them:
|Checked out pkgsrc tree, "2009Q2" branch|
|Creates Solaris zone|
|Uninstalls and deletes zone|
|Bulk build packages inside the zone|
|Updates installed packages|
|Main pkgsrc configuration file|
|Fragment file included in each zone's |
|Shared SMF configuration file, symlinked to from e.g. "|
And these are the paths where stuff will be created:
|Source tarballs of packages|
|Resulting binary packages|
|Temporary build area for packages|
|Bulk build results directory|
It’s definitely harder than it should be to get this all setup, but the good news is that once it’s done there’s very little maintenance.
Kicking it all off
Once everything is setup:
This should do the lot. Once
build-packages has finished you
should, if you configured your email address in build.conf, get an email with
the bulk build results which looks similar to this:
A fuller report is available if you configure a web server to serve the
pkgstat directory created by the bulk build, and this can help debug problems
(again see the above URL for an example).
You will need to add
files are in
/etc/opt/pkg, and log files and metadata are kept in
This stuff should be obsolete
While this all works well for me, it’s pretty lame for users who just want to install packages and have stuff work. I’m working on providing regular updates of binary packages, including a SVR4 package of the bootstrap kit, so that in theory all a user needs to do is
I’m almost there, just needs some tidying up and regular builds. Please feel free to help out!
- 16 Jul 2015 » Reducing RAM usage in pkgin
- 03 Mar 2015 » pkgsrc-2014Q4: LTS, signed packages, and more
- 06 Oct 2014 » Building packages at scale
- 04 Dec 2013 » A node.js-powered 8-bit CPU - part four
- 03 Dec 2013 » A node.js-powered 8-bit CPU - part three
- 02 Dec 2013 » A node.js-powered 8-bit CPU - part two
- 01 Dec 2013 » A node.js-powered 8-bit CPU - part one
- 21 Nov 2013 » MDB support for Go
- 30 Jul 2013 » What's new in pkgsrc-2013Q2
- 24 Jul 2013 » Distributed chrooted pkgsrc bulk builds
- 07 Jun 2013 » pkgsrc on SmartOS - creating new packages
- 15 Apr 2013 » What's new in pkgsrc-2013Q1
- 19 Mar 2013 » Installing SVR4 packages on SmartOS
- 27 Feb 2013 » SmartOS is Not GNU/Linux
- 18 Feb 2013 » SmartOS development preview dataset
- 17 Jan 2013 » pkgsrc on SmartOS - fixing broken builds
- 15 Jan 2013 » pkgsrc on SmartOS - zone creation and basic builds
- 10 Jan 2013 » Multi-architecture package support in SmartOS
- 09 Jan 2013 » Solaris portability - cfmakeraw()
- 08 Jan 2013 » Solaris portability - flock()
- 06 Jan 2013 » pkgsrc-2012Q4 illumos packages now available
- 23 Nov 2012 » SmartOS and the global zone
- 24 Oct 2012 » Setting up Samba on SmartOS
- 10 Oct 2012 » pkgsrc-2012Q3 packages for illumos
- 23 Aug 2012 » Creating local SmartOS packages
- 10 Jul 2012 » 7,000 binary packages for OSX Lion
- 09 Jul 2012 » 9,000 packages for SmartOS and illumos
- 07 May 2012 » Goodbye Oracle, Hello Joyent!
- 13 Apr 2012 » SmartOS global zone tweaks
- 12 Apr 2012 » Automated VirtualBox SmartOS installs
- 30 Mar 2012 » iptables script for Debian / Ubuntu
- 20 Feb 2012 » New site design
- 11 Jan 2012 » Set up anonymous FTP upload on Oracle Linux
- 09 Jan 2012 » Kickstart Oracle Linux in VirtualBox
- 09 Jan 2012 » Kickstart Oracle Linux from Ubuntu
- 22 Dec 2011 » Last day at MySQL
- 15 Dec 2011 » Installing OpenBSD with softraid
- 21 Sep 2011 » Create VirtualBox VM from the command line
- 14 Sep 2011 » Creating chroots for fun and MySQL testing
- 30 Jun 2011 » Graphing memory usage during an MTR run
- 29 Jun 2011 » Fix input box keybindings in Firefox
- 24 Jun 2011 » How to lose weight
- 23 Jun 2011 » How to fix stdio buffering
- 13 Jun 2011 » Serving multiple DNS search domains in IOS DHCP
- 13 Jun 2011 » Fix Firefox URL double click behaviour
- 20 Apr 2011 » SSH via HTTP proxy in OSX
- 09 Nov 2010 » How to build MySQL releases
- 29 Apr 2010 » 'apt-get' and 5,000 packages for Solaris10/x86
- 16 Sep 2009 » ZFS and NFS vs OSX
- 12 Sep 2009 » pkgsrc on Solaris
- 09 Dec 2008 » Jumpstart from OSX
- 31 Dec 2007 » Set up local caching DNS server on OSX 10.4