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

Design Rules for checkinstall Scripts

  • There can be only one checkinstall script per package and it must be named checkinstall.

  • The environment variable assignments should be added to the installation environment for use by the pkgadd command and other packaging scripts by writing them to the response file (known to the script as $1).

  • System environment variables and standard installation environment variables, except for the CLASSES and BASEDIR parameters, cannot be modified by a checkinstall script. Any of the other environment variables you created can be changed.

  • Every environment variable that the checkinstall script may manipulate should be assigned a default value in the pkginfo file.

  • The format of the output list should be PARAM=value. For example:
    CLASSES=none class1

  • Administrator interaction is not permitted during execution of a checkinstall script. All administrator interaction is restricted to the request script.

How to Gather File System Data

  1. Make the directory containing your information files the current working directory.

  2. Create a file named checkinstall with your favorite text editor.

  3. Save your changes and quit the editor when you are done.

  4. Complete one of the following tasks.

  5. Build your package.

    See "How to Build a Package", if needed.

Where to Go Next

After you build the package, install it to confirm that it installs correctly and verify its integrity. Chapter 4, Verifying and Transferring a Package explains how to do this and provides step-by-step instructions on how to transfer your verified package to a distribution medium.

Example--Writing a checkinstall Script

This example checkinstall script checks to see if database software needed by the SUNWcadap package is installed.

# checkinstall script for SUNWcadap
#
# This confirms the existence of the required specU database
 
# First find which database package has been installed.
pkginfo -q SUNWspcdA	# try the older one
 
if [ $? -ne 0 ]; then
   pkginfo -q SUNWspcdB	# now the latest
 
	  if [ $? -ne 0 ]; then	# oops
		    echo "No database package can be found. Please install the"
		    echo "SpecU database package and try this installation again."
		    exit 3		# Suspend
	  else
		    DBBASE="`pkgparam SUNWsbcdB BASEDIR`/db"	# new DB software
	  fi
else
	  DBBASE="`pkgparam SUNWspcdA BASEDIR`/db"	# old DB software
fi
 
# Now look for the database file we will need for this installation
if [ $DBBASE/specUlatte ]; then
	  exit 0		# all OK
else
	  echo "No database file can be found. Please create the database"
	  echo "using your installed specU software and try this"
	  echo "installation again."
	  exit 3		# Suspend
fi
 

Writing Procedure Scripts

The procedure scripts provide a set of instructions to be performed at particular points in package installation or removal. The four procedure scripts must be named one of the predefined names, depending on when the instructions are to be executed, and are executed without arguments.

  • The preinstall script

    Runs before class installation begins. No files should be installed by this script.

  • The postinstall script

    Runs after all volumes have been installed.

  • The preremove script

    Runs before class removal begins. No files should be removed by this script.

  • The postremove script

    Runs after all classes have been removed.

 
 
 
  Previous   Contents   Next