PKG=bufdev NAME=Buffer Device CATEGORY=system BASEDIR=/ ARCH=INTEL VERSION=Software Issue #19 CLASSES=none |
要在安装时安装驱动程序,您必须在 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 文件,请注意以下事项:
因为不需要对软件包对象进行特殊处理,所以您可以将其放置在 none 标准类中。在 pkginfo 文件中 CLASSES 参数被设置为 none。
buffer 和 buffer.conf 的路径名以变量 $KERNDIR 开头。此变量在 request 脚本中设置,允许管理员决定驱动程序文件的安装位置。缺省目录是 /kernel/drv。
postinstall 脚本(将执行驱动程序安装的脚本)有一个对应条目。
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 |