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