updated on Wed Jan 18 20:10:41 UTC 2012
[aur-mirror.git] / kernel26-pentium-m / PKGBUILD
blob5d5f3947c8a79fdf236ada96d0801d6e6c10403f
1 # Contributor: Tobias Powalowski <tpowa@archlinux.org>
2 # Contributor: Thomas Baechler <thomas@archlinux.org>
3 # Contributor: Lex Rivera aka x-demon <aur@x-demon.org>
4 # Contributor: Nuno Aniceto aka quarkup <nuno.aja@gmail.com>
6 # Maintainer: nem <nem@ikitten.co.uk>
8 # >> for more info, check the archlinux forum :: http://bbs.archlinux.org/viewtopic.php?id=87274
9 # >> this package can be found at the AUR     :: http://aur.archlinux.org/packages.php?ID=33104
11 # >> this package solves the intel cpufreq's module problem for pentium-m processors (sonoma, dothan and other models)
13 pkgbase='kernel26-pentium-m'
14 pkgname="${pkgbase}" # double $pkgname referencing to avoid split-pkg problems with AUR
16 # this is a split PKGBUILD
17 [[ "${pkgname}" == 'kernel26-pentium-m' ]] && pkgname=("${pkgbase}" "${pkgbase}-headers")
19 pkgdesc='The ZEN (or ARCH by choice) Linux Kernel and modules - optimized and patched for pentium-m'
20 _kernelname="${pkgname#kernel26}"
21 _kversion='2.6.38'
22  pkgver="${_kversion}.7" # add the subversion here, for example pkrver="${_kversion}.1"
23 _archver='1-ARCH'
24 _zenver='stable'
25 pkgrel='1'
27 arch=('i686')
28 license=('GPL2')
29 url='http://www.zen-kernel.org'
31 ## :: user variables :: #
32 _zen_patch='1'          # ZEN ( _zen_patch='1' )or ARCH ( _zen_patch='0' ) patchset
33 _speedstep_patch='1'    # the speedstep patch
34 _reconfig='1'           # needed on update only
36 # the kernel is ZEN by default!
37 # if you wish to use an ARCH one, be sure to 
38 # change the patchflag AND comment/uncomment according sources and md5s!
40 #########################
42 # for ARCH patch check :: http://projects.archlinux.org/linux-2.6-ARCH.git/
44 source=(#"ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-${_kversion}.tar.bz2" # Linux kernel
45 #"ftp://ftp.archlinux.org/other/kernel26/patch-${pkgver}-${_archver}.bz2" # ARCH patch
46 "http://git.zen-kernel.org/zen-stable/snapshot/zen-${_zenver}-${pkgver}.tar.bz2" # ZEN kernel
47 'speedstep-centrino.patch'
48 'config'
49 # standard config files for mkinitcpio ramdisk
50 "${pkgname}.preset"
51 "mkinitcpio-${pkgname}.conf")
53 md5sums=(#'7d471477bfa67546f902da62227fa976' # Linux Kernel
54 #'fb683c4eb412b6e7afac1c5ffe34c009' # ARCH patch
55 'd916844016d9b4c399db4b1e55c19bc8' # ZEN kernel
56 '17a7a0b2456f7a9512038580fc89485e' # speedstep patch
57 'f1624f8bb6ecfc55c6de998487cae397' # config (i686)
58 '7d07e5beb668f37c52fb39579ad2f2b0' # .preset and mkinitcpio
59 'ce00527a989ee68330c3cb8716fdd732')
61 # md5sum for speedstep patch v1 :: '9f385946263fe5c3c152907985a8d928'
63 build() {
64   KARCH=x86
65   cd "${srcdir}"
67   if [ "${_zen_patch}" == '1' ]; then
68     # ZEN kernel
69     msg2 "Using ZEN kernel (zen-${_zenver}-${pkgver})"
70     mv "${srcdir}/zen-${_zenver}-${pkgver}" "linux-${_kversion}"
71     cd "linux-${_kversion}"
72     
73   else
74     # ARCH patch
75     cd "${srcdir}/linux-${_kversion}"
77     msg2 "Applying the ARCH patch (patch-${pkgver}-${_archver})"
78     patch -Np1 -i "${srcdir}/patch-${pkgver}-${_archver}" #> /dev/null
79   fi
80   
81   # speedstep-centrino.patch
82   if [ "${_speedstep_patch}" == '1' ]; then 
83       msg2 'Applying the speedstep centrino patch'
84       patch -N "arch/${KARCH}/kernel/cpu/cpufreq/speedstep-centrino.c" \
85         -i "${srcdir}/speedstep-centrino.patch" > /dev/null
86   fi
87   
88   # remove extraversion
89   sed -i 's|^EXTRAVERSION = .*$|EXTRAVERSION =|g' Makefile
90   
91   msg 'Preparing the kernel config...'
92   msg2 'Cleaning the kernel tree..'
93   make mrproper
94   
95   # load configuration
96   cat ../config > ./.config
97   if [ "${_kernelname}" != "" ]; then
98     sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
99   fi
100   
101   if [ "${_reconfig}" == '1' ]; then
102         msg2 'Loading the kernel config...'
103         make prepare || return $?
104   fi
105   # :: (re)configure the kernel ::
106   msg2 'Launching config editor...'
107   make nconfig           # new CLI menu for configuration
108   #make menuconfig       # CLI menu for configuration
109   #make xconfig          # X-based configuration
110   #make oldconfig        # using old config from previous kernel version
111   #msg 'Stopping build...'; return 1
113   msg2 'Making kernel config...'
114   yes "" | make config > /dev/null || return $?
115   # build!
116   msg 'Building the kernel...'
117   msg2 'Building modules...'
118   make ${MAKEFLAGS} bzImage modules || return $?
121 package_kernel26-pentium-m-firmware() {
122   pkgdesc="The included firmware files of the Linux Kernel"
123   groups=('base')
124   msg 'Installing kernel firmware...'
126   cd ${srcdir}/linux-$_kversion
127   make firmware || return 1
128   make INSTALL_MOD_PATH=${pkgdir} firmware_install || return $?
131 package_kernel26-pentium-m-manpages() {
132   pkgdesc="Kernel hackers manual - Section 9 manpages that comes with the Linux kernel."
133   makedepends=('xmlto' 'docbook-xsl')
135   msg 'Installing kernel manpages...'
136   cd ${srcdir}/linux-${_kversion}
137   make mandocs || return 1
139   install -d ${pkgdir}/usr/share/man/man9/
140   install ${srcdir}/linux-${_kversion}/Documentation/DocBook/man/*.9.gz \
141           ${pkgdir}/usr/share/man/man9/
143   find ${pkgdir} -type f -exec chmod 644 {} \;
146 package_kernel26-pentium-m-docs() {
147   pkgdesc="Kernel hackers manual - HTML documentation that comes with the Linux kernel."
148   makedepends=('xmlto' 'docbook-xsl')
149   
150   msg 'Installing kernel docs...'
151   cd ${srcdir}/linux-${_kversion}
152   mkdir -p ${pkgdir}/usr/src/linux-${pkgver}${_kernelname}
153   mv Documentation ${pkgdir}/usr/src/linux-${pkgver}${_kernelname}
154   find ${pkgdir} -type f -exec chmod 444 {} \;
155   find ${pkgdir} -type d -exec chmod 755 {} \;
156   # remove a file already in kernel26 package
157   rm -f ${pkgdir}/usr/src/linux-${pkgver}${_kernelname}/Documentation/DocBook/Makefile
160 package_kernel26-pentium-m-headers() {
161   pkgdesc="Header files and scripts for building modules for ${pkgbase}"
162   msg 'Building kernel headers...'
163   mkdir -p ${pkgdir}/lib/modules/${_kernver}
164   cd ${pkgdir}/lib/modules/${_kernver}
165   ln -sf ../../../usr/src/linux-${_kernver} build
166   cd ${srcdir}/linux-$_kversion
167   install -D -m644 Makefile \
168     ${pkgdir}/usr/src/linux-${_kernver}/Makefile
169   install -D -m644 kernel/Makefile \
170     ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
171   install -D -m644 .config \
172     ${pkgdir}/usr/src/linux-${_kernver}/.config
173   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include
175   for i in acpi asm-generic config generated linux math-emu media net pcmcia scsi sound trace video xen; do
176     cp -a include/$i ${pkgdir}/usr/src/linux-${_kernver}/include/
177   done
179   # copy arch includes for external modules
180   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/x86
181   cp -a arch/x86/include ${pkgdir}/usr/src/linux-${_kernver}/arch/x86/
183   # copy files necessary for later builds, like nvidia and vmware
184   cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
185   cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}
186   # fix permissions on scripts dir
187   chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
188   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions
190   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel
192   cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
193   if [ "$CARCH" = "i686" ]; then
194     cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
195   fi
196   cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/
198   # add headers for lirc package
199   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video
200   cp drivers/media/video/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/
201   for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
202    mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
203    cp -a drivers/media/video/$i/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
204   done
205   # add docbook makefile
206   install -D -m644 Documentation/DocBook/Makefile \
207     ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
208   # add dm headers
209   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
210   cp drivers/md/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
211   # add inotify.h
212   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/linux
213   cp include/linux/inotify.h ${pkgdir}/usr/src/linux-${_kernver}/include/linux/
214   # add wireless headers
215   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
216   cp net/mac80211/*.h ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
217   # add dvb headers for external modules
218   # in reference to:
219   # http://bugs.archlinux.org/task/9912
220   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
221   cp drivers/media/dvb/dvb-core/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
222   # add dvb headers for external modules
223   # in reference to:
224   # http://bugs.archlinux.org/task/11194
225   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
226   cp include/config/dvb/*.h ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
227   # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
228   # in reference to:
229   # http://bugs.archlinux.org/task/13146
230   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
231   cp drivers/media/dvb/frontends/lgdt330x.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
232   cp drivers/media/video/msp3400-driver.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
233   # add xfs and shmem for aufs building
234   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs
235   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/mm
236   cp fs/xfs/xfs_sb.h ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h
237   # add headers vor virtualbox
238   # in reference to:
239   # http://bugs.archlinux.org/task/14568
240   cp -a include/drm $pkgdir/usr/src/linux-${_kernver}/include/
241   # add headers for broadcom wl
242   # in reference to:
243   # http://bugs.archlinux.org/task/14568
244   cp -a include/trace $pkgdir/usr/src/linux-${_kernver}/include/
245   # copy in Kconfig files
246   for i in `find . -name "Kconfig*"`; do 
247     mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
248     cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
249   done
251   chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
252   find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
253   # remove unneeded architectures
254   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}
255   
258 package_kernel26-pentium-m() {
259   pkgdesc='The Linux Kernel and modules - optimized and patched for pentium-m'
260   groups=('base')
261   backup=(etc/mkinitcpio.d/${pkgname}.preset)
262   depends=('coreutils' 'linux-firmware' 'module-init-tools' 'mkinitcpio>=0.5.20')
263   # pwc, ieee80211 and hostap-driver26 modules are included in kernel26 now
264   # nforce package support was abandoned by nvidia, kernel modules should cover everything now.
265   # kernel24 support is dropped since glibc24
266   replaces=('kernel24' 'kernel24-scsi' 'kernel26-scsi'
267             'alsa-driver' 'ieee80211' 'hostap-driver26'
268             'pwc' 'nforce' 'squashfs' 'unionfs' 'ivtv'
269             'zd1211' 'kvm-modules' 'iwlwifi' 'rt2x00-cvs'
270             'gspcav1' 'atl2' 'wlan-ng26' 'rt2500' 'nouveau-drm')
271   install="${pkgbase}.install"
272   options=(!strip)
273   optdepends=('crda: to set the correct wireless channels of your country')
275   KARCH=x86
276   cd ${srcdir}/linux-${_kversion}
277   # get kernel version
278   _kernver="$(make kernelrelease)"
279   mkdir -p ${pkgdir}/{lib/modules,boot}
281   msg2 'Installing modules...'
282   make INSTALL_MOD_PATH=${pkgdir} modules_install || return 1
283   cp System.map ${pkgdir}/boot/System.map26${_kernelname}
284   cp arch/$KARCH/boot/bzImage ${pkgdir}/boot/vmlinuz26${_kernelname}
285   #  # add vmlinux
286   install -m644 -D vmlinux ${pkgdir}/usr/src/linux-${_kernver}/vmlinux
288   # install fallback mkinitcpio.conf file and preset file for kernel
289   install -m644 -D ${srcdir}/${pkgname}.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset || return 1
290   # set correct depmod command for install
291   sed \
292     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
293     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
294     -i $startdir/kernel26-pentium-m.install
295   sed \
296     -e "s|source .*|source /etc/mkinitcpio.d/kernel26${_kernelname}.kver|g" \
297     -e "s|default_image=.*|default_image=\"/boot/${pkgname}.img\"|g" \
298     -e "s|fallback_image=.*|fallback_image=\"/boot/${pkgname}-fallback.img\"|g" \
299     -i ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
301   echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${pkgdir}/etc/mkinitcpio.d/${pkgname}.kver
302   # remove build and source links
303   rm -f ${pkgdir}/lib/modules/${_kernver}/{source,build}
304   # remove the firmware
305   rm -rf ${pkgdir}/lib/firmware