#$Id: PKGBUILD 22488 2008-12-26 22:47:09Z tpowa $
#Maintainer: Tobias Powalowski <tpowa@archlinux.org>

pkgname=ndiswrapper
_kernver=2.6.28-LinHES
pkgver=1.53
pkgrel=6
pkgdesc="Module for NDIS (Windows Network Drivers) drivers supplied by vendors. For stock arch 2.6 kernel."
license=('GPL')
arch=(i686 x86_64)
url="http://ndiswrapper.sourceforge.net"
install="ndiswrapper.install"
depends=("ndiswrapper-utils=$pkgver" 'kernel26>=2.6.28' 'kernel26<2.6.29')
source=(http://downloads.sourceforge.net/sourceforge/ndiswrapper/ndiswrapper-$pkgver.tar.gz
        kernel-2.6.27.patch
	ndiswrapper-CVE-2008-4395.patch)
md5sums=('393c6e6ab0803963148e18538601cdec'
         'cd09562c4afdbd20a0237a5e6d976b31'
         'b35e548a0c9eb1395f6f7b434a258ddf')

build()
{
  cd $srcdir/ndiswrapper-$pkgver/driver
  patch -Np1 -i ../../kernel-2.6.27.patch || return 1
  patch -Np3 -i ../../ndiswrapper-CVE-2008-4395.patch || return 1
  make KVERS=$_kernver || return 1
  make DESTDIR=$pkgdir KVERS=$_kernver install || return 1
  rm $pkgdir/lib/modules/$_kernver/modules.* #wtf?

  sed -i -e "s/KERNEL_VERSION='.*'/KERNEL_VERSION='${_kernver}'/" $startdir/*.install
  # move it to correct kernel directory
  mkdir -p $pkgdir/lib/modules/$_kernver/kernel/drivers/net/wireless/ndiswrapper
  mv $pkgdir/lib/modules/$_kernver/misc/* $pkgdir/lib/modules/$_kernver/kernel/drivers/net/wireless/ndiswrapper/
  rm -r $pkgdir/lib/modules/$_kernver/misc/
}