You are here

Creating (Open)Solaris packages

Topics: 
OpenSolaris

(File under : 6yo stuff that I finally integrated into my blog)
Since I became a Unix system administrator, I had the opportunity to create some Solaris packages. We all know how important decent package management is on Unix systems, and I have a decent experience in packaging software with my Debian box at home. Apt-build and such are excellent tools under Debian, so I was a bit surprised that package management seemed so primitive under Solaris.

There are some scripts out there which do the job for you, but as it is the habit with scripts, you don't know what these things are doing on your machine. If you want to know all the tidbits about packaging on Solaris, you're on the right place here.

So here is a HOWTO about creating Solaris packages based on my experience.

Intro and setup


You don't need root access for creating these packages; only if you want to install them, root access is needed. First, create the following directory structure in your homedir :
/export/home/youruser
	!
	+---  pkg
		!
		+--- src
		!
		+--- usr
			!
			+--- local

We will extract and build our software in the ~/src dir. Installation will happen in the ~/pkg/usr/local dir. So you really don't need to setup a chrooted environment as you see so many times explained in other places.

The procedure

  1. Extract your source in ~/pkg/src/foo-0.1 and cd into that directory.
  2. First, configure the software with
    $ ./configure --exec-prefix=/export/home/youruser/pkg/usr/local --prefix=/export/home/youruser/pkg/usr/local.
  3. Build your software and install it in your ~/pkg/usr/local dir :
    $ make && make install
    
  4. Now move to the installed software :
    $ cd /export/home/youruser/pkg/usr/local/
  5. We will now create the prototype file with
    $ find . -print |pkgproto > prototype
  6. Edit the prototype file and add i pkginfo=./pkginfo
    You'll get something like :
          i pkginfo=./pkginfo
          d none lib 0755 kristof users
          f none lib/libslang.a 0644 kristof users
          d none include 0755 kristof users
          f none include/slang.h 0644 kristof users
          f none include/slcurses.h 0644 kristof users
    
  7. Change in your prototype file all file owner info into bin:bin
    You should have something like :
          i pkginfo=./pkginfo
          d none lib 0755 bin bin
          f none lib/libslang.a 0644 bin bin
          d none include 0755 bin bin
          f none include/slang.h 0644 bin bin
          f none include/slcurses.h 0644 bin bin
    

    You should add pre- and postinstall scripts with a line like the pkginfo one.

  8. The part I allways forget is creating the pkginfo file :
          PKG="SCprog"
          NAME="prog"
          ARCH="intel"
          VERSION="1.00"
          CATEGORY="application"
          VENDOR="Foo, Inc."
          EMAIL="foo@net.net"
          PSTAMP="Mr Pink"
          BASEDIR="/usr/local"
          CLASSES="none"
    

    The most important entry is the BASEDIR line - it will specify where your software will be installed.

  9. Make the package with
    $ pkgmk -r `pwd`
  10. Go to the package dir :
    $ cd /var/spool/pkg
  11. Now create the package file itself :
    $ pkgtrans -s `pwd` ~/pkg/foo-0.1
  12. Go to your package (cd ~/pkg) and optionally install it with
    $ pkgadd -d foo-0.1
  13. Gzip it with gzip foo-0.1
  14. Don't forget to clean up your ~/pkg/usr/local dir :
    $ rm -rf ~/pkg/usr/local/ && mkdir -p ~/pkg/usr/local/

That's it ! Your package has been created !

Comments

Thanks for the guide!
This will certainly come in handy!