Installing SVR4 packages on SmartOS
Up until and including Solaris 10 the default packaging tools on Solaris were
the historical SVR4
pkg* commands. First written in the early 1980s they
were standard across commercial Unix systems and provided a simplistic
interface to installing and removing binary packages.
With the introduction of IPS in OpenSolaris and beyond they have been mostly
consigned to history, however there is still software provided for Solaris
which is only available in the
.pkg format, and thus it is useful to still
be able to handle them.
pkg* tools continue to be maintained in illumos and are provided
by various distributions, they are not all provided in SmartOS. There are a
few reasons for this:
SmartOS has a different design to other illumos distributions, and some key differences such as a read-only /usr mean that some packages will simply break in unexpected ways.
SmartOS is designed to be a slimmed-down distribution providing only that which is necessary for the majority of our users and use cases. Including the SVR4 tools and metadata would bloat the system.
SVR4 packages are often available only for older versions of Solaris, and whilst the excellent ABI compatability in Solaris means that the binaries themselves will often function correctly, the package may not support newer features such as SMF, or again make assumptions about the system which could result in irrevocable damage.
SmartOS uses pkgsrc to manage third-party software, and we believe it is better to convert SVR4 packages to pkgsrc format so that all packages on the system can be managed with a single toolset.
However, we do continue to ship the
pkgtrans utility with SmartOS, and this
is our gateway into converting SVR4 packages into more useful formats. The
rest of this post will explore how we can do that.
Unpacking SVR4 packages
Let’s start with an example SVR4 package and unpack it to see what it contains. I’m going to use Riak, a popular open source database as the example package.
SVR4 packages can contain multiple sub-packages, and so the ‘all’ is necessary to unpack everything in the archive. If we didn’t specify ‘all’, we would have seen:
So whilst we could have specified ‘riak’, we can always use ‘all’ to avoid having to first look at the package to see what sub-packages it contains.
We now have an unpacked package, let’s go through what it contains.
install/ directory contains some files and scripts:
copyrightis self-explanatory, and is normally displayed when using the
pkgaddcommand to let the admin know what they are agreeing to.
dependis a list of other SVR4 packages that this one depends upon. In this case they are:
As this package is originally from Solaris 10 there is a chance that
dependencies could cause issues. For example, in SmartOS we have updated
OpenSSL to 1.0.x. Additionally, if a third-party dependency was required
(i.e. one not beginning with
SUNW) then naturally you would need to
recursively apply this entire procedure to each dependency.
r.preserveare scripts executed during install (
i.) and removal (
r.). The ones for Riak simply try to retain modified files from an existing install, so we will ignore these as pkgsrc handles that by default.
preinstallis, as the name suggests, a script which is executed prior to installing the package. In Riak’s case it is used to create the ‘riak’ user and group if they do not already exist.
This provides some basic metadata about the package. The main bits we care about are:
ARCH=i386. As long as the package only depends upon libraries provided by the base OS (
SUNW*) then it shouldn’t matter whether
ARCHis 32-bit or 64-bit. However, if it requires third-party dependencies then you need to ensure that the correct ABI is provided.
BASEDIR=/opt. This is where the package would be installed by the
DESC=.... This would be output by the legacy
pkginfocommand, and we will re-use this text for our
This is somewhat equivalent to the pkgsrc
PLIST file and is a record of all
the files the package provides, however it also includes file permissions and
a basic checksum:
The last two lines, the important fields are:
iis an SVR4 metadata file,
ddenote whether it is a file or a directory,
eare configuration files.
nonemeans no special handling,
preservedoes just that, and the next field is the full path relative to
0755are the file/directory permissions
riak riakare the user and group ownership
We will need to ensure at least the file entries are handled correctly.
This directory contains the binaries etc. which make up the actual package.
The contents of this directory would normally be installed under
pkginfo file, so in Riak’s case:
This concludes the examination of the SVR4 package. Let’s turn it into a useful pkgsrc package.
Creating pkgsrc binary package
For more information on creating binary pkgsrc packages from scratch, see this post.
Create the necessary pkgsrc metadata files.
pkgsrc INSTALL script
To handle the Riak preinstall script, we will create a pkgsrc
The existing script can be mostly used as-is, we just need to put the entire
preinstall inside a
PRE-INSTALL case statement so that it is
executed prior to installing the package:
If we recall from the
pkgmap file, the entries there contained a user/group
that each file should be owned by, and we can handle that in the
script too with a
First we simply copy everything from the
reloc/ directory to a
directory we will use for pkgsrc:
Next we can use the
pkgmap file to ensure that the file modes are set
correctly with a quick and dirty script:
Create the package
We should now have everything necessary to create a binary package, taking the
version from the
If all went well then we should be able to install the package:
and we will find it under
/opt/local/riak as expected. If we try to run the
binary, we get:
This nicely proves my earlier point about packages often not working unmodified
on SmartOS, in this case because
whoami is no longer provided. Thankfully
this is an easy fix, and we can simply change
Making that change and trying again, but this time as the riak user:
This seems to work about as well as one can hope, and concludes my basic example.
I’ve covered the basics here, but there are additional things you could do to tidy up the conversion:
whoamifix back into the source file and re-generate the package.
Turn this into a real pkgsrc package, which would simplify some areas such as metadata and user creation.
Come up with a script to automate a lot of this work.
riakscript into an SMF service.
Also note that Basho very helpfully already provide a native SmartOS package on their download page, so this example is somewhat pointless, however I hope it has still proven useful ;)
- 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