JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Application Packaging Developer's Guide     Oracle Solaris 10 1/13 Information Library
search filter icon
search icon

Document Information

Preface

1.  Designing a Package

2.  Building a Package

3.  Enhancing the Functionality of a Package (Tasks)

4.  Verifying and Transferring a Package

5.  Case Studies of Package Creation

6.  Advanced Techniques for Creating Packages

Specifying the Base Directory

The Administrative Defaults File

Becoming Comfortable With Uncertainty

Using the BASEDIR Parameter

Using Parametric Base Directories

Examples--Using Parametric Base Directories

The pkginfo File

The pkgmap File

Managing the Base Directory

Accommodating Relocation

Walking Base Directories

Using the BASEDIR Parameter

The pkginfo File

The pkgmap File

Example--Analysis Scripts That Walk a BASEDIR

The request Script

The checkinstall Script

Using Relative Parametric Paths

The pkginfo File

The pkgmap File

Example--A request Script That Walks a Relative Parametric Path

Supporting Relocation in a Heterogeneous Environment

Traditional Approach

Relocatable Packages

Example-A Traditional Relocatable Package

The pkginfo File

The pkgmap File

Absolute Packages

Example-A Traditional Absolute Package

The pkgmap File

Composite Packages

Example-A Traditional Solution

The pkginfo File

The pkgmap File

Beyond Tradition

Another Look at Composite Packages

Making Absolute Path Names Look Relocatable

Example--Modifying a File

Description

Implementation

Example

Example--Creating a New File

Description

Implementation

Example

Example--A Composite Package

The pkginfo File

The pkgmap File

Making Packages Remotely Installable

Example - Installing to a Client System

Example - Installing to a Server or Standalone System

Example - Mounting Shared File Systems

Patching Packages

The checkinstall Script

The preinstall Script

The Class Action Script

The postinstall Script

The patch_checkinstall Script

The patch_postinstall Script

Upgrading Packages

The request Script

The postinstall Script

Creating Class Archive Packages

Structure of the Archive Package Directory

Keywords to Support Class Archive Packages

The faspac Utility

Glossary

Index

Upgrading Packages

The process of upgrading a package is very different from that of overwriting a package. While there are special tools to support the upgrade of standard packages delivered as part of the Oracle Solaris OS, an unbundled package can be designed to support its own upgrade—several previous examples described packages that look ahead and control the precise method of installation under the direction of the administrator. You can design the request script to support direct upgrade of a package as well. If the administrator chooses to have one package install so as to completely replace another, leaving no residual obsolete files, the package scripts can do this.

The request script and postinstall script in this example provide a simple upgradeable package. The request script communicates with the administrator and then sets up a simple file in the /tmp directory to remove the old package instance. (Although the request script creates a file (which is forbidden), it is okay because everyone has access to /tmp).

The postinstall script then executes the shell script in /tmp, which executes the necessary pkgrm command against the old package and then deletes itself.

This example illustrates a basic upgrade. It is less than fifty lines of code including some fairly long messages. It could be expanded to backout the upgrade or make other major transformations to the package as required by the designer.

The design of the user interface for an upgrade option must be absolutely sure that the administrator is fully aware of the process and has actively requested upgrade rather than parallel installation. There is nothing wrong with performing a well understood complex operation like upgrade as long as the user interface makes the operation clear.

The request Script

# request script
control an upgrade installation
 
PATH=/usr/sadm/bin:$PATH
UPGR_SCRIPT=/tmp/upgr.$PKGINST
 
UPGRADE_MSG="Do you want to upgrade the installed version ?"
 
UPGRADE_HLP="If upgrade is desired, the existing version of the \
    package will be replaced by this version. If it is not \
    desired, this new version will be installed into a different \
    base directory and both versions will be usable."
 
UPGRADE_NOTICE="Conflict approval questions may be displayed. The \
    listed files are the ones that will be upgraded. Please \
    answer \"y\" to these questions if they are presented."
 
pkginfo -v 1.0 -q SUNWstuf.\*
 
if [ $? -eq 0 ]; then
      # See if upgrade is desired here
      response=`ckyorn -p "$UPGRADE_MSG" -h "$UPGRADE_HLP"`
      if [ $response = "y" ]; then
            OldPkg=`pkginfo -v 1.0 -x SUNWstuf.\* | nawk ' \
            /SUNW/{print $1} '`
            # Initiate upgrade
            echo "PATH=/usr/sadm/bin:$PATH" > $UPGR_SCRIPT
            echo "sleep 3" >> $UPGR_SCRIPT
            echo "echo Now removing old instance of $PKG" >> \
            $UPGR_SCRIPT
            if [ ${PKG_INSTALL_ROOT} ]; then
                  echo "pkgrm -n -R $PKG_INSTALL_ROOT $OldPkg" >> \
                  $UPGR_SCRIPT
            else
                  echo "pkgrm -n $OldPkg" >> $UPGR_SCRIPT
            fi
            echo "rm $UPGR_SCRIPT" >> $UPGR_SCRIPT
            echo "exit $?" >> $UPGR_SCRIPT
 
            # Get the original package's base directory
            OldBD=`pkgparam $OldPkg BASEDIR`
            echo "BASEDIR=$OldBD" > $1
            puttext -l 5 "$UPGRADE_NOTICE"
       else
             if [ -f $UPGR_SCRIPT ]; then
                   rm -r $UPGR_SCRIPT
             fi
       fi
fi
 
exit 0

The postinstall Script

# postinstall
to execute a simple upgrade
 
PATH=/usr/sadm/bin:$PATH
UPGR_SCRIPT=/tmp/upgr.$PKGINST
 
if [ -f $UPGR_SCRIPT ]; then
      sh $UPGR_SCRIPT &
fi
 
exit 0