You are not logged in.

#1 2009-04-28 01:08:50

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,356

Is it possible to compile NVIDIA for multiple kernels simultaneously?

Hi all,

First, the reference is http://wiki.archlinux.org/index.php/NVI … tom_kernel, as well as a small discussion I started at http://aur.archlinux.org/packages.php?ID=20410.

Basically, currently the nvidia-beta (and I'm sure the rest of the nvidia scripts) use `uname -r` to obtain the current kernel name, which is then used for the rest of the PKGBUILD. Its relatively trivial to alter that to the name of whichever kernel, meaning there's no problem compiling nvidia.ko for kernel26-ice from within kernel26 itself, and to alter the name of the package so that your nvidia-beta package does not need to be over-written (you then have two nvidia.ko, each for their own kernel.

My question is, is it possible for a single PKGBUILD to compile nvidia.ko for all kernels currently installed (probably through looking at either /lib/modules or /usr/src)? This would mean only one maintainer is needed for nvidia-beta or nvidia-17xx or whichever series, and the same PKGBUILD could be used on any system, even those with multiple kernels.

I'm not very familiar with the limitations of PKGBUILDs, or the rules governing what they may or may not do (for example, accessing and checking the machine itself outside the fakeroot?), so this may be nonsense, if so feel free to point it out. Another idea would be for a simple bash script to create as many PKGBUILDs as required, based on the most recent nvidia-beta PKGBUILD, simply sed-replacing uname -r with the appropriate kernel names and modifying the PKG name.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#2 2009-04-30 13:46:17

ProgDan
Member
From: Prague, Czech Republic
Registered: 2007-10-04
Posts: 441
Website

Re: Is it possible to compile NVIDIA for multiple kernels simultaneously?

Hi,
it's not difficult to do but I DO NOT recommend to do it (see my notes below the code).

PKGBUILD

pkgname=nvidia-beta 
pkgver=185.18.04
pkgrel=1
pkgdesc="NVIDIA beta drivers for kernel26." 
arch=('i686' 'x86_64') 
[ "$CARCH" = "i686" ] && ARCH=x86 && NV=0 
[ "$CARCH" = "x86_64" ] && ARCH=x86_64 && NV=0 
provides=(nvidia=${pkgver})
url="http://www.nvidia.com/" 
depends=(kernel26 nvidia-utils-beta) 
conflicts=('nvidia-96xx' 'nvidia-71xx' 'nvidia-legacy') 
license=('custom') 
install=('nvidia.install')
source=(ftp://download.nvidia.com/XFree86/Linux-$ARCH/${pkgver}/NVIDIA-Linux-$ARCH-${pkgver}-pkg${NV}.run) 
md5sums=('95b67e6f17cc54d36ae2743df76c9f6d')
[ "$CARCH" = "x86_64" ] && md5sums=('33967a6d452c562bb8af02b0734ebf22')

build()
{
  # Read list of installed kernels
  KERNELS=`ls -1 /lib/modules`
  
  # Extract the nvidia drivers
  cd $startdir/src/
  sh NVIDIA-Linux-${ARCH}-${pkgver}-pkg${NV}.run --extract-only
  cd NVIDIA-Linux-${ARCH}-${pkgver}-pkg${NV}
  cd usr/src/nv
  ln -s Makefile.kbuild Makefile
  
   # Now build modules for each kernel
  for KERNEL in $KERNELS; do
      echo "Building for ${KERNEL}"
 
         # Compile the module
        make SYSSRC=/lib/modules/${KERNEL}/build module  || return 1
  
      # Install kernel module
      mkdir -p $startdir/pkg/lib/modules/${KERNEL}/kernel/drivers/video/
      install -m644 nvidia.ko $startdir/pkg/lib/modules/${KERNEL}/kernel/drivers/video/ || return 1
      
       # Clean
      make clean || return 1
  done;
}

nvidia.install

# arg 1:  the new package version
post_install() {
  KERNELS=`ls -1 /lib/modules`
  for KERNEL in $KERNELS; do
    depmod -v $KERNEL  > /dev/null 2>&1
  done;
}
# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
  post_install $1
  rmmod nvidia || echo 'In order to use the new nvidia module, exit Xserver and unload it manually.'
}
# arg 1:  the old package version
post_remove() {
  KERNELS=`ls -1 /lib/modules`
  for KERNEL in $KERNELS; do
    depmod -v $KERNEL > /dev/null 2>&1     
  done;
}

op=$1
shift
$op $*

PS: I haven't test it because I don't use multiple kernels

But be aware of possible problems. Some modifications may influence kernel functionalities, so once you compile a driver for kernel26-xyz on kernel26-zyx the module may not work on kernel26-xyz or may cause unexpected issues.
You also should not (you possibly even won't be able to) build module for different release version (eg. build for 2.6.28 on 2.6.29) due changes in kernel headers.
I'm also not sure if it is safe to generate module dependencies for another kernel then you are currently running.

As you can see above, it is not problem to make such a PKGBUILD, but it also brings too many problems and it's too dangerous that it is better to stay at current model "module package for each kernel". So if you want to you may try to use this PKGBUILD, but I strictly warn everyone else that it may cause more harm then use so don't blame me if something goes wrong. You were warned cool.

Last edited by ProgDan (2009-04-30 13:48:06)

Offline

Board footer

Powered by FluxBB