Tuesday, November 18, 2008

Create Solaris Package from Source

For this example I will use stunnel since I had to create this package at work today. This software will be compiled from source and created as a package.

First we create a directory structure for our new package. In this example, I'll use /var/tmp/src, but it can be created anywhere.

# cd /var/tmp/src
# mkdir LDSstunnel InfoPath

In the InfoPath directory which we just created, use your favorite text editor (vi) to create a file named pkginfo with the following contents.

ARCH=SPARC
CATEGORY=application
NAME=stunnel
PKG=LDSstunnel
VERSION=4.26
DESC=allows to encrypt arbitrary TCP connections inside SSL
VENDOR=stunnel source taken from http://www.stunnel.org
- ARCH - is the architecture this package is built for. Can be sparc, i386 or ppc
- CATEGORY - list under which category to display the package
- NAME - short name of the package
- PKG - name of package. It is customary to make the first four letters unique to your company, such as a stock symbol.
- VERSION - version of package. In this case this is the version of stunnel
- DESC - descriptive information about the package
- VENDOR - used to describe the vendor that holds the software copyright
More information about these fields and other fields that can be used is in the pkginfo(4) man page.


Configure, compile, and install the software in a unique place

# ./configure --prefix=/opt/LDSstunnel
# make
# make install
# cd /opt/LDSstunnel
# mv * /
var/tmp/src/LDSstunnel/
# cd ..
# rmdir LDSstunnel

Make any changes that need to be made to config files, etc.
I copied a default configuration file into /var/tmp/src/LDSstunnel/etc/stunnel/

In the InfoPath directory create a file named prototype. This file can be created manually, however, it is much easier to use the pkgproto tool.
# cd /var/tmp/src
# pkgproto ./LDSstunnel > InfoPath/prototype

Add a line to the end of the prototype file with information about the pkginfo file
# echo "i pkginfo=/var/tmp/src/InfoPath/pkginfo" >> InfoPath/prototype

Use the pkgmk tool to create the package
# pkgmk -f InfoPath/prototype -b /var/tmp/src

We can now use the pkginfo command to get information about this new package which is in the /var/spool/pkg directory
# cd /var/spool/pkg
# pkginfo -d .
application LDSstunnel stunnel

Our package is located in the /var/spool/pkg directory. We could copy the contents of this directory to an nfs export or tarball it and copy it to the destination server and install.

No comments: