This package installs a driver.
This case study demonstrates the following techniques:
Installing and loading a driver with a postinstall script
Unloading a driver with a preremove script
For more information on these scripts, see "Writing Procedure Scripts".
Create a request script.
The request script determines where the administrator wants the driver objects to be installed, by questioning the administrator and assigning the answer to the $KERNDIR parameter.
The script ends with a routine to make the two parameters
CLASSES and KERNDIR available to the installation environment and the postinstall script.
Create a postinstall script.
The postinstall script actually performs the driver installation. It is executed after the two files buffer and buffer.conf have been installed. The postinstall file shown for this example performs the following actions:
Uses the add_drv command to load the driver into the system
Creates a link for the device using the installf command
Finalizes the installation using the installf -f command
Create a preremove script.
The preremove script uses the rem_drv command to unload the driver from the system, and then removes the link /dev/buffer0.
PKG=bufdev NAME=Buffer Device CATEGORY=system BASEDIR=/ ARCH=INTEL VERSION=Software Issue #19 CLASSES=none
To install a driver at the time of installation, you must include the object and configuration files for the driver in the prototype file.
i pkginfo i request i postinstall i preremove f none $KERNDIR/buffer 444 root root f none $KERNDIR/buffer.conf 444 root root
Looking at the prototype file for this example, notice the following:
Since no special treatment is required for the package objects, you can put them into the standard none class. The
CLASSES parameter is set to none in the pkginfo file.
The path names for buffer and buffer.conf begin with the variable $KERNDIR. This variable is set in the request script and allows the administrator to decide where the driver files should be installed. The default directory is /kernel/drv.
There is an entry for the postinstall script (the script that will perform the driver installation).
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
# 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
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