Solaris Software Packaging and Installation
Paul Foster
14/11/2000
Overview
• Solaris package mechanism & related tools
• Building packages
• Preparing packages for burning on CD
• Sample Package
Seven Steps to a Package on CD
• Build Install Tree
• Build the pkginfo file
• Build the prototype file
• Write your post_install, pre_remove and request scripts
• Build the package
• Build an ISO Image using mkisofs
• Burn a CD using the ISO Image
Solaris Package Process
SourceFiles
pkginfo
prototype
InstallScripts pkgmk Package
mkisofs
ISO Image
CDPackage
pkgprotoBurn CD
Key files in a package
• Key Files– pkginfo : general information about the package
– post_install : runs after files are extracted
– pre_remove : runs prior to software removal
– request : prompts installer for extra information
– prototype : description of files & permissions
3 types of files: – -i installation files (/var/sadm/<pkgname>)
– -f normal files
– -d directories
post_install/pre_remove/request
• Must be Bourne Shell Scripts (/bin/sh)
• Scripts run as root - so use explicit paths (e.g. /bin/rm)
• Make parts conditional ( if HPOV installed then do x,y,z)
• Save modified files in a safe place to aid re-installing
• Modifications to files use sed - especially for delete
• Small progress messages / Detailed error messages
• Request script can be used to read license keys, etc.
• Can place helper scripts in /var/sadm/<pkgname> if desired
• Exit status of 0 indicates no errors
The pkginfo file
• Specifies:
– name of the package (short & long form)
– where to install package (e.g. /opt/pfp)
– revision information
– contact details
Run-time Environment Settings
• Exported variables are the settings from your pkginfo file
BASEDIR=/opt/pfp
CLIENT_BASEDIR=/opt/pfp
DESC=Pauls Sample Package
INSTDATE=Nov 14 2000 08:28
INST_DATADIR=/scratch1/tmp/paul/packaging/installation_package
NAME=pfpEMS
OAMBASE=/usr/sadm/sysadm
PKG=pfp
PKGINST=pfp
PKGSAV=/var/sadm/pkg/pfp/save
PSTAMP=pf200006161700
TZ=Australia/Queensland
VERSION=2.0,REV=2000.6.23.12.00
Making a Prototype(pkgproto <pathname>)
i postinstall
i preremove
i request
i pkginfo
i preremove.sed
d none bin 0755 bin bin
f none bin/flex 0750 bin bin
f none bin/lcc 0751 bin bin
Making a Package(pkgmk -o -d <path> -f prototype -r <prototype
tree>) • Example:
pkgmk -o -d ./installation_tree -f prototype -r ./prototype_tree
– installation_tree : is the target package directory
– prototype : describes how I want things installed
– prototype_tree : is my source files copied from the build area
Installing our package(pkgadd -d <drive> <pkgname>)
bash# /usr/sbin/pkgadd -d /scratch/tmp/paul/packaging/installation_package pfp
Processing package instance <pfp> from </scratch1/tmp/paul/packaging/installation_package>
pfpEMS
(sparc) 2.0,REV=2000.6.23.12.00
CiTR Pty Ltd.
The selected base directory </opt/pfp> must exist before installation is
attempted.
Do you want this directory created now [y,n,?,q] y
Using </opt/pfp> as the package base directory.
## Processing package information.
## Processing system information.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.
Installing our Package (cont.)
This package contains scripts which will be executed with super-user
permission during the process of installing this package.
Do you want to continue with the installation of <pfp> [y,n,?] y
Installing pfpEMS as <pfp>
## Installing part 1 of 1.
/opt/pfp/bin/flex
/opt/pfp/bin/lcc
[ verifying class <none> ]
## Executing postinstall script.
Installation of <pfp> was successful.
Information about our package(pkginfo -l [-d <path>] <pkgname>)
bash# /usr/bin/pkginfo -l -d /cdrom/cdrom0 pfp
PKGINST: pfp
NAME: pfpEMS
CATEGORY: system
ARCH: sparc
VERSION: 2.0,REV=2000.6.23.12.00
BASEDIR: /opt/pfp
VENDOR: CiTR Pty Ltd.
DESC: Pauls Sample Package
PSTAMP: pf200006161700
HOTLINE: Please contact your local system administrator.
STATUS: spooled
FILES: 8 spooled pathnames
1 directories
2 executables
5 package information files
1067 blocks used (approx)
Removing our package(pkgrm <pkgname>)
bash# /usr/sbin/pkgrm pfp
The following package is currently installed:
pfp pfpEMS
(sparc) 2.0,REV=2000.6.23.12.00
Do you want to remove this package? y
## Removing installed package instance <pfp>
This package contains scripts which will be executed with super-user
permission during the process of removing this package.
Do you want to continue with the removal of this package [y,n,?,q] y
## Verifying package dependencies.
## Processing package information.
## Executing preremove script.
## Removing pathnames in class <none> (...Some stuff deleted...)
## Updating system information.
Removal of <pfp> was successful.
/var/sadm/pkg
• Your pre_remove script lives here until the package is removed
• pkginfo file determines what gets put in here
• If your package fails to remove cleanly:
– Hand cleanup
– Edit the pre_remove to exit 0 immediately
– Do the pkgrm
Burning the package onto a CD
• mkisofs - builds an ISO9660 file systeme.g.mkisofs -l -o /tmp/cd.iso -a -r -v -A “ems” ./installation_package
• Later versions (1.12) support a -J flag (Joilet support) and tools for verification of ISO images
• Newer versions are downloadable off the net.
• cd.iso suitable for burning onto a CD(Solaris readable by default, PC readable with -J flag)
A Working Example
• For a very simple fully integrated/automated example– Build a prototype tree
– Builds a prototype
– Builds a package
– Builds an ISO file system
– Makefile to perform all tasks in correct order
• See /home/foster/tweek/solaris_package.tar.gz
Other Thoughts
• Alteration of Build Process to Instrument Binaries– Simple code generation of build information
• Release Number, Build Description, Incremental Build No, etc.
• Doesn’t depend on revision control strings embedded in binary (not everyone uses RCS/CVS)
– Manifest of installed binaries (e.g. TP414.1 experience)
• Solaris JumpStart Mechanism– Automated rebuilding of test machine (TV935.3 experience)