Home Index Changes Prefs Log in »
Packaging Project

Building the Image Packaging System, pkg(5), for Multiple Platforms


The Image Packaging System, uprinting voucher pkg(5), is an OpenSolaris project that offers a new packaging and repository system for Solaris software. From the update center/cross-platform/software infrastructure point of view, this can be used across more than just Solaris. In late 2007, an evaluation was performed to determine how portable, extensible, and feasible it is to use pkg(5) as a more generic packaging system across typical middleware platforms (e.g. Windows, Linux). Part of that assessment was attempting to port pkg(5) to non-Solaris platforms. The result of the assessment has been to adopt pkg(5) as the packaging mechanism for Update Center 2 with the expectation that it will be adopted by the Sun SWI as a whole.

This page provides instructions for how to build pkg(5) on various platforms.


Right now, the only platforms this is known to work on are:

  • Solaris 10U4 or 11 (Nevada) Build 67 or later
  • Ubuntu Linux 7.04 (Feisty Fawn) or later
  • Red Hat Enterprise Linux 4 or later
  • Windows XP/SP2
  • Mac OS X
  • AIX

It will probably work on any platform that supports Python 2.6.

Binary Distributions

To quickly try out the pkg(5) binaries for various platforms, see the Update Center Try It page. After completing step 3, you will have a working binary pkg(5) installation on your system.

Getting the Source


  • Mercurial. Obtain the latest version (recent OpenSolaris or Solaris Nevada distros have it). Mercurial is also used during the build.

Cloning using Mercurial

$ hg clone ssh://anon@hg.opensolaris.org/hg/pkg/gate ips
requesting all changes
adding changesets
adding manifests
adding file changes
added 128 changesets with 2509 changes to 1896 files
1853 files updated, 0 files merged, 0 files removed, 0 files unresolved

This will result in the IPS source code being copied to the ips directory.

Building the Source


