updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / kernel26-vserver-grsec / PKGBUILD
blob08931b2a5d27d300fea01c99987267481e8edd63
1 # Contributor: Jonathan Liu <net147@gmail.com>
2 pkgname=kernel26-vserver-grsec
3 _kernelname=${pkgname#kernel26}
4 _basekernel=2.6.32
5 pkgver=${_basekernel}.28
6 pkgrel=5
7 _patchname="patch-${pkgver}-1-ARCH"
8 _vserver=2.3.0.36.29.6
9 _grsec=2.2.1
10 _timestamp=20110215
11 pkgdesc="The Linux Kernel and modules with Linux-VServer and grsecurity patchset"
12 arch=('i686' 'x86_64')
13 license=('GPL2')
14 groups=('base')
15 url="http://linux-vserver.org/"
16 backup=("etc/mkinitcpio.d/${pkgname}.preset")
17 depends=('coreutils' 'linux-firmware' 'module-init-tools' 'mkinitcpio')
18 install=$pkgname.install
19 source=(ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$_basekernel.tar.bz2
20         ftp://ftp.kernel.org/pub/linux/kernel/v2.6/longterm/v2.6.32/patch-$pkgver.bz2
21         libata-alignment.patch
22         xen-hypervisor.patch
23         undef.patch
24         http://people.linux-vserver.org/~harry/patch-${pkgver}-vs${_vserver}-grsec${_grsec}-${_timestamp}.diff
25         # the main kernel config files
26         config config.x86_64
27         # standard config files for mkinitcpio ramdisk
28         $pkgname.preset)
29 optdepends=('crda: to set the correct wireless channels of your country')
30 md5sums=('260551284ac224c3a43c4adac7df4879'
31          'fc8c36b4638d8384a5d26a50413a1d11'
32          '30851deee235a7486bd408cbe8eb2d71'
33          '4b53693735fa0e0f7142985739780e10'
34          'dc30610b3e531e7ffa6b4cd121950215'
35          'a4975629aff5f6175c90434eb60ccf3a'
36          '953f53206c55eb7d80b281d4b7b52953'
37          '1c15c7d757168876a919ad2c4e779812'
38          '232661e2e74d134e30d0f3a854403d5a')
40 build() {
41   KARCH=x86
43   cd ${srcdir}/linux-${_basekernel}
44    if [ "$_basekernel" != "$pkgver" ]; then
45      # add latest kernel stable patch
46      patch -Np1 -i ${srcdir}/patch-$pkgver
47    fi
49   # Add libata ATAPI alignment patch
50   patch -Np1 -i ${srcdir}/libata-alignment.patch
51   # Add Hypervisor compiling error patch
52   patch -Np1 -i ${srcdir}/xen-hypervisor.patch
53   # Add Linux-VServer patches and grsecurity patchset
54   patch -Np1 -i ${srcdir}/patch-${pkgver}-vs${_vserver}-grsec${_grsec}-${_timestamp}.diff
55   # Add GCC compile patch
56   patch -Np1 -i ${srcdir}/undef.patch
57   # Strip extra version
58   sed -i 's|^EXTRAVERSION = .*$|EXTRAVERSION = |g' Makefile
60   if [ "$CARCH" = "x86_64" ]; then
61     cat ../config.x86_64 >./.config
62   else
63     cat ../config >./.config
64   fi
65   # Strip local version
66   echo "-grsec" >./localversion-grsec
67   # Add Linux-VServer to local version
68   echo "-vs" >./localversion-vserver
69   # get kernel version  
70   make prepare
71   _kernver="$(make kernelrelease)"
72   # load configuration
73   # Configure the kernel. Replace the line below with one of your choice.
74   #make menuconfig # CLI menu for configuration
75   #make xconfig # X-based configuration
76   #make oldconfig # using old config from previous kernel version
77   # ... or manually edit .config
78   ####################
79   # stop here
80   # this is useful to configure the kernel
81   #msg "Stopping build"
82   #return 1
83   ####################
84   yes "" | make config
85   # build!
86   make bzImage modules
87   mkdir -p ${pkgdir}/{lib/modules,boot}
88   make INSTALL_MOD_PATH=${pkgdir} modules_install
89   cp System.map ${pkgdir}/boot/System.map26${_kernelname}
90   cp arch/$KARCH/boot/bzImage ${pkgdir}/boot/vmlinuz26${_kernelname}
91   install -D -m644 Makefile \
92     ${pkgdir}/usr/src/linux-${_kernver}/Makefile
93   install -D -m644 kernel/Makefile \
94     ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
95   install -D -m644 .config \
96     ${pkgdir}/usr/src/linux-${_kernver}/.config
97   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include
99   for i in acpi asm-{generic,x86} config linux math-emu media net pcmcia scsi sound trace video; do
100     cp -a include/$i ${pkgdir}/usr/src/linux-${_kernver}/include/
101   done
103   # copy arch includes for external modules
104   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/x86
105   cp -a arch/x86/include ${pkgdir}/usr/src/linux-${_kernver}/arch/x86/
107   # copy files necessary for later builds, like nvidia and vmware
108   cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
109   cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}
110   # fix permissions on scripts dir
111   chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
112   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions
114   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel
116   cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
117   if [ "$CARCH" = "i686" ]; then
118     cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
119   fi
120   cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/
122   # add headers for lirc package
123   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video
124   cp drivers/media/video/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/
125   for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 usbvideo zc0301; do
126    mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
127    cp -a drivers/media/video/$i/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
128   done
129   # add docbook makefile
130   install -D -m644 Documentation/DocBook/Makefile \
131     ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
132   # add dm headers
133   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
134   cp drivers/md/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
135   # add inotify.h
136   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/linux
137   cp include/linux/inotify.h ${pkgdir}/usr/src/linux-${_kernver}/include/linux/
138   # add wireless headers
139   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
140   cp net/mac80211/*.h ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
141   # add dvb headers for external modules
142   # in reference to:
143   # http://bugs.archlinux.org/task/9912
144   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
145   cp drivers/media/dvb/dvb-core/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
146   # add dvb headers for external modules
147   # in reference to:
148   # http://bugs.archlinux.org/task/11194
149   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
150   cp include/config/dvb/*.h ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
151   # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
152   # in reference to:
153   # http://bugs.archlinux.org/task/13146
154   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
155   cp drivers/media/dvb/frontends/lgdt330x.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
156   cp drivers/media/video/msp3400-driver.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
157   # add dvb headers
158   # in reference to:
159   # http://bugs.archlinux.org/task/20402
160   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb
161   cp drivers/media/dvb/dvb-usb/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/
162   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends
163   cp drivers/media/dvb/frontends/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
164   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners
165   cp drivers/media/common/tuners/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/
166   # add xfs and shmem for aufs building
167   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs
168   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/mm
169   cp fs/xfs/xfs_sb.h ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h
170   # add headers vor virtualbox
171   # in reference to:
172   # http://bugs.archlinux.org/task/14568
173   cp -a include/drm $pkgdir/usr/src/linux-${_kernver}/include/
174   # add headers for broadcom wl
175   # in reference to:
176   # http://bugs.archlinux.org/task/14568
177   cp -a include/trace $pkgdir/usr/src/linux-${_kernver}/include/
178   # add headers for crypto modules
179   # in reference to:
180   # http://bugs.archlinux.org/task/22081
181   cp -a include/crypto $pkgdir/usr/src/linux-${_kernver}/include/
182   # add vmlinux
183   cp vmlinux ${pkgdir}/usr/src/linux-${_kernver}
184   # copy in Kconfig files
185   for i in `find . -name "Kconfig*"`; do 
186     mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
187     cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
188   done
189   # copy local version
190   cp localversion-* $pkgdir/usr/src/linux-${_kernver}
192   cd ${pkgdir}/usr/src/linux-${_kernver}/include && ln -s asm-$KARCH asm
193   # add header for aufs2-util
194   cp -a ${srcdir}/linux-$_basekernel/include/asm-generic/bitsperlong.h ${pkgdir}/usr/src/linux-${_kernver}/include/asm/
196   chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
197   find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
198   cd ${pkgdir}/lib/modules/${_kernver} && \
199     (rm -f source build; ln -sf ../../../usr/src/linux-${_kernver} build)
200   # install fallback mkinitcpio.conf file and preset file for kernel
201   install -m644 -D ${srcdir}/${pkgname}.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
202   # set correct depmod command for install
203   sed \
204     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
205     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
206     -i ${srcdir}/../${pkgname}.install
207   sed \
208     -e "s|source .*|source /etc/mkinitcpio.d/kernel26${_kernelname}.kver|g" \
209     -e "s|default_image=.*|default_image=\"/boot/${pkgname}.img\"|g" \
210     -e "s|fallback_image=.*|fallback_image=\"/boot/${pkgname}-fallback.img\"|g" \
211     -i ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
213   echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${pkgdir}/etc/mkinitcpio.d/${pkgname}.kver
214   # remove unneeded architectures
215   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}
216   # remove the firmware
217   rm -rf ${pkgdir}/lib/firmware
220 # vim:set ts=2 sw=2 et: