1 # Maintainer: Jonathan Liu <net147@gmail.com>
2 pkgname=kernel26-grsecurity
3 _kernelname=${pkgname#kernel26}
5 pkgver=${_basekernel}.46
8 _timestamp=201109150655
9 pkgdesc="The Linux Kernel and modules with grsecurity patchset"
10 arch=('i686' 'x86_64')
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
22 # standard config files for mkinitcpio ramdisk
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')
33 cd ${srcdir}/linux-${_basekernel}
34 if [ "$_basekernel" != "$pkgver" ]; then
35 # add latest kernel stable patch
36 patch -Np1 -i ${srcdir}/patch-$pkgver
39 # Add grsecurity patchset
40 patch -Np1 -i ${srcdir}/grsecurity-${_grsec}-${pkgver}-${_timestamp}.patch
42 sed -i 's|^EXTRAVERSION = .*$|EXTRAVERSION = |g' Makefile
44 if [ "$CARCH" = "x86_64" ]; then
45 cat ../config.x86_64 >./.config
47 cat ../config >./.config
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
59 # this is useful to configure the kernel
65 make ${MAKEFLAGS} bzImage modules
70 cd ${srcdir}/linux-${_basekernel}
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/
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/
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
115 # add docbook makefile
116 install -D -m644 Documentation/DocBook/Makefile \
117 ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
119 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
120 cp drivers/md/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
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
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
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
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/
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
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
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
178 -e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
179 -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
180 -i ${srcdir}/../${pkgname}.install
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: