Solaris/Packages

Creating a Solaris package
Make your self a nice new directory to work in

mkdir /root/exim.package.1.69 cd /root/exim.package.1.69

Create a file list
Create a list of all files used by the program you want to package.

du -a /usr/exim/ | cut -f2 > file.list Edit the file to clean out any un-needed files (eg in the below there is no need for "/usr/exim/.profile" etc

file.list v1
/usr/exim/.profile /usr/exim/local.cshrc /usr/exim/local.login /usr/exim/local.profile /usr/exim/bin/exim-4.69-4 /usr/exim/bin/exim /usr/exim/bin/eximon /usr/exim/bin/eximon.bin /usr/exim/bin/exim_dumpdb /usr/exim/bin/exim_fixdb /usr/exim/bin/exim_tidydb /usr/exim/bin/exinext /usr/exim/bin/exiwhat /usr/exim/bin/exim_dbmbuild /usr/exim/bin/exicyclog /usr/exim/bin/exigrep /usr/exim/bin/eximstats /usr/exim/bin/exipick /usr/exim/bin/exiqgrep /usr/exim/bin/exiqsumm /usr/exim/bin/exim_lock /usr/exim/bin/exim_checkaccess /usr/exim/bin /usr/exim/configure /usr/exim

file.list v2
/usr/exim/bin/exim-4.69-4 /usr/exim/bin/exim /usr/exim/bin/eximon /usr/exim/bin/eximon.bin /usr/exim/bin/exim_dumpdb /usr/exim/bin/exim_fixdb /usr/exim/bin/exim_tidydb /usr/exim/bin/exinext /usr/exim/bin/exiwhat /usr/exim/bin/exim_dbmbuild /usr/exim/bin/exicyclog /usr/exim/bin/exigrep /usr/exim/bin/eximstats /usr/exim/bin/exipick /usr/exim/bin/exiqgrep /usr/exim/bin/exiqsumm /usr/exim/bin/exim_lock /usr/exim/bin/exim_checkaccess /usr/exim/bin /usr/exim/configure /usr/exim

Create a Prototype file
cat file.list | pkgproto > Prototype

Prototype v1
f none /usr/exim/bin/exim-4.69-4 4755 root root s none /usr/exim/bin/exim=exim-4.69-4 f none /usr/exim/bin/eximon 0755 root root f none /usr/exim/bin/eximon.bin 0755 root root f none /usr/exim/bin/exim_dumpdb 0755 root root f none /usr/exim/bin/exim_fixdb 0755 root root f none /usr/exim/bin/exim_tidydb 0755 root root f none /usr/exim/bin/exinext 0755 root root f none /usr/exim/bin/exiwhat 0755 root root f none /usr/exim/bin/exim_dbmbuild 0755 root root f none /usr/exim/bin/exicyclog 0755 root root f none /usr/exim/bin/exigrep 0755 root root f none /usr/exim/bin/eximstats 0755 root root f none /usr/exim/bin/exipick 0755 root root f none /usr/exim/bin/exiqgrep 0755 root root f none /usr/exim/bin/exiqsumm 0755 root root f none /usr/exim/bin/exim_lock 0755 root root f none /usr/exim/bin/exim_checkaccess 0755 root root d none /usr/exim/bin 0755 root root f none /usr/exim/configure 0644 root root d none /usr/exim 0755 exim exim

more lines need to be added at the top of this file eg:-

i pkginfo i checkinstall i postinstall

Prototype v2
i pkginfo i checkinstall i postinstall f none /usr/exim/bin/exim-4.69-4 4755 root root s none /usr/exim/bin/exim=exim-4.69-4 f none /usr/exim/bin/eximon 0755 root root f none /usr/exim/bin/eximon.bin 0755 root root f none /usr/exim/bin/exim_dumpdb 0755 root root f none /usr/exim/bin/exim_fixdb 0755 root root f none /usr/exim/bin/exim_tidydb 0755 root root f none /usr/exim/bin/exinext 0755 root root f none /usr/exim/bin/exiwhat 0755 root root f none /usr/exim/bin/exim_dbmbuild 0755 root root f none /usr/exim/bin/exicyclog 0755 root root f none /usr/exim/bin/exigrep 0755 root root f none /usr/exim/bin/eximstats 0755 root root f none /usr/exim/bin/exipick 0755 root root f none /usr/exim/bin/exiqgrep 0755 root root f none /usr/exim/bin/exiqsumm 0755 root root f none /usr/exim/bin/exim_lock 0755 root root f none /usr/exim/bin/exim_checkaccess 0755 root root d none /usr/exim/bin 0755 root root f none /usr/exim/configure 0644 root root d none /usr/exim 0755 exim exim

Create pkginfo
add the following fields. Edit as appropriate for your package. You can get information about the already installed package with:-

pkginfo -l MYexim

PKG="MYexim" NAME="MY Exim Package" VERSION="4.69" ARCH="sparc" CLASSES="none" CATEGORY="application" VENDOR="GNU" PSTAMP="30thSep08" EMAIL="me@MY.co.uk" ISTATES="S s 1 2 3" RSTATES="S s 1 2 3" BASEDIR="/"

===Creating package scripts: What are they I hear you say?

checkinstall is a script that is run at install time, by the user "nobody". With it you can check for dependancies and problems and if needed, exit the pkgadd gracefully. Care is needed when building the package that the permissions on the directories are set up so the user "nobody" can get to the script. You are NOT asked by pkgadd if you want to run this script.

preinstall is run as root when the package is actually installing. An abort here will require the user to pkgrm the half installed package. You are asked by pkgadd if you want to run this script.

postinstall is a script that runs after the rest of the package is installed. With it you can do things like utilize the just installed software, install kernel drivers, create devices and other post-install things. This script also runs as root. You are asked by pkgadd if you want to run this script.

To add them to the Prototype file put in a line like:

i preinstall i postinstall i checkinstall

These scripts are run after installation starts, so if something goes wrong with the install in those scripts and they exit with non-zero then a pkgrm will be required to clean up the half installed package.

Create checkinstall
Now create /var/tmp/checkinstall, and put this in it (stolen from a webpage somewhere). It's not necessary, but nice:-

expected_platform="sparc" platform=`uname -p` if [ ${platform} != ${expected_platform} ]; then echo "\n\n\n\tThis package must be installed on a ${expected_platform} architecture\n" echo "\tAborting installation.\n\n\n" exit 1 fi exit 0
 * 1) !/bin/sh

Create postinstall

 * 1) !/bin/sh

if [ `grep exim /etc/group` = "" ] ; then echo " no exim group found adding it now" groupadd -g 225 exim fi
 * 1) check if we have the exim group

if [ 'grep exim /etc/passwd' = "" ] ; then echo "no exim user found adding it now" useradd -u 225 -g exim -d /usr/exim -m -c "Exim user" exim fi
 * 1) check if we have the nagios user

Create the package
pkgmk -o -r / -d /var/tmp -f Prototype

This creates a directory in /var/tmp with the name of you package. In this case, E2exim.

Create the .pkg
pkgtrans -s /var/tmp /var/tmp/MYexim-4.69-Sol10-sparc-01.pkg MYexim

gzip -9 /var/tmp/MYexim-4.69-Sol10-sparc-01.pkg

pkgtrans -s 