Newer
Older
# Maintainer: Sébastien Luttringer <seblu@aur.archlinux.org>
# Customized version of linux for seblu computers
shopt -s nullglob
# WARNING:
# Always use 3 dot versionning here! (e.g: 3.11.0, not 3.11)
# Althought tarball release are not nammed with the third number, the kernel
# built version contains it. Thus, modules and identifiers are with the last 0.
kernelver=3.11-rc5
license=('GPL2')
url='http://www.kernel.org'
options=('!strip')
source=("config.$CARCH.$kernelver")
# major kernel version (first number)
kernelmaj=${kernelver%%.*}
# base url for kernel related tarballs (full, patch, etc)
kernelurl="https://www.kernel.org/pub/linux/kernel/v$kernelmaj.x"
# here we have a Linus kernel
if [[ $kernelver =~ $kernelmaj\.[[:digit:]]+\.0 ]]; then
# kernel base is the version of the full kernel tarball to download
kernelbase=${kernelver%.0}
# here we have a Linus rc kernel
elif [[ $kernelver =~ -rc ]]; then
kernelbase=$kernelmaj.$((${kernelbase#*.} - 1))
patchurl="testing/patch-$kernelver.xz"
# here we have stable kernel schema (probably Greg)
elif [[ $kernelver =~ $kernelmaj\.[[:digit:]]+\.[[:digit:]]+ ]]; then
# kernel base is the version of the full kernel tarball to download
# we are in error, probably the last version number is not here
error "Invalid kernel number: $kernelver, read warning before \$kernelver!"
exit 2
# adding base kernel to sources
# we doesn't use .sign as kernel.org provide only .sign for raw tarball (no xz)
# makepkg doesn't handle this correctly
source+=("$kernelurl/linux-$kernelbase.tar.xz")
# adding patch to sources
if [[ -n $patchurl ]]; then
source+=("$kernelurl/$patchurl")
md5sums+=('SKIP')
fi
# we can now guess real package name. Useful to avoid overwrite
# small hack to avoid makepkg to check checksum
# Because kernel compilation is heavy IO process we are nice people
_nice='nice -n 19'
if [[ -e patch-$kernelver ]]; then
ln -sf patch-$kernelver 00-patch-$kernelver.patch
msg2 "Applying patch: ${_f##*/}"
$_nice patch -N -p1 -i "$_f"
done
# loading default config
# use make localmodconfig to check .config is correct
msg2 'Copying config'
install "$srcdir/config.$CARCH.$kernelver" .config
# removing last dot if zero
#sed -ri 's/^SUBLEVEL = 0$/SUBLEVEL =/' Makefile
# force suffixe in config (must be the right!)
sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"$kernelsuf\"|g" .config
}
build() {
msg2 "Kernel version: $kernelver"
msg2 "Kernel suffix: $kernelsuf"
cd linux-$kernelbase
# define current build version
yes '' | $_nice make config &>/dev/null
$_nice make prepare &>/dev/null
msg2 'Compiling'
$_nice make bzImage modules
# get real compiled kernel version
compver=$(make kernelrelease)
pkgdesc="The Linux Kernel, version $compver"
provides=("linux=$kernelver" "linux-headers=$kernelver" "linux-docs=$kernelver")
depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio')
sed -ri "s/pkgname=.*/pkgname='$pkgname'/" "$startdir/$install"
$_nice make INSTALL_MOD_PATH="$pkgdir/usr" DEPMOD=/bin/true modules_install
$_nice depmod -b "$pkgdir/usr" -- "$compver"
$_nice install -D -m644 arch/x86/boot/bzImage "$pkgdir/boot/vmlinuz-$compver"
# install mkinitcpio preset file for kernel
install -d "$pkgdir/etc/mkinitcpio.d/"
cat > "$pkgdir/etc/mkinitcpio.d/$pkgname.preset" << EOF
# mkinitcpio preset file for $pkgname
ALL_config="/etc/mkinitcpio.conf"
PRESETS=('default' 'fallback')
#default_config="/etc/mkinitcpio.conf"
#default_options=""
#fallback_config="/etc/mkinitcpio.conf"
fallback_options="-S autodetect"
EOF
# setup current version package (used by install script)
install -d "$pkgdir/usr/share/$pkgname"
cat > "$pkgdir/usr/share/$pkgname/info" << EOF
KERNEL_NAME=$pkgname
KERNEL_VERSION=$kernelver
KERNEL_SUFFIX=$kernelsuf
KERNEL_BUILD=$compver
# remove build and source links
# remove the firmware (avoiding conflict with 2.6
# copy documentation
install -d "$pkgdir/usr/src/linux-$compver"
$_nice cp -r Documentation "$pkgdir/usr/src/linux-$compver"
# copy headers
copy_headers
# check rights
chown -R root.root "$pkgdir/usr/src/linux-$compver"
chmod -R u=rwX,go=rX "$pkgdir/usr/src/linux-$compver"
# gzip -9 all modules to safe 100MB of space
msg2 'Gzip modules harder'
$_nice find "$pkgdir" -name '*.ko' -exec gzip -9 {} \;
ln -sf ../../../src/linux-$compver "$pkgdir/usr/lib/modules/$compver/build"
install -D -m644 Makefile "$pkgdir/usr/src/linux-$compver/Makefile"
install -D -m644 kernel/Makefile "$pkgdir/usr/src/linux-$compver/kernel/Makefile"
install -D -m644 .config "$pkgdir/usr/src/linux-$compver/.config"
for i in localversion*; do
install -m644 "$i" "$pkgdir/usr/src/linux-$compver/$i"
done
install -d "$pkgdir/usr/src/linux-$compver/include"
for i in acpi asm-generic config crypto drm generated linux math-emu \
media net pcmcia scsi sound trace uapi video xen; do
cp -a include/$i "$pkgdir/usr/src/linux-$compver/include/"
done
# copy arch includes for external modules
install -d "$pkgdir/usr/src/linux-$compver/arch/x86"
cp -a arch/x86/include "$pkgdir/usr/src/linux-$compver/arch/x86/"
# copy files necessary for later builds, like nvidia and vmware
cp Module.symvers "$pkgdir/usr/src/linux-$compver"
cp -a scripts "$pkgdir/usr/src/linux-$compver"
# fix permissions on scripts dir
chmod og-w -R "$pkgdir/usr/src/linux-$compver/scripts"
install -d "$pkgdir/usr/src/linux-$compver/.tmp_versions"
install -d "$pkgdir/usr/src/linux-$compver/arch/x86/kernel"
cp arch/x86/Makefile "$pkgdir/usr/src/linux-$compver/arch/x86/"
cp arch/x86/kernel/asm-offsets.s "$pkgdir/usr/src/linux-$compver/arch/x86/kernel/"
# add headers for lirc package
# pci
for i in bt8xx cx88 saa7134; do
install -d "$pkgdir/usr/src/linux-$compver/drivers/media/pci/$i"
cp -a drivers/media/pci/$i/*.h "$pkgdir/usr/src/linux-$compver/drivers/media/pci/$i"
done
# usb
for i in cpia2 em28xx pwc sn9c102; do
install -d "$pkgdir/usr/src/linux-$compver/drivers/media/usb/$i"
cp -a drivers/media/usb/$i/*.h "$pkgdir/usr/src/linux-$compver/drivers/media/usb/$i"
done
# i2c
mkdir -p "$pkgdir/usr/src/linux-$compver/drivers/media/i2c"
cp drivers/media/i2c/*.h "$pkgdir/usr/src/linux-$compver/drivers/media/i2c/"
for i in cx25840; do
install -d "$pkgdir/usr/src/linux-$compver/drivers/media/i2c/$i"
cp -a drivers/media/i2c/$i/*.h "$pkgdir/usr/src/linux-$compver/drivers/media/i2c/$i"
# add docbook makefile
install -D -m644 Documentation/DocBook/Makefile \
"$pkgdir/usr/src/linux-$compver/Documentation/DocBook/Makefile"
# add dm headers
install -d "$pkgdir/usr/src/linux-$compver/drivers/md"
cp drivers/md/*.h "$pkgdir/usr/src/linux-$compver/drivers/md"
# add inotify.h
install -d "$pkgdir/usr/src/linux-$compver/include/linux"
cp include/linux/inotify.h "$pkgdir/usr/src/linux-$compver/include/linux/"
# add wireless headers
install -d "$pkgdir/usr/src/linux-$compver/net/mac80211/"
cp net/mac80211/*.h "$pkgdir/usr/src/linux-$compver/net/mac80211/"
# add dvb headers for external modules
# in reference to:
# http://bugs.archlinux.org/task/9912
install -d "$pkgdir/usr/src/linux-$compver/drivers/media/dvb-core"
cp drivers/media/dvb-core/*.h "$pkgdir/usr/src/linux-$compver/drivers/media/dvb-core/"
# add dvb headers for external modules
# in reference to:
# http://bugs.archlinux.org/task/11194
install -d "$pkgdir/usr/src/linux-$compver/include/config/dvb/"
cp include/config/dvb/*.h "$pkgdir/usr/src/linux-$compver/include/config/dvb/"
# add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
# in reference to:
# http://bugs.archlinux.org/task/13146
install -d "$pkgdir/usr/src/linux-$compver/drivers/media/dvb-frontends/"
cp drivers/media/dvb-frontends/lgdt330x.h "$pkgdir/usr/src/linux-$compver/drivers/media/dvb-frontends/"
cp drivers/media/i2c/msp3400-driver.h "$pkgdir/usr/src/linux-$compver/drivers/media/i2c/"
# in reference to:
# http://bugs.archlinux.org/task/20402
install -d "$pkgdir/usr/src/linux-$compver/drivers/media/usb/dvb-usb"
cp drivers/media/usb/dvb-usb/*.h "$pkgdir/usr/src/linux-$compver/drivers/media/usb/dvb-usb/"
install -d "$pkgdir/usr/src/linux-$compver/drivers/media/dvb-frontends"
cp drivers/media/dvb-frontends/*.h "$pkgdir/usr/src/linux-$compver/drivers/media/dvb-frontends/"
install -d "$pkgdir/usr/src/linux-$compver/drivers/media/tuners"
cp drivers/media/tuners/*.h "$pkgdir/usr/src/linux-$compver/drivers/media/tuners/"
# add xfs and shmem for aufs building
install -d "$pkgdir/usr/src/linux-$compver/fs/xfs"
install -d "$pkgdir/usr/src/linux-$compver/mm"
cp fs/xfs/xfs_sb.h "$pkgdir/usr/src/linux-$compver/fs/xfs/xfs_sb.h"
for i in $(find . -name "Kconfig*"); do
install -d "$pkgdir/usr/src/linux-$compver"/$(echo $i | sed 's|/Kconfig.*||')
cp "$i" "$pkgdir/usr/src/linux-$compver/$i"
done
# strip scripts directory
find "$pkgdir/usr/src/linux-$compver/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
case "$(file -bi "$binary")" in
*application/x-sharedlib*) # Libraries (.so)
$_nice strip $STRIP_SHARED "$binary";;
$_nice strip $STRIP_STATIC "$binary";;
$_nice strip $STRIP_BINARIES "$binary";;
# remove unneeded architectures
$_nice rm -rf "${pkgdir}"/usr/src/linux-${_kernver}/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: