Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
5.  Package Creation Case Studies Installing and Removing a Driver With Procedure Scripts Case Study Files The prototype File  Previous   Contents   Next 
   
 

The request Script

trap 'exit 3' 15
# determine where driver object should be placed; location
# must be an absolute path name that is an existing directory
KERNDIR=`ckpath -aoy -d /kernel/drv -p \
"Where do you want the driver object installed"` || exit $?

# make parameters available to installation service, and
# so to any other packaging scripts
cat >$1 <<!

CLASSES='$CLASSES'
KERNDIR='$KERNDIR'
!
exit 0

The postinstall Script

# KERNDIR parameter provided by `request' script
err_code=1                    # an error is considered fatal
# Load the module into the system
cd $KERNDIR
add_drv -m '* 0666 root sys' buffer || exit $err_code
# Create a /dev entry for the character node
installf $PKGINST /dev/buffer0=/devices/eisa/buffer*:0 s
installf -f $PKGINST

The preremove Script

err_code=1                    # an error is considered fatal
# Unload the driver
rem_drv buffer || exit $err_code
# remove /dev file
removef $PKGINST /dev/buffer0 ; rm /dev/buffer0
removef -f $PKGINST

Installing a Driver Using the sed Class and Procedure Scripts

This case study describes how to install a driver using the sed class and procedure scripts. It is also different from the previous case study (see "Installing and Removing a Driver With Procedure Scripts") because this package is made up of both absolute and relocatable objects.

Techniques

This case study demonstrates the following techniques:

Approach

  • Create a prototype file containing both absolute and relocatable package objects.

    This is discussed in detail in "The prototype File".

  • Add the sed class script to the prototype file.

    The name of a script must be the name of the file that will be edited. In this case, the file to be edited is /etc/devlink.tab and so the sed script is named /etc/devlink.tab. There are no requirements for the mode, owner, and group of a sed script (represented in the sample prototype by question marks). The file type of the sed script must be e (indicating that it is editable).

  • Set the CLASSES parameter to include the sed class.

  • Create a sed class action script (/etc/devlink.tab).

  • Create a postinstall script.

    The postinstall script needs to execute the add_drv command to add the device driver to the system.

  • Create a preremove script.

    The preremove script needs to execute the rem_drv command to remove the device driver from the system, prior to the package being removed.

  • Create a copyright file.

    A copyright file contains the ASCII text of a copyright message. The message shown in the sample file is displayed on the screen during package installation.

Case Study Files

The pkginfo File

PKG=SUNWsst
NAME=Simple SCSI Target Driver
VERSION=1
CATEGORY=system
ARCH=sparc
VENDOR=Sun Microsystems
BASEDIR=/opt
CLASSES=sed

The prototype File

For example, this case study uses the hierarchical layout of the package objects shown in the figure below.

Figure 5-1 Hierarchical Package Directory Structure

The package objects are installed in the same places as they are in the pkg directory above. The driver modules (sst and sst.conf) are installed into /usr/kernel/drv and the include file is installed into /usr/include/sys/scsi/targets. The sst, sst.conf, and sst_def.h files are absolute objects. The test program, sstest.c, and its directory SUNWsst are relocatable; their installation location is set by the BASEDIR parameter.

The remaining components of the package (all the control files) go in the top directory of the package on the development machine, except the sed class script. This is called devlink.tab after the file it modifies, and goes into etc, the directory containing the real devlink.tab file.

From the pkg directory, run the pkgproto command as follows:

find usr SUNWsst -print | pkgproto > prototype

The output from the above command looks like this:

d none usr 0775 pms mts
d none usr/include 0775 pms mts
d none usr/include/sys 0775 pms mts
d none usr/include/sys/scsi 0775 pms mts
d none usr/include/sys/scsi/targets 0775 pms mts
f none usr/include/sys/scsi/targets/sst_def.h 0444 pms mts
d none usr/kernel 0775 pms mts
d none usr/kernel/drv 0775 pms mts
f none usr/kernel/drv/sst 0664 pms mts
f none usr/kernel/drv/sst.conf 0444 pms mts
d none SUNWsst 0775 pms mts
f none SUNWsst/sstest.c 0664 pms mts
 
 
 
  Previous   Contents   Next