updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / kernel-netbook / PKGBUILD
blob981c76ffec57c1de1930170b142dd2109204845b
1 # Maintainer: Dieghen89 <dieghen89@gmail.com>
3 BFQ_IO_SCHEDULER="y"
4 TUX_ON_ICE="n"
5 BROADCOM_WL="n"
7 pkgname=kernel-netbook
8 true && pkgname=('kernel-netbook' 'kernel-netbook-headers')
9 makedepends=('dmidecode' 'xmlto' 'docbook-xsl' 'linux-firmware')
10 optdepends=('hibernate-script: tux on ice default script' 'tuxonice-userui: graphical interface for toi [AUR]')
11 _basekernel=3.1
12 pkgver=${_basekernel}.6
13 pkgrel=1
14 pkgdesc="Static kernel for netbooks with Intel Atom N270/N280/N450/N550 such as eeepc with the add-on of external firmware (broadcom-wl) and patchset (BFS + TOI + BFQ optional) - Only Intel GPU - Give more power to your netbook!"
15 options=('!strip')
16 arch=('i686')
17 license=('GPL2')
18 url=('http://code.google.com/p/kernel-netbook')
20 ####################################
21 md5sums=('8d43453f8159b2332ad410b19d86a931'
22          'b815dda0a05f7774a0ed0b705b8cfd4c'
23          '62d04d148b99f993ef575a71332593a9'
24          'a4c69095403ff44d5dfd8a935c3aca5a'
25          'e470805b4ef9d469a85b6e2f811ac337'
26          '61ca56c06bf197c0548ecd9fe01b2515'
27          '93e1b461374ae8b5147bba9887964cbe'
28          'afbd01926c57fc5b82ee6034dc9311e5'
29          'e8c333eaeac43f5c6a1d7b2f47af12e2'
30          '5974286ba3e9716bfbad83d3f4ee985a'
31          'a6f0377c814da594cffcacbc0785ec1a'
32          '3f79843b6b1a3f7e8041eb8ed86e4ff5'
33          '2bb172117ede96c14289f9f9bc34f58f'
34          'aee89fe7f034aea2f2ca95322774c1b5'
35          '9d3c56a4b999c8bfbd4018089a62f662'
36          '263725f20c0b9eb9c353040792d644e5'
37          'a50c9076012cb2dda49952dc6ec3e9c1'
38          '52d41fa61e80277ace2b994412a0c856'
39          'a9c018cb0b9caa90f03ee90b71a2c457'
40          '6587a43af34dbceee5f28c98ce5e069b')
41 ###################################
42 #  external drivers  and firmware #
43 ###################################
45 #Broadcom-wl:
46 broadcom_ver=5.100.82.112
47 broadcom="hybrid-portsrc_x86_32-v${broadcom_ver//./_}"
48 #BFS: - http://users.on.net/~ckolivas/kernel/ -
49 _ckpatchversion=2
50 _ckpatchname="patch-${_basekernel}.0-ck${_ckpatchversion}"
51 #BFQ: - http://algo.ing.unimo.it/people/paolo/disk_sched/ -
52 _bfqpatchversion="1"
53 _bfqpath="http://algo.ing.unimo.it/people/paolo/disk_sched/patches/3.1.0-v3r1"
54 #TuxOnIce:
55 _toipatch="current-tuxonice-for-3.0.patch.bz2"
57 ##### Sources #####
58 source=( #kernel sources and arch patchset
59         "http://www.kernel.org/pub/linux/kernel/v3.x/linux-${_basekernel}.tar.bz2"
60         "http://ftp.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.bz2"
61         #"ftp://ftp.archlinux.org/other/linux/patch-${pkgver}.gz"
62         ##external drivers:
63         "http://www.broadcom.com/docs/linux_sta/${broadcom}.tar.gz"
64         #"http://switch.dl.sourceforge.net/sourceforge/syntekdriver/stk11xx-$stk11xx_ver.tar.gz"
65         #BFS patch:
66         "http://ck.kolivas.org/patches/3.0/3.1/${_basekernel}.0-ck${_ckpatchversion}/${_ckpatchname}.bz2"
67         #BFQ patch:
68         "${_bfqpath}/0001-block-prepare-I-O-context-code-for-BFQ-v3r1-for-3.1.patch"
69         "${_bfqpath}/0002-block-cgroups-kconfig-build-bits-for-BFQ-v3r1-3.1.patch"
70         "${_bfqpath}/0003-block-introduce-the-BFQ-v3r1-I-O-sched-for-3.1.patch"
71         #TuxOnIce:
72         "http://tuxonice.net/files/${_toipatch}"
73         #Arch Logo
74         "logo_linux_mono.pbm"
75         "logo_linux_clut224.ppm"
76         "logo_linux_vga16.ppm"
77         #Others:
78         "linux3.patch"
79         "license.patch"
80         "semaphore.patch"
81         "change-default-console-loglevel.patch"
82         "i915-fix-ghost-tv-output.patch"
83         "i915-fix-incorrect-error-message.patch"
84         "usb-add-reset-resume-quirk-for-several-webcams.patch"
85         "kernel-netbook.preset"
86         "config")
87         
88 build() {
89   cd ${srcdir}/linux-$_basekernel
91   # Patching Time:
93   # minorversion patch:
94   patch -p1 -i "${srcdir}/patch-${pkgver}"
96   # Some chips detect a ghost TV output
97   # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
98   # Arch Linux bug report: FS#19234
99   #
100   # It is unclear why this patch wasn't merged upstream, it was accepted,
101   # then dropped because the reasoning was unclear. However, it is clearly
102   # needed.
103   patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
105   # In 3.1.0, a DRM_DEBUG message is falsely declared as DRM_ERROR. This
106   # worries users, as this message is displayed even at loglevel 4. Fix
107   # this.
108   patch -Np1 -i "${srcdir}/i915-fix-incorrect-error-message.patch"
110   # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
111   # remove this when a Kconfig knob is made available by upstream
112   # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
113   patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
114   
115   # replace tux logo with arch one
116   install -m644 ${srcdir}/logo_linux_clut224.ppm drivers/video/logo/
117   install -m644 ${srcdir}/logo_linux_mono.pbm drivers/video/logo/
118   install -m644 ${srcdir}/logo_linux_vga16.ppm drivers/video/logo/
120   # --> BFS
121   msg "Patching source with BFS patch:"
122   #Adjust localversion
123   sed -i -e "s/-ck${_ckpatchversion}//g" ${srcdir}/${_ckpatchname}
124   #patching time
125   patch -Np1 -i ${srcdir}/${_ckpatchname}
127   # --> TOI
128   if [ $TUX_ON_ICE = "y" ] ; then
129     msg "Patching source with TuxOnIce patch"
130     bzip2 -dck ${srcdir}/${_toipatch} \
131         | sed 's/printk(KERN_INFO "PM: Creating hibernation image:\\n/printk(KERN_INFO "PM: Creating hibernation image: \\n/' \
132         | patch -Np1 -F4 || { echo "Failed TOI"; return 1 ; }
133   fi
135   # --> BFQ
136   if [ $BFQ_IO_SCHEDULER = "y" ] ; then
137     msg "Patching source with BFQ patches"
138     for i in $(ls ${srcdir}/000*.patch); do
139       patch -Np1 -i $i
140     done
141   fi
144   ### Clean tree and copy ARCH config over
145   msg "Running make mrproper to clean source tree"
146   make mrproper
148   # copy config
149   cp ../config ./.config
151   make prepare
153   # make defconfig
154   # configure kernel    
155   # use menuconfig, if you want to change the configuration
156   make menuconfig
157   # make gconfig
158   # make nconfig
159   yes "" | make config
160   # build kernel
161   msg "Now starts something magic:"
162   make ${MAKEFLAGS} bzImage modules
165 package_kernel-netbook() {
166   pkgdesc='Static kernel for netbooks with Intel Atom N270/N280/N450/N550 such as eeepc with the add-on of external firmware (broadcom-wl) - Only Intel GPU - Give more power to your netbook!'
167   depends=('coreutils' 'module-init-tools')
168   install=kernel-netbook.install
169   optdepends=('crda: for wireless regulatory domain support' 
170               'linux-firmware: firmware for rt2860, tigon3, brcmsmac'
171               'hibernate-script: tux on ice default script'
172               'tuxonice-userui: graphical interface for toi [AUR]')
173   groups=(eee)
175   cd ${srcdir}/linux-$_basekernel
176   # install our modules
177   mkdir -p $pkgdir/{lib/modules,boot}
178   make INSTALL_MOD_PATH=$pkgdir modules_install
179   
180   # Get kernel version
181   _kernver="$(make kernelrelease)"
183   # remove build and source links
184   rm -r $pkgdir/lib/modules/$_kernver/{source,build}
185   
186   # remove the firmware directory
187   rm -rf ${pkgdir}/lib/firmware
189   # install the kernel
190   install -D -m644 ${srcdir}/linux-$_basekernel/System.map $pkgdir/boot/System.map-netbook
191   install -D -m644 ${srcdir}/linux-$_basekernel/arch/x86/boot/bzImage ${pkgdir}/boot/vmlinuz-netbook
192   install -D -m644 ${srcdir}/linux-$_basekernel/.config $pkgdir/boot/kconfig-netbook
194   # install preset file for mkinitcpio
195   #sed -i -e "s/ALL_kver=.*/ALL_kver=\'${_kernver}\'/g" ${srcdir}/${pkgname}.preset
196   install -m644 -D ${srcdir}/${pkgname}.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
198   # set correct depmod command for install
199   sed -i -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" $startdir/$pkgname.install
201 ##Extramodules dir support
202   _extramodules="extramodules-${_basekernel}${_kernelname:--netbook}"  
204 ##Section: Broadcom-wl
205   if [ "${BROADCOM_WL}" == "y" ] ; then
206     msg "Compiling broadcom-wl module:"
207     cd ${srcdir}/
208     #patching broadcom as broadcom-wl package on AUR
209     patch -p1 -i linux3.patch
210     patch -p1 -i license.patch
211     patch -p1 -i semaphore.patch
212     make -C ${srcdir}/linux-$_basekernel M=`pwd`
213     install -D -m 755 wl.ko ${pkgdir}/lib/modules/${_extramodules}/wl.ko
214   fi
216   # gzip -9 all modules to safe a lot of MB of space
217   find "$pkgdir" -name '*.ko' -exec gzip -9 {} \;
219   # make room for external modules
220   ln -s "../${_extramodules}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
221   # add real version for building modules and running depmod from post_install/upgrade
222   mkdir -p "${pkgdir}/lib/modules/${_extramodules}"
223   echo "${_kernver}" > "${pkgdir}/lib/modules/${_extramodules}/version"
226 package_kernel-netbook-headers() {
227   KARCH=x86
228   pkgdesc='Header files and scripts for building modules for kernel-netbook'
230   mkdir -p "${pkgdir}/lib/modules/${_kernver}"
232   cd "${pkgdir}/lib/modules/${_kernver}"
233   ln -sf ../../../usr/src/linux-${_kernver} build
235   cd "${srcdir}/linux-${_basekernel}"
236   install -D -m644 Makefile \
237     "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
238   install -D -m644 kernel/Makefile \
239     "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
240   install -D -m644 .config \
241     "${pkgdir}/usr/src/linux-${_kernver}/.config"
243   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
245   for i in acpi asm-generic config crypto drm generated linux math-emu \
246     media net pcmcia scsi sound trace video xen; do
247     cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
248   done
250   # copy arch includes for external modules
251   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
252   cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
254   # copy files necessary for later builds, like nvidia and vmware
255   cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
256   cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
258   # fix permissions on scripts dir
259   chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
260   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
262   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
264   cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
266   if [ "${CARCH}" = "i686" ]; then
267     cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
268   fi
270   cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
272   # add headers for lirc package
273   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
275   cp drivers/media/video/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
277   for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
278     mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
279     cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
280   done
282   # add docbook makefile
283   install -D -m644 Documentation/DocBook/Makefile \
284     "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
286   # add dm headers
287   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
288   cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
290   # add inotify.h
291   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
292   cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
294   # add wireless headers
295   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
296   cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
298   # add dvb headers for external modules
299   # in reference to:
300   # http://bugs.archlinux.org/task/9912
301   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
302   cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
303   # and...
304   # http://bugs.archlinux.org/task/11194
305   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
306   cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
308   # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
309   # in reference to:
310   # http://bugs.archlinux.org/task/13146
311   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
312   cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
313   cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
315   # add dvb headers
316   # in reference to:
317   # http://bugs.archlinux.org/task/20402
318   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
319   cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
320   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
321   cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
322   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
323   cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
325   # add xfs and shmem for aufs building
326   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
327   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
328   cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
330   # copy in Kconfig files
331   for i in `find . -name "Kconfig*"`; do
332     mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
333     cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
334   done
336   chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
337   find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
339   # strip scripts directory
340   find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
341     case "$(file -bi "${binary}")" in
342       *application/x-sharedlib*) # Libraries (.so)
343         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
344       *application/x-archive*) # Libraries (.a)
345         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
346       *application/x-executable*) # Binaries
347         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
348     esac
349   done
351   # remove unneeded architectures
352   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}