Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
5.  Package Creation Case Studies Soliciting Input From the Administrator Approach  Previous   Contents   Next 
   
 

Case Study Files

The pkginfo File

PKG=ncmp
NAME=NCMP Utilities
CATEGORY=application, tools
BASEDIR=/
ARCH=SPARC
VERSION=RELEASE 1.0, Issue 1.0
CLASSES=""
NCMPBIN=/bin
NCMPMAN=/usr/man
EMACS=/usr/emacs

The prototype File

i pkginfo
i request
x bin $NCMPBIN 0755 root other
f bin $NCMPBIN/dired=/usr/ncmp/bin/dired 0755 root other
f bin $NCMPBIN/less=/usr/ncmp/bin/less 0755 root other
f bin $NCMPBIN/ttype=/usr/ncmp/bin/ttype 0755 root other
f emacs $NCMPBIN/emacs=/usr/ncmp/bin/emacs 0755 root other
x emacs $EMACS 0755 root other
f emacs $EMACS/ansii=/usr/ncmp/lib/emacs/macros/ansii 0644 root other
f emacs $EMACS/box=/usr/ncmp/lib/emacs/macros/box 0644 root other
f emacs $EMACS/crypt=/usr/ncmp/lib/emacs/macros/crypt 0644 root other
f emacs $EMACS/draw=/usr/ncmp/lib/emacs/macros/draw 0644 root other
f emacs $EMACS/mail=/usr/ncmp/lib/emacs/macros/mail 0644 root other
f emacs $NCMPMAN/man1/emacs.1=/usr/ncmp/man/man1/emacs.1 0644 root other
d man $NCMPMAN 0755 root other
d man $NCMPMAN/man1 0755 root other
f man $NCMPMAN/man1/dired.1=/usr/ncmp/man/man1/dired.1 0644 root other
f man $NCMPMAN/man1/ttype.1=/usr/ncmp/man/man1/ttype.1 0644 root other
f man $NCMPMAN/man1/less.1=/usr/ncmp/man/man1/less.1 0644 inixmr other

The request Script

trap 'exit 3' 15
# determine if and where general executables should be placed
ans=`ckyorn -d y \
-p "Should executables included in this package be installed"
` || exit $?
if [ "$ans" = y ]
then
   CLASSES="$CLASSES bin"
   NCMPBIN=`ckpath -d /usr/ncmp/bin -aoy \
   -p "Where should executables be installed"
   ` || exit $?
fi
# determine if emacs editor should be installed, and if it should
# where should the associated macros be placed
ans=`ckyorn -d y \
-p "Should emacs editor included in this package be installed"
` || exit $?
if [ "$ans" = y ]
then
   CLASSES="$CLASSES emacs"
   EMACS=`ckpath -d /usr/ncmp/lib/emacs -aoy \
   -p "Where should emacs macros be installed"
   ` || exit $?
fi

Note that a request script can exit without leaving any files on the file system. For installations on Solaris versions prior to 2.5 and compatible versions (where no checkinstall script may be used) the request script is the correct place to test the file system in any manner necessary to ensure that the installation will succeed. When the request script exits with code 1, the installation will quit cleanly.

These example files show the use of parametric paths to establish multiple base directories. However, the preferred method involves use of the BASEDIR parameter which is managed and validated by the pkgadd command. Whenever multiple base directories are used, take special care to provide for installation of multiple versions and architectures on the same platform.

Creating a File at Installation and Saving It During Removal

This case study creates a database file at installation time and saves a copy of the database when the package is removed.

Techniques

This case study demonstrates the following techniques:

  • Using classes and class action scripts to perform special actions on different sets of objects

    For more information, see "Writing Class Action Scripts".

  • Using the space file to inform the pkgadd command that extra space is required to install this package properly

    For more information on the space file, see "Reserving Additional Space on a Target System".

  • Using the installf command to install a file not defined in the prototype and pkgmap files

Approach

To create a database file at installation and save a copy on removal for this case study, you must complete the following tasks:

  • Define three classes.

    The package in this case study requires the following three classes be defined in the CLASSES parameter:

    • The standard class of none, which contains a set of processes belonging in the subdirectory bin.

    • The admin class, which contains an executable file config and a directory containing data files.

    • The cfgdata class, which contains a directory.

  • Make the package collectively relocatable.

    Notice in the prototype file that none of the path names begins with a slash or an environment variable. This indicates that they are collectively relocatable.

  • Calculate the amount of space the database file requires and create a space file to deliver with the package. This file notifies the pkgadd command that the package requires extra space and specifies how much.

  • Create a class action script for the admin class (i.admin).

    The sample script initializes a database using the data files belonging to the admin class. To perform this task, it does the following:

    • Copies the source data file to its proper destination

    • Creates an empty file named config.data and assigns it to a class of cfgdata

    • Executes the bin/config command (delivered with the package and already installed) to populate the database file config.data using the data files belonging to the admin class

    • Executes the installf -f command to finalize installation of config.data

    No special action is required for the admin class at removal time so no removal class action script is created. This means that all files and directories in the admin class are removed from the system.

  • Create a removal class action script for the cfgdata class (r.cfgdata).

    The removal script makes a copy of the database file before it is deleted. No special action is required for this class at installation time, so no installation class action script is needed.

    Remember that the input to a removal script is a list of path names to remove. Path names always appear in reverse alphabetical order. This removal script copies files to the directory named $PKGSAV. When all the path names have been processed, the script then goes back and removes all directories and files associated with the cfgdata class.

    The outcome of this removal script is to copy config.data to $PKGSAV and then remove the config.data file and the data directory.

 
 
 
  Previous   Contents   Next