# # Spec file for NVIDIA kernel module. # # $Header: //sw/main/drivers/resman/NVIDIA_kernel.spec#22 $ # %define RELEASE 4363 %define CUSTOM_RELEASE 4363 %define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE} %define ver 1.0 Summary: NVIDIA kernel module for NVIDIA Architecture support. Name: NVIDIA_kernel Version: %ver Release: %rel Copyright: NVIDIA Corp. 2000 Group: User Interface/X Hardware Support Source: ftp://ftp1.detonator.nvidia.com/pub/drivers/english/XFree86_40/NVIDIA_kernel-%{ver}-%{RELEASE}.tar.gz URL: http://www.nvidia.com Vendor: NVIDIA Corp. BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION} Packager: Buildmeister Requires: kernel >= 2.2.0 Requires: rpm >= 3.0.4 %description NVIDIA Architecture support for systems with updated or custom kernels. %prep %setup -q -n ${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}-${RPM_PACKAGE_RELEASE} %build # don't exit immediately when something bad happens. set +e # building an rpm from an srpm does not check the requires field. # make sure that rpm is good enough for us. RPMVERSION=`rpm -q --queryformat "%{VERSION}" rpm` RPMMAJOR=`echo $RPMVERSION | awk -F \. '{print $1;}'` RPMMINOR=`echo $RPMVERSION | awk -F \. '{print $2;}'` RPMPATCH=`echo $RPMVERSION | awk -F \. '{print $3;}'` if [ $RPMMAJOR -le 3 -a $RPMMINOR -le 0 -a $RPMPATCH -lt 4 ]; then echo -e "\nNeed rpm version 3.0.4 or greater\n"; exit 1; fi make nvidia.o # This will install the module itself onto the user's system, but not # load it into the running system. This will allow our auto-builds to # execute properly %install # create a file list for nvidia.o, to make sure the path is correct # it really should be under $RPM_BUILD_ROOT, but the %files section # does not honor it. Bummer. rm -f /tmp/files.lst # allow a build script to override the targetted kernel # otherwise default to current running kernel if [ -z "$TARGET_KERNEL" ]; then export TARGET_KERNEL=`uname -r` fi if [ -d $RPM_ROOT/lib/modules/$TARGET_KERNEL/kernel ]; then INSTALLPATH=/lib/modules/$TARGET_KERNEL/kernel/drivers/video else INSTALLPATH=/lib/modules/$TARGET_KERNEL/video fi mkdir -p $RPM_BUILD_ROOT/$INSTALLPATH install -m 0444 nvidia.o $RPM_BUILD_ROOT/$INSTALLPATH echo "%attr(444 root root) " $INSTALLPATH/nvidia.o > /tmp/files.lst install -m 0755 -d $RPM_BUILD_ROOT/dev if [ ! -c /dev/.devfsd ]; then for i in 0 1 2 3 4 5 6 7; do node="$RPM_BUILD_ROOT/dev/nvidia$i" touch $node || error "touch \"$node\"" chmod 0666 $node || error "chmod \"$node\"" done node="$RPM_BUILD_ROOT/dev/nvidiactl" touch $node || error "touch \"$node\"" chmod 0666 $node || error "chmod \"$node\"" find $RPM_BUILD_ROOT/dev -type f -print \ | sed "s,^$RPM_BUILD_ROOT,%ghost ," >> /tmp/files.lst fi unset RPM_BUILD_ROOT # trick RPM 4.0 into not stripping us %clean [ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT # Old versions of the tarball Makefile would install NVdriver in the # wrong directory. Remove the old NVdriver, if that leaves it parent # directory empty remove it as well. Note that we always install the # nvidia.o module in the correct directory, so we don't need to worry # about it here. %pre WRONGDIR=/lib/modules/`uname -r`/kernel/video if [ -d $WRONGDIR ]; then rm -f $WRONGDIR/NVdriver rmdir --ignore-fail-on-non-empty $WRONGDIR fi # In %post we basically do "run-time" installation # Note that our files are installed onto the system, and the packages # are cleaned up and gone. There are no Makefiles or fancy environment # variables to play with. I basically repeated the needed parts of the # install.sh script here %post # unload it quietly if already loaded.. /sbin/rmmod NVdriver >& /dev/null /sbin/rmmod nvidia >& /dev/null rmmod_failed=0 /sbin/lsmod | grep nvidia >& /dev/null && rmmod_failed=1 /sbin/lsmod | grep NVdriver >& /dev/null && rmmod_failed=1 if [ $rmmod_failed -eq 1 ]; then echo echo "Unable to remove existing NVIDIA kernel module." echo "Please be sure you have exited X before attempting" echo "to install the NVIDIA_kernel rpm." echo exit 1 fi # delete the old NVdriver # XXX is there a better way to do this? if [ -z "$TARGET_KERNEL" ]; then export TARGET_KERNEL=`uname -r` fi if [ -d $RPM_ROOT/lib/modules/$TARGET_KERNEL/kernel ]; then INSTALLPATH=/lib/modules/$TARGET_KERNEL/kernel/drivers/video else INSTALLPATH=/lib/modules/$TARGET_KERNEL/video fi rm -f $INSTALLPATH/NVdriver function error { echo "$(basename $0): fatal error, $1 failed" exit 1 } modconf="" tmp=`mktemp -q /tmp/nvidia.XXXXXX` || error "mktemp" paths[0]=/etc/conf.modules paths[1]=/etc/modules.conf paths[2]=/etc/modutils/aliases for path in ${paths[@]}; do test -f $path && modconf=$path done if [ ! -z $modconf ]; then sed '/^alias.*\(NVdriver\|nvidia\)/d' < $modconf > $tmp if [ -c /dev/.devfsd ]; then echo "alias /dev/nvidia* nvidia" >> $tmp else echo "alias char-major-195 nvidia" >> $tmp fi mv $tmp $modconf test -x /sbin/update-modules && /sbin/update-modules else if [ -f /etc/rc.d/rc.modules ]; then sed '/.*\(NVdriver\|nvidia\).*/d' < /etc/rc.d/rc.modules > $tmp echo "/sbin/modprobe nvidia" >> $tmp mv $tmp /etc/rc.d/rc.modules fi fi if [ ! -c /dev/.devfsd ]; then for i in 0 1 2 3 4 5 6 7; do node="/dev/nvidia$i" rm -f $node mknod $node c 195 $i || error "mknod \"$node\"" chmod 0666 $node || error "chmod \"$node\"" done node="/dev/nvidiactl" rm -f $node mknod $node c 195 255 || error "mknod \"$node\"" chmod 0666 $node || error "chmod \"$node\"" fi # Add it to the module dependency list. /sbin/depmod -a && /sbin/modprobe nvidia # Check to see if the module is actually loaded if ! /sbin/lsmod | grep nvidia >& /dev/null ; then echo echo "Failed to install nvidia.o" echo exit 1 fi # It worked echo echo nvidia.o installed successfully echo exit 0 %preun if [ $1 = 0 ] ; then # # unload it quietly if already loaded.. # # Only unload if unused, otherwise this scriptlet fails and # RPM won't continue with uninstallation. So we also check # if the usage count is zero. # if [ x`/sbin/lsmod | grep nvidia | tr -s " " | cut -f 3 -d " "` == "x0" ]; then /sbin/rmmod nvidia >& /dev/null fi fi paths[0]=/etc/conf.modules paths[1]=/etc/modules.conf paths[2]=/etc/modutils/aliases modconf="" for path in ${paths[@]}; do test -f $path && modconf=$path done if [ "x$modconf" != "x" ] then tmpfile=`mktemp /dev/nvidia.XXXXXX` if [ $? -ne 0 -o ! -f $tmpfile ] then echo "mktemp failed; edit modprobe.conf by hand" exit 0 fi grep -v '^alias *\(char-major-195\|/dev/nvidia[0-9]\) *nvidia' \ $modconf >> "$tmpfile" cat "$tmpfile" >> $modconf rm -f "$tmpfile" [ -x /sbin/update-modules ] && /sbin/update-modules fi %files -f /tmp/files.lst %changelog * Mon Jul 14 2003 darkness - Updated for 4363 - Put devices in as %ghost files - Removed configuration from modprobe.conf on uninstallation * Thu Nov 07 2002 Joseph Kain - Suppress lsmod output * Fri Oct 11 2002 Andy Ritger - Check that the module is loaded before reporting success. * Fri Sep 06 2002 Gareth Hughes - Change NVdriver to nvidia.o everywhere. * Mon Nov 26 2001 Joseph Kain - Use %{_tmppath} instead of hardcoding /var/tmp * Tue Aug 24 2001 Joseph Kain - in preun check usage count of NVdriver before trying to unload. * Thu Aug 31 2000 Terence Ripperda - allow build scripts to specify a kernel version via TARGET_KERNEL variable otherwise fallback to `uname -r` - when searching for agpgart module, search in RPM_BUILD_ROOT, so we don't pick up an errant symbol on a build machine. * Tue Aug 15 2000 Mark Cooke - Change permissions on NVdriver to 444 to avoid symbol-stripping issues with versions of RPM after 3.0.4 - Add a test to make sure the NVdriver registers correctly. * Wed Aug 02 2000 Terence Ripperda - regress use of /proc/devices to get major number * Tue May 02 2000 Terence Ripperda - regress use of "make install" in post, no Makefile present * Fri Apr 27 2000 Nick Triantos - Use "NVdriver" and "install" targets on make - Remove BuildReq item from header, was causing build error * Thu Apr 27 2000 Gregory McLean - Cleaned out some redundant parts of the spec file. - Set the buildroot. - Made sure the preun gets called properly. - Added a %clean section to keep building machine tidy. - Set up logic for epoc builds if needed.