updated on Tue Jan 17 08:05:08 UTC 2012
[aur-mirror.git] / kernel26-grsecurity / PKGBUILD
blob0c25a2a374ba3c44b4c8825d0d119d704d661598
1 # Maintainer: Jonathan Liu <net147@gmail.com>
2 pkgname=kernel26-grsecurity
3 _kernelname=${pkgname#kernel26}
4 _basekernel=2.6.32
5 pkgver=${_basekernel}.46
6 pkgrel=2
7 _grsec=2.2.2
8 _timestamp=201109150655
9 pkgdesc="The Linux Kernel and modules with grsecurity patchset"
10 arch=('i686' 'x86_64')
11 license=('GPL2')
12 groups=('base')
13 url="http://grsecurity.net/"
14 backup=("etc/mkinitcpio.d/${pkgname}.preset")
15 depends=('coreutils' 'linux-firmware' 'module-init-tools' 'mkinitcpio')
16 install=$pkgname.install
17 source=(ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-${_basekernel}.tar.bz2
18         ftp://ftp.kernel.org/pub/linux/kernel/v2.6/longterm/v2.6.32/patch-$pkgver.bz2
19         http://grsecurity.net/stable/grsecurity-${_grsec}-${pkgver}-${_timestamp}.patch
20         # the main kernel config files
21         config config.x86_64
22         # standard config files for mkinitcpio ramdisk
23         $pkgname.preset)
24 optdepends=('crda: to set the correct wireless channels of your country')
25 md5sums=('260551284ac224c3a43c4adac7df4879'
26          '1b630a58fd4f179e9f255331f147ed33'
27          '3e3db2573f69c53ccd86c9eb36435e12'
28          '9e135f50079f327da7eec61607930ff7'
29          'd2f605ed2b303242236f278ee18ea302'
30          'a1292e10959fe0d33d45b2433edf37a3')
32 build() {
33   cd ${srcdir}/linux-${_basekernel}
34   if [ "$_basekernel" != "$pkgver" ]; then
35     # add latest kernel stable patch
36     patch -Np1 -i ${srcdir}/patch-$pkgver
37   fi
39   # Add grsecurity patchset
40   patch -Np1 -i ${srcdir}/grsecurity-${_grsec}-${pkgver}-${_timestamp}.patch
41   # Strip extra version
42   sed -i 's|^EXTRAVERSION = .*$|EXTRAVERSION = |g' Makefile
44   if [ "$CARCH" = "x86_64" ]; then
45     cat ../config.x86_64 >./.config
46   else
47     cat ../config >./.config
48   fi
49   # get kernel version  
50   make prepare
51   # load configuration
52   # Configure the kernel. Replace the line below with one of your choice.
53   #make menuconfig # CLI menu for configuration
54   #make xconfig # X-based configuration
55   #make oldconfig # using old config from previous kernel version
56   # ... or manually edit .config
57   ####################
58   # stop here
59   # this is useful to configure the kernel
60   #msg "Stopping build"
61   #return 1
62   ####################
63   yes "" | make config
64   # build!
65   make ${MAKEFLAGS} bzImage modules
68 package() {
69   KARCH=x86
70   cd ${srcdir}/linux-${_basekernel}
71   # get kernel version  
72   _kernver="$(make kernelrelease)"
73   mkdir -p ${pkgdir}/{lib/modules,boot}
74   make INSTALL_MOD_PATH=${pkgdir} modules_install
75   cp System.map ${pkgdir}/boot/System.map26${_kernelname}
76   cp arch/$KARCH/boot/bzImage ${pkgdir}/boot/vmlinuz26${_kernelname}
77   install -D -m644 Makefile \
78     ${pkgdir}/usr/src/linux-${_kernver}/Makefile
79   install -D -m644 kernel/Makefile \
80     ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
81   install -D -m644 .config \
82     ${pkgdir}/usr/src/linux-${_kernver}/.config
83   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include
85   for i in acpi asm-{generic,x86} config crypto drm linux math-emu media net pcmcia scsi sound trace video; do
86     cp -a include/$i ${pkgdir}/usr/src/linux-${_kernver}/include/
87   done
89   # copy arch includes for external modules
90   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/x86
91   cp -a arch/x86/include ${pkgdir}/usr/src/linux-${_kernver}/arch/x86/
93   # copy files necessary for later builds, like nvidia and vmware
94   cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
95   cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}
96   # fix permissions on scripts dir
97   chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
98   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions
100   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel
102   cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
103   if [ "$CARCH" = "i686" ]; then
104     cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
105   fi
106   cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/
108   # add headers for lirc package
109   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video
110   cp drivers/media/video/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/
111   for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 usbvideo zc0301; do
112    mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
113    cp -a drivers/media/video/$i/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
114   done
115   # add docbook makefile
116   install -D -m644 Documentation/DocBook/Makefile \
117     ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
118   # add dm headers
119   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
120   cp drivers/md/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
121   # add inotify.h
122   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/linux
123   cp include/linux/inotify.h ${pkgdir}/usr/src/linux-${_kernver}/include/linux/
124   # add wireless headers
125   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
126   cp net/mac80211/*.h ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
127   # add dvb headers for external modules
128   # in reference to:
129   # http://bugs.archlinux.org/task/9912
130   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
131   cp drivers/media/dvb/dvb-core/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
132   # add dvb headers for external modules
133   # in reference to:
134   # http://bugs.archlinux.org/task/11194
135   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
136   cp include/config/dvb/*.h ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
137   # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
138   # in reference to:
139   # http://bugs.archlinux.org/task/13146
140   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
141   cp drivers/media/dvb/frontends/lgdt330x.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
142   cp drivers/media/video/msp3400-driver.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
143   # add dvb headers
144   # in reference to:
145   # http://bugs.archlinux.org/task/20402
146   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb
147   cp drivers/media/dvb/dvb-usb/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/
148   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends
149   cp drivers/media/dvb/frontends/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
150   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners
151   cp drivers/media/common/tuners/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/
152   # add xfs and shmem for aufs building
153   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs
154   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/mm
155   cp fs/xfs/xfs_sb.h ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h
156   # add vmlinux
157   cp vmlinux ${pkgdir}/usr/src/linux-${_kernver}
158   # copy in Kconfig files
159   for i in `find . -name "Kconfig*"`; do 
160     mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
161     cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
162   done
163   # copy local version
164   cp localversion-* $pkgdir/usr/src/linux-${_kernver}
166   cd ${pkgdir}/usr/src/linux-${_kernver}/include && ln -s asm-$KARCH asm
167   # add header for aufs2-util
168   cp -a ${srcdir}/linux-$_basekernel/include/asm-generic/bitsperlong.h ${pkgdir}/usr/src/linux-${_kernver}/include/asm/
170   chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
171   find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
172   cd ${pkgdir}/lib/modules/${_kernver} && \
173     (rm -f source build; ln -sf ../../../usr/src/linux-${_kernver} build)
174   # install fallback mkinitcpio.conf file and preset file for kernel
175   install -m644 -D ${srcdir}/${pkgname}.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
176   # set correct depmod command for install
177   sed \
178     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
179     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
180     -i ${srcdir}/../${pkgname}.install
181   sed \
182     -e "s|source .*|source /etc/mkinitcpio.d/kernel26${_kernelname}.kver|g" \
183     -e "s|default_image=.*|default_image=\"/boot/${pkgname}.img\"|g" \
184     -e "s|fallback_image=.*|fallback_image=\"/boot/${pkgname}-fallback.img\"|g" \
185     -i ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
187   echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${pkgdir}/etc/mkinitcpio.d/${pkgname}.kver
188   # remove unneeded architectures
189   rm -rf ${pkgdir}/usr/src/linux-${_kernver}/arch/{alpha,arm,arm26,avr32,blackfin,cris,frv,h8300,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,parisc,powerpc,ppc,s390,sh,sh64,sparc,sparc64,um,v850,xtensa}
190   # remove the firmware
191   rm -rf ${pkgdir}/lib/firmware
192   # gzip -9 all modules to save space
193   find "$pkgdir" -name '*.ko' -exec gzip -9 {} \;
196 # vim:set ts=2 sw=2 et: