Skip to content
PKGBUILD 8.03 KiB
Newer Older
# Maintainer: Sébastien Luttringer <seblu@aur.archlinux.org>
# Customized version of linux for seblu computers

Seblu's avatar
Seblu committed
kernver=3.13
Seblu's avatar
Seblu committed
kernsuf=-seblu
kernbld=0
Seblu's avatar
Seblu committed
pkgname=linux
Seblu's avatar
Seblu committed
pkgver=0
pkgrel=$(($kernbld+1))
Seblu's avatar
up  
Seblu committed
arch=('x86_64')
license=('GPL2')
url='http://www.kernel.org'
options=('!strip')
Seblu's avatar
Seblu committed
makedepends=('kmod' 'bc' 'git')
source=("git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git#tag=v$kernver"
        "config.$CARCH.$kernver")
md5sums=('SKIP' 'SKIP')
Seblu's avatar
Seblu committed
shopt -s nullglob
Seblu's avatar
up  
Seblu committed

Seblu's avatar
Seblu committed
prepare() {
Seblu's avatar
Seblu committed
  # apply patches
Seblu's avatar
Seblu committed
  cd linux
Seblu's avatar
Seblu committed
  for _f in "$srcdir"/*.patch; do
    [[ -r "$_f" ]] || continue
    msg2 "Applying patch: ${_f##*/}"
Seblu's avatar
Seblu committed
    patch -N -p1 -i "$_f"
Seblu's avatar
Seblu committed
  done

	# loading default config
  # use make localmodconfig to check .config is correct
  msg2 'Copying config'
Seblu's avatar
Seblu committed
  install "$srcdir/config.$CARCH.$kernver" .config
Seblu's avatar
Seblu committed

	# removing last dot if zero
	#sed -ri 's/^SUBLEVEL = 0$/SUBLEVEL =/' Makefile
	# force suffixe in config (must be the right!)
	msg2 'Setting kernel suffix'
Seblu's avatar
Seblu committed
	sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"$kernsuf\"|g" .config

  # remove git informations
  # these info will be used by make kernelrelease and produce wrong information
  # because ownership has fakely be changed by fakeroot during packaging.
  rm -rf .git
Seblu's avatar
Seblu committed
}

