DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Packaging your software applications

3. Create an installation database

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

Techniques

This case study shows examples of the following techniques:

Approach

To create a database file at the time of installation and save a copy on removal, you must:

  1. Create three classes.

    This package requires three classes:

  2. Make the package collectively relocatable.

    Notice in the sample prototype(F) file that none of the pathnames begin with a slash or a variable. This indicates that they are collectively relocatable.

  3. Calculate the amount of space the database file will require and create a space(F) file to deliver with the package. This file notifies pkgadd(ADM) that this package requires extra space and how much extra space. For an example, see the sample space file for this package.

  4. Create an installation class action script for the admin class.

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

    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 will simply be removed from the system.

  5. Create a removal class action script for the cfgdata class.

    The sample removal script makes a copy of the database file before it is deleted during package removal. 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 pathnames to remove. Pathnames always appear in lexical order with the directories appearing first. This script captures directory names so that they can be acted upon later and copies any files to a directory named /tmp. When all of the pathnames 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 /tmp and then remove the config.data file and the data directory.

pkginfo file

   PKG='krazy'
   NAME='KrAzY Applications'
   CATEGORY='applications'
   ARCH='3b2'
   VERSION='Version 1'
   CLASSES='none cfgdata admin'

prototype file

   i pkginfo
   i i.admin
   i r.cfgdata
   d none bin 555 root sys
   f none bin/process1 555 root other
   f none bin/process2 555 root other
   f none bin/process3 555 root other
   f none bin/config 500 root sys
   d admin cfg 555 root sys
   f admin cfg/datafile1 444 root sys
   f admin cfg/datafile2 444 root sys
   f admin cfg/datafile3 444 root sys
   f admin cfg/datafile4 444 root sys
   d cfgdata data 555 root sys

space file

   # extra space required by config data which is
   # dynamically loaded onto the system
   data 500 1

Installation class action script (i.admin)

   # PKGINST parameter provided by installation service
   # BASEDIR parameter provided by installation service
   

while read src dest do # the installation service provides '/dev/null' as the # pathname for directories, pipes, special devices, etc # which it knows how to create [ "$src" = /dev/null ] && continue

cp $src $dest || exit 2 done

# if this is the last time this script will # be executed during the installation, do additional # processing here if [ "$1" = ENDOFCLASS ] then # our config process will create a data file based on any changes # made by installing files in this class; make sure # the data file is in class 'cfgdata' so special rules can apply # to it during package removal installf -c cfgdata $PKGINST $BASEDIR/data/config.data f 444 root sys || exit 2 $BASEDIR/bin/config > $BASEDIR/data/config.data || exit 2 installf -f -c cfgdata $PKGINST || exit 2 fi exit 0

Removal class action script (r.cfgdata)

   # the product manager for this package has suggested that
   # the configuration data is so valuable that it should be
   # backed up to /tmp before it is removed!
   

while read path do # pathnames appear in lexical order, thus directories # will appear first; you cannot operate on directories # until done, so just keep track of names until # later if [ -d $path ] then dirlist="$dirlist $path" continue fi mv $path /tmp || exit 2 done if [ -n "$dirlist" ] then rm -rf $dirlist || exit 2 fi exit 0


Next topic: 4. Define package compatibilities and dependencies
Previous topic: 2. Device driver installation

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005