PlatformRequirements above what is shipped in distro
Solarisput /usr/sfw/bin in your $PATH, make sure you are using Python 2.6
OpenSSL (do pkg-get openssl)
setuputils 0.6c9
tidy (install using python -m easy_install pyXML)
libcurl (download source, run configure, and make install)
pyXML 0.8.4 (install using python -m easy_install pyXML)
simplejson (install using python -m easy_install simplejson)
libcurl (download source, run configure, and make install)
Make sure to run unit test cases with python2.6
RHEL 4Development Tools (use Applications-System Settings-Add/Remove Applications)
Mercurial (use CentOS 0.9.4 RPM)
Python 2.6 (build from source, use --enable-unicode=ucs4 to ./configure)
elfutils-libelf-devel 0.97 (obtain from Red Hat Network)
setuptools 0.6c9
OpenSSL 0.9.8i (build from source, use -shared option to ./config, remove the libssl.a and libcrypto.a files to make SELinux work correctly)
tidy (checkout from CVS, cd build/gmake, make and make install)
pyXML 0.8.4 (install using python -m easy_install pyXML)
simplejson (install using python -m easy_install simplejson)
libcurl (download source, run configure, and make install)
WindowsPython 2.6 installed to C:\Python26, create python2.6 and python2.6.exe copies of python.exe in C:\Python26
setuputils 0.6c9
patch 2.5.9 (if it doesn't come with Mercurial)
Microsoft Visual C++ 2008 Express
Win 32 OpenSSL v0.9.8i installed to C:\OpenSSL
pyXML 0.8.4 (install using python -m easy_install pyXML)
simplejson (install using python -m easy_install simplejson)
Mac OS Xpython 2.6
pyXML 0.8.4 (install using python -m easy_install pyXML)
simplejson (install using python -m easy_install simplejson)
AIXPython 2.6 (get full build from UC2 project, this includes OpenSSL)
setuputils 0.6c9 (with python in PATH, install with sh setuptools*.egg, use --prefix arg)
pyXML 0.8.4 (install using python -m easy_install pyXML)
simplejson (install using python -m easy_install simplejson)
patch 2.5.9
libcurl (get build from UC2 project)

Building on Solaris, Linux, Mac OS X, AIX

export CPPFLAGS="-Ipath-to-OpenSSL-include -Ipath-to-libcurl-include"
CPPFLAGS="$CPPFLAGS -qlanglvl=extc99"  (AIX only)
export LDFLAGS="-L/path-to-OpenSSL-lib -Lpath-to-libcurl-lib"
LDFLAGS="$LDFLAGS -bnolibpath" (AIX only)
cd ips/src
python setup.py install

Building on Windows

These instructions assume the components are installed to the folders listed in the requirements table. If you install them elsewhere, then change the instructions appropriately.

Before building on Windows some build component modifications are required.

In a command prompt:

cd ips\src
set CURL_DIR=C:\path to where CURL is installed
set OPENSSL=C:\path to where OpenSSL is installed
set PYTHONHOME=C:\Python24
set CL=-I%OPENSSL%\include
set PATH=%PATH%;C:\Mercurial;%OPENSSL%;%OPENSSL%\bin;%CURL_DIR%\bin
setup.py install
setup.py test

Using the Resulting Binaries

Once the workspace is built, you can run the unit test cases using the following command:

On Solaris, Linux, Mac OS X:

sudo python setup.py test

For RHEL 4, the "nobody" user must be configured for "su" access to run the tests successfully. This can be done by changing the login shell for "nobody" to /bin/bash. Also, set PYTHON_EGG_CACHE=/tmp and export it before running the tests.

On Windows:

setup.py test

To use the binaries, set your PATH to include the directories containing the binaries: ips/proto/root_platform/usr/bin where platform is one of:

  • i386 for Solaris/x86
  • sparc for Solaris/sparc
  • linux_i386 for Linux
  • windows for Windows
  • darwin for Mac OS X

Also, set the PYTHONPATH environment variable to the ips/proto/root_platform/usr/lib/python2.6/vendor-packages directory.

Once you set these two environment variables, you can use the pkg command to create new images and install software from a repository. The pkgsend command will also be in your PATH.

To access the server executable, pkg.depotd, you need reference the ips/proto/root_platform/usr/lib directory.

Starting the Server

The first step is to start the server:

$ pkg.depotd -d /tmp/myrepo -p 10000 --set-property publisher.prefix=localhost

This starts the server, and sets it to use the (presumably writeable) /tmp/myrepo directory to store its database. The server listens on port 10000 (you can visit this port using HTTP and see a summary report in HTML).

You should leave this process running (it is a tiny HTTP server).

Using the Client

First, ensure that basic client functionality works by issuing the following commands:

Solaris/Linux/Mac OS X

eval `pkgsend -s http://localhost:10000/ open library/libc@0.1-1`

pkgsend close

This creates a simple package with no dependencies and no contents. You should see a few lines of output from the server:

localhost - - [27/Aug/2007 14:15:19] "GET /open/library%2Flibc%400.1-1 HTTP/1.1" 200 -
localhost - - [27/Aug/2007 14:15:28] "GET /close/1188238519_pkg%3A%2Flibrary%2Flibc%400.1%2C5.11-1%3A20070827T141519Z HTTP/1.1" 200 -

You can visit http://localhost:10000 to ensure the package was correctly saved.


The basic commands are the same for Windows, but eval doesn't work. So you need to use a different method to set the environment variable that is returned by pkgsend:

call pkgsend.bat -s http://localhost:10000/ open -n "foo@1.0,5.11-0" >trans.txt
set /P PKG_TRANS_ID= < trans.txt

From here on, the pkgsend commands are the same as on Solaris.

« Home Attachments Info Index Changes
This page (revision-57) was last changed on 07-Jan-10 12:43 PM, -0800 by TomMueller