Creating local SmartOS packages
Ok, so you have a SmartOS machine set up, and are using
pkgin
to install packages. Now you may want to also handle your local
software using the same tools, so that you can take advantage of easily
installing and upgrading packages. This post describes how you can do this.
We will be creating a hypothetical package meminfo
, containing a script of
the same name which prints basic memory information, and just enough metadata
for it to be understood by the packaging tools. This guide assumes you are
running a standard dataset which includes packaging tools in /opt/local/sbin
,
that is:
should give you a list of currently installed packages.
Files to install
First, let’s start in a clean directory, and then create a files
sub-directory which will hold the files we want to package. The files in this
directory will be installed relative to the packaging prefix, which for most
SmartOS installs will be /opt/local
.
Now we create the meminfo
script. You will probably just copy your binaries
into place at this stage.
Ensure the script is executable!
Finally for this part, generate a packlist
file which simply contains a list
of files we want packaged, relative to the files
directory:
The packlist
file supports many directives which are lines beginning with
@<cmd>
. These let you do things such as change file permissions once the
file has been installed. See the ‘PACKING LIST DETAILS’ section of
pkg_create(1)
for more
information.
Package metadata
In order to successfully create a package, we need a few metadata files which describe the package.
build-info
This file contains basic information about the package, and is primarily used to ensure that the package can be installed on the target machine. The minimum information required is:
MACHINE_ARCH
. On SmartOS this is eitheri386
orx86_64
depending upon whether you chose abase/smartos
orbase64/smartos64
dataset. Attempting to install a package intended for one architecture with package tools built for a different architecture will work due to SmartOS being able to run both 32-bit and 64-bit applications, but you will get warnings when installing.OPSYS
. On SmartOS this isSunOS
, i.e. the output ofuname -s
.OS_VERSION
. On SmartOS this is5.11
, i.e. the output ofuname -r
.PKGTOOLS_VERSION
. An integer describing the version of thepkg_install
tools required to understand this package. At the current time pkgsrc sets a base version of20091115
so just use this.
The easiest way to generate this file is simply to get it from an existing package, for example:
comment
This is a short string describing the package which is shown in the default
pkg_info
or pkgin list
output. Keep this short, preferably under 60
characters, so that it displays correctly in 80-column terminals.
description
This is a longer multi-line description of the package which is output by
pkg_info <package name>
or pkgin pkg-descr <package name>
. Format this to
80-columns.
So we should now have:
Create the package
We now have enough information to create a basic package. The magic invocation to perform the operation is:
The -B
, -c
, -d
and -f
arguments simply pull in the metadata files we’ve
written.
The -I
argument specifies the destination prefix. As we are creating a
package outside of this prefix we need to tell pkg_create
of the ultimate
destination.
The -p
argument is used in conjunction with -I
to tell pkg_create where our
files to be packaged can be found.
The -U
argument means we should just create the package, and not register it.
And finally, we provide the package file. The packaging tools understand version numbers, so we can just provide the file name and it will determine the package name and version from that.
To verify the package, you can run:
Installing
For a single machine, you can now simply install the package with:
If you want to publish the package so that it is available to pkgin
you need
to create a pkg_summary
file and put it alongside the package for download.
This file is usually compressed to speed things up, and pkgin
supports both
.gz
and .bz2
.
For example purposes I will simply use file://, but of course you can use http:// instead if you put the packages and pkg_summary file somewhere accessible:
Add this repository to pkgin
and reload:
Now the package should show up:
and be installable:
This covers the basics and should be enough to get started. As mentioned,
there are many other options available, and I suggest that if you need
additional functionality you take a look at the
pkg_create
manual page, or
simply use pkg_info -X
on more complicated packages to see what they do.
All Posts
- 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