|
|||
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 Supporting Relocation in a Heterogeneous Environment Making Packages Remotely Installable |
Upgrading PackagesThe 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 Solaris operating environment, 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 upgradable 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 |
||
|