(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 :
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.
- Extract your source in ~/pkg/src/foo-0.1 and cd into that directory.
- First, configure the software with
$ ./configure --exec-prefix=/export/home/youruser/pkg/usr/local --prefix=/export/home/youruser/pkg/usr/local.
- Build your software and install it in your ~/pkg/usr/local dir :
$ make && make install
- Now move to the installed software :
$ cd /export/home/youruser/pkg/usr/local/
- We will now create the prototype file with
$ find . -print |pkgproto > prototype
- Edit the prototype file and add i pkginfo=./pkginfo
You'll get something like :
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
- Change in your prototype file all file owner info into bin:bin
You should have something like :
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.
- The part I allways forget is creating the pkginfo file :
The most important entry is the BASEDIR line - it will specify where your software will be installed.
- Make the package with
$ pkgmk -r `pwd`
- Go to the package dir :
$ cd /var/spool/pkg
- Now create the package file itself :
$ pkgtrans -s `pwd` ~/pkg/foo-0.1
- Go to your package (cd ~/pkg) and optionally install it with
$ pkgadd -d foo-0.1
- Gzip it with gzip foo-0.1
- 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 !