Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
3.  Enhancing the Functionality of a Package Creating Installation Scripts  Previous   Contents   Next 
   
 

Script Processing During Package Installation

The type of scripts you use depends on when the action of the script is needed during the installation process. As a package is installed, the pkgadd command performs the following steps:

  1. Executes the request script.

    This is the only point at which your package can solicit input from the administrator installing the package.

  2. Executes the checkinstall script.

    The checkinstall script gathers file system data and can create or alter environment variable definitions to control the subsequent installation. For more information on package environment variables, see "Package Environment Variables".

  3. Executes the preinstall script.

  4. Installs package objects, for each class to be installed.

    Installation of these files occurs class by class, and class action scripts are executed accordingly. The list of classes operated on and the order in which they should be installed is initially defined with the CLASSES parameter in your pkginfo file. However, your request script or checkinstall script can change the value of the CLASSES parameter. For more information on how classes are processed during installation, see "How Classes Are Processed During Installation".

    1. Creates symbolic links, devices, named pipes, and required directories.

    2. Installs the regular files (file types e, v, f), based on their class.

      The class action script is passed only regular files to install. All other package objects are created automatically from information in the pkgmap file.

    3. Creates all hard links.

  5. Executes the postinstall script.

Script Processing During Package Removal

When a package is being removed, the pkgrm command performs these steps:

  1. Executes the preremove script.

  2. Removes the package objects, for each class.

    Removal also occurs class by class. Removal scripts are processed in the reverse order of installation, based on the sequence defined in the CLASSES parameter. For more information on how classes are processed during installation, see "How Classes Are Processed During Installation".

    1. Removes hard links.

    2. Removes regular files.

    3. Removes symbolic links, devices, and named pipes.

  3. Executes the postremove script.

The request script is not processed at the time of package removal. However, its output (a list of environment variables) is retained in the installed package and made available to removal scripts.

Package Environment Variables Available to Scripts

The following groups of environment variables are available to all installation scripts. Some of the environment variables can be modified by a request or checkinstall script.

  • The request or checkinstall script can set or modify any of the standard parameters in the pkginfo file except for the required parameters. The standard installation parameters are described in detail in pkginfo(4).


    Note - The BASEDIR parameter can only be modified starting with the Solaris 2.5 and compatible releases.


  • You can define your own installation environment variables by assigning values to them in the pkginfo file. Such environment variables must be alphanumeric with initial capital letters. Any of these environment variables can be changed by a request or checkinstall script.

  • Both a request script and a checkinstall script can define new environment variables by assigning values to them and putting them in the installation environment.

  • The table below lists environment variables that are available to all installation scripts through the environment. None of these can be modified by a script.

    Table 3-2 Package Environment Variables Available to Scripts

    Environment Variable

    Description

    CLIENT_BASEDIR

    The base directory with respect to the target system. While BASEDIR is the variable to use if you are referring to a specific package object from the install system (most likely a server), CLIENT_BASEDIR is the path to include in files placed on the client system. CLIENT_BASEDIR exists if BASEDIR exists and is identical to BASEDIR if there is no PKG_INSTALL_ROOT.

    INST_DATADIR

    The directory where the package now being read is located. If the package is being read from a tape, this will be the location of a temporary directory where the package has been transferred into directory format. In other words, assuming there is no extension to the package name (for example, SUNWstuff.d), the request script for the current package would be found at $INST_DATADIR/$PKG/install.

    PATH

    The search list used by sh to find commands on script invocation. PATH is usually set to /sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin.

    PKGINST

    The instance identifier of the package being installed. If another instance of the package is not already installed, the value is the package abbreviation (for example, SUNWcadap). Otherwise, it is the package abbreviation followed by a suffix, such as SUNWcadap.4.

    PKGSAV

    The directory where files can be saved for use by removal scripts or where previously saved files can be found. Available only in the Solaris 2.5 and compatible releases.

    PKG_INSTALL_ROOT

    The root file system on the target system where the package is being installed. It exists only if the pkgadd and pkgrm commands were invoked with the -R option. This conditional existence facilitates its use in procedure scripts in the form ${PKG_INSTALL_ROOT}/somepath.

    PKG_NO_UNIFIED

    Is an environment variable that gets set if the pkgadd and pkgrm commands were invoked with the -M and -R options. This environment variable is passed to any package installation script or package command that is part of the package environment.

    UPDATE

    This environment variable does not exist under most installation environments. If it does exist (with the value yes), it means that a package with the same name, version, and architecture is already installed on the system or that this package is overwriting an installed package of the same name at the direction of the administrator. In these events, the original base directory is always used.

      

Obtaining Package Information for a Script

Two commands can be used from scripts to solicit information about a package:

  • The pkginfo command returns information about software packages, such as the instance identifier and package name.

  • The pkgparam command returns values for requested environment variables.

    See pkginfo(1), pkgparam(1), and Chapter 4, Verifying and Transferring a Package for more information.

 
 
 
  Previous   Contents   Next