Solaris Packages can be created in 4 simple steps listed below:
- Create a pkginfo for information about your package.
- Create a prototype of your package to include the files which you want to ship.
- Make the package to make it ready to ship.
- Transfer the package from directory to a data stream file.
Explanation:There are mainly 6 scripts that you can add to your package. There are some other scripts also which are used for patching. They are:
- request: To prompt user for input. This script will not be executed if an instance of package is already installed with instance=overwrite in /var/sadm/install/admin/default file
- checkinstall: Used to check whether the package is already installed or the system meets the requirements of package or to configure the installation of your package by setting environment for other scripts.
- preinstall: Used to configure installation according to the environment set in checkinstall script.
- postinstall: Used to configure installation after the installation has happened.
- preremove: Used to execute some pre un-installation commands like removing the new files created by the package which were not part of the package supplied.
- postremove: Used to execute full cleanup and other system commands like ldconfig to remove the broken links left by the package removal.
# Copy all your scripts to some temp dir
cat $request > /tmp/request
cat $preinstall > /tmp/preinstall
cat $postinstall > /tmp/postinstall
cat $checkinstall > /tmp/checkinstall
cat $preremove > /tmp/preremove
cat $postremove > /tmp/postremove
cat $copyright > /tmp/copyright #for copyright message
cat $depend > /tmp/depend #for adding package names which are required for your package in format of <type> <pkg.abbr> <name>
# Create pkginfo
echo "PKG=$pkg\nNAME=$pkg\nVERSION=$ver\nARCH=$arch\nCLASSES=none\nCATEGORY=application\nVENDOR=$vendor\nPSTAMP=`date`\nEMAILemail@example.com\nBASEDIR=$path" > /tmp/pkginfo
# Create prototype
echo "i pkginfo\ni preinstall\ni postinstall\ni checkinstall\ni request\ni preremove\ni postremove\ni copyright\ni depend" > /tmp/Prototype
pkgproto $path/$pkg=$pkg >> /tmp/Prototype
# For creating relocatable packages
sed -i "s:$path:\$BASEDIR/:g" /tmp/Prototype # Only path represents a variable in this command.
# Make package
#if the package is relocatable then supply "BASEDIR=$path" in below command
pkgmk -o -r / -d /tmp -f /tmp/Prototype
# Transfer the package
pkgtrans -s `pwd` /tmp/$pkgfile $pkg
- You can use any temporary directory just replace /tmp with your choice.
- You can set the file permissions before creating a prototype file.
- You can use your custom prototype file for file mappings pointing to files in specific directory. for e.g. : i pkginfo=/home/user/mysrc/pkginfo.
- You can use your own custom prototype file to define the file permissions also.