build() {
Seblu's avatar
Seblu committed
  msg2 "Building kernel version: $kernver$kernsuf"
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
  cd linux

  # define current build version
Seblu's avatar
Seblu committed
  echo "$kernbld" > .version

  # Preapre compilation
Seblu's avatar
Seblu committed
  msg2 'Preparing compilation'
Seblu's avatar
Seblu committed
  yes '' | make config &>/dev/null
  make prepare &>/dev/null

  # Compiling sources
  msg2 'Compiling'
Seblu's avatar
Seblu committed
  make bzImage modules
Seblu's avatar
Seblu committed
  cd linux
  # get real compiled kernel version
Seblu's avatar
Seblu committed
  kernrel=$(make kernelrelease)
  pkgdesc="The Linux Kernel, version $kernrel"
  pkgname="linux-$kernrel"
  pkgver="${kernrel%$kernsuf}"
  pkgver="${pkgver//-/_}"
  provides=("linux=$pkgver" "linux-headers=$pkgver")
  conflicts=("linux-seblu-$pkgver")
Seblu's avatar
Seblu committed
  depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio')
  install='install'

Seblu's avatar
Seblu committed
  msg2 "Packing kernel version: $kernrel"

  # installing modules
Seblu's avatar
up  
Seblu committed
  # disable DEPMOD because it fail due to poor hack in scripts/depmod.sh
  # and it's done by kernel-install in .install
Seblu's avatar
Seblu committed
  make INSTALL_MOD_PATH="$pkgdir/usr" DEPMOD=/bin/true modules_install
Seblu's avatar
up  
Seblu committed

  # install kernel and map
Seblu's avatar
Seblu committed
  install -D -m644 arch/x86/boot/bzImage "$pkgdir/usr/lib/kernel/vmlinuz-$kernrel"

  # remove build and source links
Seblu's avatar
Seblu committed
  rm -f "$pkgdir/usr/lib/modules/$kernrel"/{source,build}
Seblu's avatar
Seblu committed
  # remove the firmware
Seblu's avatar
up  
Seblu committed
  rm -rf "$pkgdir/usr/lib/firmware"
Seblu's avatar
Seblu committed

  # copy headers
  copy_headers
Seblu's avatar
Seblu committed

  # check rights
Seblu's avatar
Seblu committed
  chown -R root.root "$pkgdir/usr/src/linux-$kernrel"
  chmod -R u=rwX,go=rX "$pkgdir/usr/src/linux-$kernrel"

  # gzip -9 all modules to safe 100MB of space
  msg2 'Gzip modules harder'
Seblu's avatar
Seblu committed
  find "$pkgdir" -name '*.ko' -exec gzip -9 {} \;
Seblu's avatar
up  
Seblu committed
  # create build symlink into /usr/lib/modules
Seblu's avatar
Seblu committed
  ln -sf ../../../src/linux-$kernrel "$pkgdir/usr/lib/modules/$kernrel/build"
Seblu's avatar
up  
Seblu committed

  # Copy kernel config files
Seblu's avatar
Seblu committed
  cd "$srcdir"/linux
  install -D -m644 Makefile "$pkgdir/usr/src/linux-$kernrel/Makefile"
  install -D -m644 kernel/Makefile "$pkgdir/usr/src/linux-$kernrel/kernel/Makefile"
  install -D -m644 .config "$pkgdir/usr/src/linux-$kernrel/.config"
  for i in localversion*; do
Seblu's avatar
Seblu committed
    install -m644 "$i" "$pkgdir/usr/src/linux-$kernrel/$i"
Seblu's avatar
up  
Seblu committed

  # create include directory
Seblu's avatar
Seblu committed
  install -d "$pkgdir/usr/src/linux-$kernrel/include"
Seblu's avatar
up  
Seblu committed
  for i in acpi asm-generic config crypto drm generated linux math-emu \
    media net pcmcia scsi sound trace uapi video xen; do
Seblu's avatar
Seblu committed
    cp -a include/$i "$pkgdir/usr/src/linux-$kernrel/include/"
  done

  # copy arch includes for external modules
Seblu's avatar
Seblu committed
  install -d "$pkgdir/usr/src/linux-$kernrel/arch/x86"
  cp -a arch/x86/include "$pkgdir/usr/src/linux-$kernrel/arch/x86/"

  # copy files necessary for later builds, like nvidia and vmware
Seblu's avatar
Seblu committed
  cp Module.symvers "$pkgdir/usr/src/linux-$kernrel"
  cp -a scripts "$pkgdir/usr/src/linux-$kernrel"
Seblu's avatar
up  
Seblu committed

  # fix permissions on scripts dir
Seblu's avatar
Seblu committed
  chmod og-w -R "$pkgdir/usr/src/linux-$kernrel/scripts"
  install -d "$pkgdir/usr/src/linux-$kernrel/.tmp_versions"
Seblu's avatar
Seblu committed
  install -d "$pkgdir/usr/src/linux-$kernrel/arch/x86/kernel"
Seblu's avatar
Seblu committed
  cp arch/x86/Makefile "$pkgdir/usr/src/linux-$kernrel/arch/x86/"
  cp arch/x86/kernel/asm-offsets.s "$pkgdir/usr/src/linux-$kernrel/arch/x86/kernel/"

  # add headers for lirc package
Seblu's avatar
up  
Seblu committed
  # pci
  for i in bt8xx cx88 saa7134; do
Seblu's avatar
Seblu committed
    install -d "$pkgdir/usr/src/linux-$kernrel/drivers/media/pci/$i"
    cp -a drivers/media/pci/$i/*.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/pci/$i"
Seblu's avatar
up  
Seblu committed
  done
  # usb
  for i in cpia2 em28xx pwc sn9c102; do
Seblu's avatar
Seblu committed
    install -d "$pkgdir/usr/src/linux-$kernrel/drivers/media/usb/$i"
    cp -a drivers/media/usb/$i/*.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/usb/$i"
Seblu's avatar
up  
Seblu committed
  done
  # i2c
Seblu's avatar
Seblu committed
  mkdir -p "$pkgdir/usr/src/linux-$kernrel/drivers/media/i2c"
  cp drivers/media/i2c/*.h  "$pkgdir/usr/src/linux-$kernrel/drivers/media/i2c/"
Seblu's avatar
up  
Seblu committed
  for i in cx25840; do
Seblu's avatar
Seblu committed
    install -d "$pkgdir/usr/src/linux-$kernrel/drivers/media/i2c/$i"
    cp -a drivers/media/i2c/$i/*.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/i2c/$i"
Seblu's avatar
up  
Seblu committed

  # add dm headers
Seblu's avatar
Seblu committed
  install -d "$pkgdir/usr/src/linux-$kernrel/drivers/md"
  cp drivers/md/*.h  "$pkgdir/usr/src/linux-$kernrel/drivers/md"
Seblu's avatar
up  
Seblu committed

  # add inotify.h
Seblu's avatar
Seblu committed
  install -d "$pkgdir/usr/src/linux-$kernrel/include/linux"
  cp include/linux/inotify.h "$pkgdir/usr/src/linux-$kernrel/include/linux/"
Seblu's avatar
up  
Seblu committed

  # add wireless headers
Seblu's avatar
Seblu committed
  install -d "$pkgdir/usr/src/linux-$kernrel/net/mac80211/"
  cp net/mac80211/*.h "$pkgdir/usr/src/linux-$kernrel/net/mac80211/"
Seblu's avatar
up  
Seblu committed

  # add dvb headers for external modules
  # in reference to:
  # http://bugs.archlinux.org/task/9912
Seblu's avatar
Seblu committed
  install -d "$pkgdir/usr/src/linux-$kernrel/drivers/media/dvb-core"
  cp drivers/media/dvb-core/*.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/dvb-core/"
Seblu's avatar
up  
Seblu committed

  # add dvb headers for external modules
  # in reference to:
  # http://bugs.archlinux.org/task/11194
Seblu's avatar
Seblu committed
  install -d "$pkgdir/usr/src/linux-$kernrel/include/config/dvb/"
  cp include/config/dvb/*.h "$pkgdir/usr/src/linux-$kernrel/include/config/dvb/"
Seblu's avatar
up  
Seblu committed

  # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
  # in reference to:
  # http://bugs.archlinux.org/task/13146
Seblu's avatar
Seblu committed
  install -d "$pkgdir/usr/src/linux-$kernrel/drivers/media/dvb-frontends/"
  cp drivers/media/dvb-frontends/lgdt330x.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/dvb-frontends/"
  cp drivers/media/i2c/msp3400-driver.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/i2c/"
Seblu's avatar
up  
Seblu committed

Seblu's avatar
Seblu committed
  # add dvb headers
  # in reference to:
  # http://bugs.archlinux.org/task/20402
Seblu's avatar
Seblu committed
  install -d "$pkgdir/usr/src/linux-$kernrel/drivers/media/usb/dvb-usb"
  cp drivers/media/usb/dvb-usb/*.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/usb/dvb-usb/"
  install -d "$pkgdir/usr/src/linux-$kernrel/drivers/media/dvb-frontends"
  cp drivers/media/dvb-frontends/*.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/dvb-frontends/"
  install -d "$pkgdir/usr/src/linux-$kernrel/drivers/media/tuners"
  cp drivers/media/tuners/*.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/tuners/"
Seblu's avatar
up  
Seblu committed

  # add xfs and shmem for aufs building
Seblu's avatar
Seblu committed
  install -d "$pkgdir/usr/src/linux-$kernrel/fs/xfs"
  install -d "$pkgdir/usr/src/linux-$kernrel/mm"
  cp fs/xfs/xfs_sb.h "$pkgdir/usr/src/linux-$kernrel/fs/xfs/xfs_sb.h"
Seblu's avatar
up  
Seblu committed

  # copy in Kconfig files
  for i in $(find . -name "Kconfig*"); do
Seblu's avatar
Seblu committed
    install -d "$pkgdir/usr/src/linux-$kernrel"/$(echo $i | sed 's|/Kconfig.*||')
    cp "$i" "$pkgdir/usr/src/linux-$kernrel/$i"
Seblu's avatar
up  
Seblu committed
  # strip scripts directory
Seblu's avatar
Seblu committed
  find "$pkgdir/usr/src/linux-$kernrel/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
Seblu's avatar
up  
Seblu committed
    case "$(file -bi "$binary")" in
      *application/x-sharedlib*) # Libraries (.so)
        $_nice strip $STRIP_SHARED "$binary";;
Seblu's avatar
up  
Seblu committed
      *application/x-archive*) # Libraries (.a)
        $_nice strip $STRIP_STATIC "$binary";;
Seblu's avatar
up  
Seblu committed
      *application/x-executable*) # Binaries
        $_nice strip $STRIP_BINARIES "$binary";;
Seblu's avatar
up  
Seblu committed
    esac
  done

  # remove unneeded architectures
Seblu's avatar
Seblu committed
  rm -rf "${pkgdir}"/usr/src/"linux-$kernrel"/arch/{alpha,arm,arm26,avr32,blackfin,c6x,cris,frv,h8300,hexagon,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,openrisc,parisc,powerpc,ppc,s390,score,sh,sh64,sparc,sparc64,tile,unicore32,um,v850,xtensa}
}

# vim:set ts=2 sw=2 ft=sh et: