Creating software-packages under Solaris
This page describes how to create your own packages for Solaris --
which I recommend for
Getting and compiling the software
Before you can start to package something you need to get the sources and compile them. Kind of obvious, eh? Generally you should check the documentation supplied with the source tarball. If your program uses autoconf you'll be fine with `configure --prefix=/something --maybe-additional-options && make'
I'm going to use /opt as destination for software in this howto, therefore
you'd type `--prefix=/opt', binaries will end up in /opt/bin, and so on.
We'll do the packaging for a fake software package named `sw'. Building,
packaging and similar stuff will take place in /export/install (for
various reasons I prefer
Getting the files being installed
Now you do need a list of files a `make install' will install. Most software allows you to do something like `make DESTDIR=/export/sw install' -- which would result in having the software installed under /export/sw/prefix. Unfortunately, some developers use different names for this variable or don't provide support for it it all.
If you're lucky they'll mention in the documentation how you can install the program into a different location. If not you'll have to check -- and maybe edit -- the makefile. If you don't want to edit the makefile installing into an empty /opt would work, too. However, don't use --prefix for this purpose (unless you're going to compile it with correct prefix) because it specifies some pathnames linked into the binary -- e.g. where to find configuration files. If you install the software under a different prefix the software most likely will fail.
OK, we assume you got the software installed under /export/sw. Now we can use find to retrieve a list of all files there. Of course we don't want `export/sw` in front of the path names -- and we don't want empty lines. We can use sed and awk for the job.
# find /export/sw | sed 's,/export/sw,,' | awk 'length > 0'
will create the list as we'd like it to be.
Creating a package prototype
OK, we have a list of files. Now it's time to do the actual install -- go to the source directory and type `make install'. As a next step we create a package prototype from the file list we made in the last step. Write the file list into a file -- for example sw.list. For our virtual package this could look like this:
/opt/bin/sw
/opt/etc/sw.conf
/opt/man/man1/sw.1
Now use
# cat sw.list | pkgproto > sw.proto # cat sw.proto d none /opt 0775 root other d none /opt/bin 0775 root other f none /opt/bin/sw 0755 bin bin d none /opt/etc 0775 root other f none /opt/etc/sw.conf 0644 root other d none /opt/man 0775 root other d none /opt/man/man1 0775 root other f none /opt/man/man1/sw.1 0444 bin bin #
Check the file permissions and ownerships, maybe they are not the way
you'd like them to be. If your satisfied with the permissions you
need to add at least two additional files --
# cat checkinstall
#!/bin/sh
expected_platform="sparc"
platform=`uname -p`
if [ ${platform} != ${expected_platform} ]; then
echo "This package must be installed on ${expected_platform}"
exit '
fi
exit 0
# cat pkginfo
PKG="AARDsw"
NAME="sw"
VERSION="1.0"
ARCH="sparc"
CLASSES="none"
CATEGORY="tools"
VENDOR="AARD"
PSTAMP="9thNov2004"
EMAIL="bwachter-pkg@lart.info"
ISTATES="S s 1 2 3"
RSTATES="S s 1 2 3"
BASEDIR="/"
Create the two files in the current directory, and add them two the
prototype --
There are some more scripts for pre/postinstall as well as pre/postremove.
Usage is pretty simple, just some script performing actions, which gets
added to pkginfo like other metadata -- i.e.
Creating the package
We do have a prototype, we do have additional scripts, and the software is installed where it should be. Time to create the package.
pkgmk -o -r / -d /export/ -f sw.proto
will create a directory containing your package under /export. The directory will be named like the `PKG'-value you specified in the prototype. You can use this package directory to install the software -- if you want. We'd prefer having the package in `datastream' format, it's easier to distribute. We can do the transformation with the pkgtrans-utility:
pkgtrans -s `pwd` /export/sw-1.0-sol10-sparc AARDsw
After this you'll have a file named sw-1.0-sol10-sparc in /export, containing your package in datastream format. Just gzip it and upload it somewhere. The uncompressed datastream package can be installed with `pkgadd -d filename`