Document ID: 0001
Topic: Installation, Package Management
Created: 2003-10-20
Last Updated: 2007-02-11
Author: Stefan Parvu
References: Solaris Packages
OS: Solaris Express. Applicable to Solaris 8, 9, 10

Managing Solaris Packages

Solaris OE has a package management solution to install and delete software. A set of tools is provided to keep the system up to date: pkginfo, pkgrm ,pkgadd, pkgask, pkgchk, pkgtrans and pkgmk. There are couple of blueprints available under Sun's pages, like: http://www.sun.com/blueprints/0100/soe.pdf, http://www.sun.com/blueprints/1299/repairing.pdf where there are lot of tips and guidelines about: Recovery techniques, Repairing file ownership and Mode using package management tools. I will provide a simple guide how you can create a Solaris package. Let's think you want to compile and create a Solaris package for an open source project what you like. First check out www.sunfreeware.com and if you can't find your package in there keep reading ! What you have to do first ? How are you gonna create the package from a collection of object, binary and configuration files? How can you remove and install again that software ? This guide has the basic answers to these questions.

I usually keep my source of all Solaris packages under my home directory in a specific directory structure format. This helps me a lot during the creation phase of the package. So, you need first to have a place where you could add, compile and install the software. After that you have to create a Solaris package from that software structure. Let's see how can you do it step by step. For this example let's say you want to create a Solaris package for netpbm library available at http://sourceforge.net/projects/netpbm

  1. Create a directory to host all packages what are you planning to build. Choose whatever suits you: your home directory or a different directory

    /export/home/user/pkgs

    then under this directory create a package directory for each software you plan to create a package
    /export/home/user/pkgs/netpbm10

    Now it is time to create three more subdirectories under package's directory:
    /export/home/user/pkgs/netpbm10/source keeps your source code for the package
    /export/home/user/pkgs/netpbm10/control for all package configuration files
    /export/home/user/pkgs/netpbm10/netpbm the final place where the software will install before to create the final package

  2. Download the open source package under source directory. For instance download the source code from: http://sourceforge.net/projects/netpbm

  3. Configure and compile the software under source directory. It is important when you configure the software, using ./configure script or similar, to make sure your installation directory will be the directory created at step 1, /export/home/user/pkgs/netpbm10/netpbm - In this way the software will install under your source tree instead of /usr/local or /opt slices

    For the netpbm package you should use configure script. Please read under doc directory the INSTALL file. For instance you will notice the difference between GNU's auto configure script and this one:

    The 'configure' program is not GNU Autoconf - it is a simple program specific to Netpbm that prompts you for information about your system. If your system is not typical, you'll have to do a little more work, as described below under "custom installation."

    Use gmake instead of make. The maintainer of the software is: Bryan Henderson: bryanh@giraffe-data.com and has good tips under INSTALL about this.

    You can just simple run:

    $ ./configure
    $ gmake all
    $ gmake package pkgdir=/export/home/user/pkgs/netpbm10/netpbm

  4. Everything now it is installed under netpbm directory. Next step: configuring the pkginfo and protoytpe files -

    Change the directory to control directory, /export/home/user/pkgs/netpbm10/control. Create a file called pkginfo. Add all details about your package to this file.

    A standard pkginfo file has a format like:

    PKG=''netpbm''
    NAME=''Netpbm Toolkit''
    ARCH=''sparc''
    VERSION=''10.8''
    CATEGORY=''application''
    DESC=''Netpbm is a toolkit for manipulation of graphic images - http://netpbm.sourceforge.net/doc''
    PSTAMP=''September 14, 2002''
    EMAIL=''stefan@extum.com''
    CLASSES=''none''
    BASEDIR=''/opt''
    where all these variables are defined in the next table:

    Name Description
    PKG Defines the package's name, abbreviation. It should be alphanumeric, no number as first character
    NAME Full name of the package. Provide a clear, concise and complete information about your package
    ARCH Describes what sort of architecture is associated with the package. Maxim 16 alphanumeric characters
    VERSION The version of the package. 256 max ASCII characters. Can not begin with left parenthesis
    CATEGORY Used to describe what it is the category of that package. Possible values: system or applications
    DESC Text that describes the package. Use a real description about this package
    PSTAMP The time/date when the package was released
    EMAIL The email address of the author of the package
    BASEDIR Defines where the software package will install, under what slice the package will go
       
       

  5. Change the owner of the final package installation to something which you want. I usually keep them as root:root -

    $ cd /export/home/user/pkgs/netpbm10
    # chown -R root:root netpbm/

  6. Prototype file - In order to create the Solaris package you have to say somewhere what are the files you want to pack, what are the permissions etc ... For this reason you have to create the prototype file

    Change your directory to the main package, netpbm10 and become root. As root just create the prototype file.

    $ cd /export/home/user/pkgs/netpbm10
    # pkgproto ./netpbm > control/prototype

    This will create a prototype file owned by root. The prototype file contains all your directories, files from the package along with its owners and permissions. The trick to change recursive all netpbm structure to root:root was to save some time when you have to fix the prototype file ownership.

    Have a look: you have already root and root under prototype file. If you didn't change the owner you had to run a script or simple command line to fix the owners of all files from prototype file. Now the prototype file looks ok and has the correct permissions

    d none netpbm 0755 root root
    f none netpbm/pkginfo 0644 root root
    f none netpbm/README 0644 root root
    d none netpbm/bin 0755 root root
    f none netpbm/bin/manweb 0755 root root
    ...
    The last thing to do is to add the information about your pkginfo file to prototype file. Simple add the folowing line at the top of prototype:

    i pkginfo=/export/home/user/pkgs/netpbm10/control/pkginfo

    After this your prototype should look like:

    i pkginfo=/export/home/user/pkgs/netpbm10/control/pkginfo
    d none netpbm 0755 root root
    f none netpbm/pkginfo 0644 root root
    f none netpbm/README 0644 root root
    d none netpbm/bin 0755 root root
    ...
  7. Now it is the time to just fire pkgmk command and create your package. For this you have to be under the control directory

    $ cd /export/home/user/pkgs/netpbm10/control
    # pkgmk -o -b /export/home/user/pkgs/netpbm10

  8. Test the package as root:
    # pkgchk -d /var/spool/pkg netpbm

  9. At the end create the package under /tmp as root:
    # pkgtrans -s /var/spool/pkg /tmp/netpbm-10.8-sol9sparc-gcc.gz

    Choose a appropiate name for your package, define clear terms like: what this package is about, what compilers you have used, what platform you have builded for etc. Keep in mind to create a simple rule anyway ... I have used something like:

    package-version-OSPlatform-Compiler

  10. As root install the package under Solaris
    # gunzip /tmp/netpbm-10.8-sol9sparc-gcc.gz
    # pkgadd -d netpbm-10.8-sol9sparc-gcc and the package will install under /opt as defined in step 5
Bibliography

``Using Solaris Packages'' by Dave Zwieback http://www.samag.com/documents/s=1171/sam9912c/9912c.htm
``Application Packaging Developer's Guide'' by Sun Microsystems Inc. http://docs.sun.com/db?p=/doc/806-7008

Back to main homepage

This document is Copyright (c) 2007 Stefan Parvu
Document License: PDL