Olivier Blin <[EMAIL PROTECTED]> writes:

>> If I could get alsa-0.9.8 and nVidia drivers, I'd keep running this
>> baby. Very responsive compared 2.4.22-21 on my 1.3G 9.2 cooker
>> machine!
>
> I'll try to build the nvidia drivers later today. If I succeed, i'll
> write a small howto :)

Added to the Nvidia 2.6 patch, I had to add one more patch to be able
to build on a different running kernel, and somme specs changes IIRC.

#
# Spec file for NVIDIA kernel module.
#
# $Header: //sw/OEM/nvr40_linux_4490/drivers/resman/NVIDIA_kernel.spec#1 $
#
%define RELEASE 4496
%define CUSTOM_RELEASE 4496
%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
Patch:          NVIDIA_kernel-1.0-4496-2.6.diff
Patch1:         NVIDIA_kernel-1.0-4496-kerver.patch
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}

%patch -p1 -z .26
%patch1 -p1 -z .kerver


%build
    # don't exit immediately when something bad happens.
    set +e

    ln -s Makefile.kbuild Makefile
    # 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
    IGNORE_CC_MISMATCH=1 make install
    install -m 0444 nvidia.ko $RPM_BUILD_ROOT/$INSTALLPATH
    echo "%attr(444 root root) " $INSTALLPATH/nvidia.ko > /tmp/files.lst
    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 [EMAIL PROTECTED]; do
        test -f $path && modconf=$path
    done

    if [ ! -z $modconf ]; then
        # Initialize the permissions on $tmp so that we don't change the
        # permissions of $modconf when we mv it into place
        cp -p $modconf $tmp
        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 -f $tmp $modconf
        test -x /sbin/update-modules && /sbin/update-modules
    else
        if [ -f /etc/rc.d/rc.modules ]; then
            # Initialize the permissions on $tmp so that we don't change the
            # permissions of /etc/rc.d/rc.modules when we mv it into place
            cp -p /etc/rc.d/rc.modules $tmp
            sed '/.*\(NVdriver\|nvidia\).*/d' < /etc/rc.d/rc.modules > $tmp
            echo "/sbin/modprobe nvidia" >> $tmp
            mv -f $tmp /etc/rc.d/rc.modules
        fi
    fi

    if [ ! -c /dev/.devfsd ]; then
        for i in 0 1 2 3; 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.ko"
        echo
        exit 1
    fi

    # It worked
    echo
    echo nvidia.ko 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

%files -f /tmp/files.lst

%changelog
* Sun Jan 05 2003 Joseph Kain <[EMAIL PROTECTED]>
- Correctly preserve permissions on /etc/rc.d/rc.modules.
- Pass "-f" option to mv.
- Fix typos.

* Fri Jan 03 2003 Joseph Kain <[EMAIL PROTECTED]>
- Preserve permissions on modules conf file.

* Thu Nov 07 2002 Joseph Kain <[EMAIL PROTECTED]>
- Suppress lsmod output

* Fri Oct 11 2002 Andy Ritger <[EMAIL PROTECTED]>
- Check that the module is loaded before reporting success.

* Fri Sep 06 2002 Gareth Hughes <[EMAIL PROTECTED]>
- Change NVdriver to nvidia.o everywhere.

* Mon Nov 26 2001 Joseph Kain <[EMAIL PROTECTED]>
- Use %{_tmppath} instead of hardcoding /var/tmp

* Tue Aug 24 2001 Joseph Kain <[EMAIL PROTECTED]>
- in preun check usage count of NVdriver before trying to unload.

* Thu Aug 31 2000 Terence Ripperda <[EMAIL PROTECTED]>
- 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 <[EMAIL PROTECTED]>
- 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 <[EMAIL PROTECTED]>
- regress use of /proc/devices to get major number

* Tue May 02 2000 Terence Ripperda <[EMAIL PROTECTED]>
- regress use of "make install" in post, no Makefile present

* Fri Apr 27 2000 Nick Triantos <[EMAIL PROTECTED]>
- Use "NVdriver" and "install" targets on make
- Remove BuildReq item from header, was causing build error

* Thu Apr 27 2000 Gregory McLean <[EMAIL PROTECTED]>
- 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.

--- NVIDIA_kernel-1.0-4496/Makefile.kbuild.kerver	2003-09-07 08:26:42.923982911 +0200
+++ NVIDIA_kernel-1.0-4496/Makefile.kbuild	2003-09-07 08:27:18.675144332 +0200
@@ -71,11 +71,11 @@
 ifdef KERNDIR
   KERNEL_SOURCES := $(KERNDIR)
   KERNEL_HEADERS := -I$(KERNEL_SOURCES)/include
-  MODULE_ROOT    := /lib/modules/$(shell uname -r)/kernel/drivers # XXX
+  MODULE_ROOT    := /lib/modules/$(TARGET_KERNEL)/kernel/drivers # XXX
 else
-  KERNEL_SOURCES := /lib/modules/$(shell uname -r)/build
+  KERNEL_SOURCES := /lib/modules/$(TARGET_KERNEL)/build
   KERNEL_HEADERS := -I$(KERNEL_SOURCES)/include
-  MODULE_ROOT    := /lib/modules/$(shell uname -r)/kernel/drivers
+  MODULE_ROOT    := /lib/modules/$(TARGET_KERNEL)/kernel/drivers
 endif
 
 #

-- 
Warly

Reply via email to