updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / linux-pax / PKGBUILD
blobbbb75b11f77bf983dbe6f98e9a4287ac8b0c1a62
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=test5
11 pkgver=${_basekernel}.1
12 pkgrel=1
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=('linux-pax-flags' '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         i915-gpu-finish.patch
37         config
38         config.x86_64
39         $pkgname.install
40         $pkgname.preset
42 md5sums=(
43         090eb3dae0f520f7770f85193e931ad3
44         5af10730e2a535948b6a293db499ed71
45         9d3c56a4b999c8bfbd4018089a62f662
46         342071f852564e1ad03b79271a90b1a5
47         e787ef4bc66e2d9a7883eaece7a915b9
48         327e5eb7b07b474e0433cc0cca6f96a6
49         f1397e95d7f6e9f4180b8b16bbc49d52
50         42a358c6b1b83c391bde6babcaec8555
51         5d29c2995ffa1ac918dd6b269ec09ecc
54 build() {
55   cd $srcdir/linux-$pkgver
57   # fix FS#27883
58   # drm/i915: Only clear the GPU domains upon a successful finish
59   patch -Np1 -i "${srcdir}/i915-gpu-finish.patch"
61   # Some chips detect a ghost TV output
62   # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
63   # Arch Linux bug report: FS#19234
64   #
65   # It is unclear why this patch wasn't merged upstream, it was accepted,
66   # then dropped because the reasoning was unclear. However, it is clearly
67   # needed.
68   patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
70   # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
71   # remove this when a Kconfig knob is made available by upstream
72   # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
73   patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
75   # Add PaX patches
76   patch -Np1 -i $srcdir/pax-linux-$pkgver-$_paxver.patch
78   if [ "${CARCH}" = "x86_64" ]; then
79     cat "${srcdir}/config.x86_64" > ./.config
80   else
81     cat "${srcdir}/config" > ./.config
82   fi
84   if [ "${_kernelname}" != "" ]; then
85     sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
86   fi
88   # remove the sublevel from Makefile
89   # this ensures our kernel version is always 3.X-ARCH
90   # this way, minor kernel updates will not break external modules
91   # we need to change this soon, see FS#16702
92   sed -ri 's|^(SUBLEVEL =).*|\1|' Makefile
94   # get kernel version
95   [ "$_menuconfig" = "0" ] && {
96     make prepare
97   }
99   # load configuration
100   # Configure the kernel. Replace the line below with one of your choice.
101   [ "$_menuconfig" = "1" ] && {
102     make menuconfig # CLI menu for configuration
103     #make nconfig # new CLI menu for configuration
104     #make xconfig # X-based configuration
105     #make oldconfig # using old config from previous kernel version
106     # ... or manually edit .config
107   }
109   ####################
110   # stop here
111   # this is useful to configure the kernel
112   [ "$_menuconfig" = "1" ] && {
113     msg "Stopping build"
114     return 1
115   }
116   ####################
118   yes "" | make config
120   # build!
121   make ${MAKEFLAGS} bzImage modules
124 package() {
125   cd $srcdir/linux-$pkgver
127   KARCH=x86
129   # get kernel version
130   _kernver="$(make kernelrelease)"
132   mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
133   make INSTALL_MOD_PATH="${pkgdir}" modules_install
134   cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"
136   # add vmlinux
137   install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
139   # install fallback mkinitcpio.conf file and preset file for kernel
140   install -D -m644 "${srcdir}/${pkgname}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
142   # set correct depmod command for install
143   sed \
144     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
145     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
146     -i "${startdir}/${pkgname}.install"
147   sed \
148     -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|g" \
149     -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|g" \
150     -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|g" \
151     -i "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
153   # remove build and source links
154   rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
155   # remove the firmware
156   rm -rf "${pkgdir}/lib/firmware"
157   # gzip -9 all modules to safe 100MB of space
158   find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
159   # make room for external modules
160   ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
161   # add real version for building modules and running depmod from post_install/upgrade
162   mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}"
163   echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}/version"