アプリケーションパッケージ開発者ガイド

手続きスクリプトによるドライバのインストールと削除

このパッケージでは、ドライバをインストールします。

手法

このケーススタディーでは、次の手法の実例を示します。

これらのスクリプトの詳細については、「手続きスクリプトの書き込み」を参照してください。

アプローチ

ケーススタディーで使用するファイル

pkginfo ファイル

PKG=bufdev
NAME=Buffer Device
CATEGORY=system
BASEDIR=/
ARCH=INTEL
VERSION=Software Issue #19
CLASSES=none

prototype ファイル

インストール時にドライバをインストールするには、ドライバのオブジェクトおよび構成ファイルを prototype ファイルに含める必要があります。

この例では、ドライバの実行モジュールの名前は buffer です。add_drv コマンドは、このファイルに対して実行されます。カーネルは、構成ファイル buffer.conf をドライバの構成に利用します。

i pkginfo
i request
i postinstall
i preremove
f none $KERNDIR/buffer 444 root root
f none $KERNDIR/buffer.conf 444 root root

この例の prototype ファイルを見て、次の点に注意してください。

request スクリプト

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

postinstall スクリプト

# 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

preremove スクリプト

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