updated on Wed Jan 25 20:08:56 UTC 2012
[aur-mirror.git] / linux-pax / PKGBUILD
blob5e4092819118820b2a0a7a2741e0a9315c6adb5f
1 # Original kernel maintainers:
2 #       Tobias Powalowski <tpowa@archlinux.org>
3 #       Thomas Baechler <thomas@archlinux.org>
4 # Contributors:
5 #       henning mueller <henning@orgizm.net>
7 pkgname=linux-pax
8 _kernelname=${pkgname#linux}
9 _basekernel=3.2
10 _paxver=test3
11 pkgver=${_basekernel}
12 pkgrel=4
13 arch=(i686 x86_64)
14 url="http://www.kernel.org/"
15 license=(GPL2)
16 options=(!strip)
18 pkgdesc="The Linux Kernel and modules with PaX patches"
19 groups=('base')
20 depends=('paxctl' 'coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
21 optdepends=('crda: to set the correct wireless channels of your country')
22 provides=('kernel26-pax')
23 conflicts=('kernel26-pax')
24 replaces=('kernel26-pax')
25 backup=("etc/mkinitcpio.d/${pkgname}.preset")
26 install=$pkgname.install
28 _menuconfig=0
29 [ ! -z $MENUCONFIG ] && _menuconfig=1
31 source=(
32         ftp://ftp.kernel.org/pub/linux/kernel/v3.0/linux-$pkgver.tar.bz2
33         http://grsecurity.net/test/pax-linux-$pkgver-$_paxver.patch
34         change-default-console-loglevel.patch
35         i915-fix-ghost-tv-output.patch
36         config
37         config.x86_64
38         $pkgname.install
39         $pkgname.preset
40         $pkgname-fix-permissions
42 md5sums=(
43         7ceb61f87c097fc17509844b71268935
44         b9abf5eabb8f502d3b82910798e80bfa
45         9d3c56a4b999c8bfbd4018089a62f662
46         342071f852564e1ad03b79271a90b1a5
47         523dc8857f80520a833e30542708b5ae
48         f1397e95d7f6e9f4180b8b16bbc49d52
49         c792439f6f6c0dcedd1c71af63673d30
50         5d29c2995ffa1ac918dd6b269ec09ecc
51         85bb4c7bf39ee39265546b21d6170bc9
54 build() {
55   cd $srcdir/linux-$pkgver
57   # Some chips detect a ghost TV output
58   # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
59   # Arch Linux bug report: FS#19234
60   #
61   # It is unclear why this patch wasn't merged upstream, it was accepted,
62   # then dropped because the reasoning was unclear. However, it is clearly
63   # needed.
64   patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
66   # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
67   # remove this when a Kconfig knob is made available by upstream
68   # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
69   patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
71   # Add PaX patches
72   patch -Np1 -i $srcdir/pax-linux-$pkgver-$_paxver.patch
74   if [ "${CARCH}" = "x86_64" ]; then
75     cat "${srcdir}/config.x86_64" > ./.config
76   else
77     cat "${srcdir}/config" > ./.config
78   fi
80   if [ "${_kernelname}" != "" ]; then
81     sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
82   fi
84   # remove the sublevel from Makefile
85   # this ensures our kernel version is always 3.X-ARCH
86   # this way, minor kernel updates will not break external modules
87   # we need to change this soon, see FS#16702
88   sed -ri 's|^(SUBLEVEL =).*|\1|' Makefile
90   # get kernel version
91   [ "$_menuconfig" = "0" ] && {
92     make prepare
93   }
95   # load configuration
96   # Configure the kernel. Replace the line below with one of your choice.
97   [ "$_menuconfig" = "1" ] && {
98     make menuconfig # CLI menu for configuration
99     #make nconfig # new CLI menu for configuration
100     #make xconfig # X-based configuration
101     #make oldconfig # using old config from previous kernel version
102     # ... or manually edit .config
103   }
105   ####################
106   # stop here
107   # this is useful to configure the kernel
108   [ "$_menuconfig" = "1" ] && {
109     msg "Stopping build"
110     return 1
111   }
112   ####################
114   yes "" | make config
116   # build!
117   make ${MAKEFLAGS} bzImage modules
120 package() {
121   cd $srcdir/linux-$pkgver
123   KARCH=x86
125   # get kernel version
126   _kernver="$(make kernelrelease)"
128   mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
129   make INSTALL_MOD_PATH="${pkgdir}" modules_install
130   cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"
132   # add vmlinux
133   install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
135   # install fallback mkinitcpio.conf file and preset file for kernel
136   install -D -m644 "${srcdir}/${pkgname}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
138   # set correct depmod command for install
139   sed \
140     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
141     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
142     -i "${startdir}/${pkgname}.install"
143   sed \
144     -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|g" \
145     -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|g" \
146     -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|g" \
147     -i "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
149   # remove build and source links
150   rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
151   # remove the firmware
152   rm -rf "${pkgdir}/lib/firmware"
153   # gzip -9 all modules to safe 100MB of space
154   find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
155   # make room for external modules
156   ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
157   # add real version for building modules and running depmod from post_install/upgrade
158   mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}"
159   echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}/version"
161   install -D -m755 $srcdir/$pkgname-fix-permissions \
162           $pkgdir/usr/bin/$pkgname-fix-permissions