Here is a quick guide to building a package for Solaris i have used a learn by example approach, so with "your" package things will be different.
Creating a Solaris exim package[edit]
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[edit]
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[edit]
/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[edit]
/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/configure.orig /usr/exim
Create a Prototype file[edit]
cat file.list | pkgproto > Prototype
Prototype v1[edit]
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 i preinstall
Prototype v2[edit]
i pkginfo i checkinstall i postinstall i preinstall 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 f none /usr/exim/configure.orig 0644 root root d none /usr/exim 0755 exim exim
Create pkginfo[edit]
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="[email protected]" ISTATES="S s 1 2 3" RSTATES="S s 1 2 3" BASEDIR="/"
Creating package scripts[edit]
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[edit]
Now create /var/tmp/checkinstall, and put this in it (stolen from a webpage somewhere). It's not necessary, but nice:-
#!/bin/sh # 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
Create preinstall[edit]
#!/bin/sh # # add the exim user and group # Modified for MYexim By DrOwl <[email protected]>, 2008-10-02 # check if we have the exim group if [ "`grep exim /etc/group`" = "" ] ; then echo " no exim group found adding it now" groupadd -g 225 exim fi # check if we have the exim user 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 passwd -l exim fi
Create postinstall[edit]
#!/bin/sh # # add the MYexim startup service # Modified for MYexim By DrOwl <[email protected]>, 2008-10-02 # this section adds SMF echo " checking to see if we have a MYexim Service already... " eximServiceDef="/var/svc/manifest/network/smtp-exim.xml" serviceCheck=`svcs -a | grep exim` serviceExist=$? existingService=`echo $serviceCheck | awk '{print $3}'` serviceNoOf=`svcs -a | grep exim | wc -l` if [ $serviceExist -ne 0 ] ; then # did the grep fail with an error? echo " ...ok... none found adding exim startup service " /usr/sbin/svccfg -v import $eximServiceDef else # if grep passes then we have a matching servcie if [ $serviceNoOf -ne "1" ] ; then echo " there was more then one exim service found, you'er going to have to fix this manually" echo " do a 'svcs -a | grep exim' and remove the existing services then import the new one" echo " with '/usr/sbin/svccfg -v import $eximServiceDef'" else echo " The Apache startup service seems to exist already " echo " the service in question is \n $existingService " echo " removing the existing service..." /usr/sbin/svcadm -v disable $existingService /usr/sbin/svccfg -v delete $existingService echo "...replacing with the new one " /usr/sbin/svccfg -v import $eximServiceDef echo " ... quick cycle of the service" /usr/sbin/svcadm -v enable exim /usr/sbin/svcadm -v disable exim echo " service installed, you will need to manual start it after checking the existing config" fi echo "you should go set up httpd.conf before starting exim" fi
Create the package[edit]
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[edit]
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 <from dir> <into pkg> <pkg name/s to be included>