updated on Thu Jan 19 12:17:07 UTC 2012
[aur-mirror.git] / kernel-netbook-ice / PKGBUILD
blob8c771a3a7a70882e87f54086e10e1b0c6a594335
1 # Maintainer: Balor <dieghen89@gmail.com>
3 BFQ_IO_SCHEDULER="y"
4 TUX_ON_ICE="y"
6 pkgname=kernel-netbook-ice
7 true && pkgname=('kernel-netbook-ice' 'kernel-netbook-headers-ice')
8 depends=('coreutils' 'module-init-tools')
9 makedepends=('dmidecode' 'xmlto' 'docbook-xsl')
10 optdepends=('hibernate-script: tux on ice default script' 'tuxonice-userui: graphical interface for toi [AUR]')
11 _basekernel=2.6.38
12 pkgver=${_basekernel}.8
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 ####################################
22 ###################################
23 #  external drivers  and firmware #
24 ###################################
26 #Arch patchset
27 patchname=patch-${pkgver}-1-ARCH
28 #Broadcom-wl:
29 broadcom_ver=5.100.82.38
30 broadcom="hybrid-portsrc_x86_32-v${broadcom_ver//./_}"
31 #Stk11xx:
32 #stk11xx_ver="2.1.0"
33 #stk11xx="stk11xx-$stk11xx_ver"
34 #BFS: - http://users.on.net/~ckolivas/kernel/ -
35 _ckpatchversion=3
36 _ckpatchname="patch-${_basekernel}-ck${_ckpatchversion}"
37 #BFQ: - http://algo.ing.unimo.it/people/paolo/disk_sched/ -
38 _bfqpatchversion="2"
39 _bfqpath="http://algo.ing.unimo.it/people/paolo/disk_sched/patches/2.6.38"
40 #TuxOnIce:
41 _toipatch="tuxonice-3.2-for-2.6.38.patch.bz2"
43 ##### Sources #####
44 source=( #kernel sources and arch patchset
45         "ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-${_basekernel}.tar.bz2"
46         "ftp://ftp.archlinux.org/other/kernel26/${patchname}.bz2"
47         #external drivers:
48         "http://www.broadcom.com/docs/linux_sta/${broadcom}.tar.gz"
49         #"http://switch.dl.sourceforge.net/sourceforge/syntekdriver/stk11xx-$stk11xx_ver.tar.gz"
50         #BFS patch:
51         "http://www.kernel.org/pub/linux/kernel/people/ck/patches/2.6/${_basekernel}/${_basekernel}-ck${_ckpatchversion}/${_ckpatchname}.bz2"
52         "http://ck.kolivas.org/patches/bfs/bfs400-bfs401.patch"
53         #BFQ patch:
54         "${_bfqpath}/0001-block-prepare-I-O-context-code-for-BFQ-v2-for-2.6.38.patch"
55         "${_bfqpath}/0002-block-cgroups-kconfig-build-bits-for-BFQ-v2-2.6.38.patch"
56         "${_bfqpath}/0003-block-introduce-the-BFQ-v2-I-O-sched-for-2.6.38.patch"
57         #TuxOnIce:
58         http://www.tuxonice.net/files/${_toipatch}
59         #Others:
60         "config"
61         "license.patch"
62         "semaphore.patch"
63         "mutex-sema.patch"
64         "kernel-netbook-ice.preset")
65         
66 build() {
68   cd ${srcdir}/linux-$_basekernel
70   # patching the kernel with:
71   # --> arch patchset
72   msg "Patching source with Arch Official Patchset:"
73   patch -Np1 -i ${srcdir}/$patchname
75   # --> BFS
76   msg "Patching source with BFS patch:"
77   #Adjust localversion
78   sed -i -e "s/-ck${_ckpatchversion}//g" ${srcdir}/${_ckpatchname}
79   #patching time
80   patch -Np1 -i ${srcdir}/${_ckpatchname}
81   msg "Patching source with bfs363-test2 patch"
82   msg "For details, see: http://ck-hack.blogspot.com/2011/03/bfs-and-optimising-global-scheduler-for.html"
83   sleep 2s
84   patch -Np1 -i ${srcdir}/bfs400-bfs401.patch
86   # --> TOI
87   if [ $TUX_ON_ICE = "y" ] ; then
88     msg "Patching source with TuxOnIce patch"
89     bzip2 -dck ${srcdir}/${_toipatch} \
90                 | sed 's/printk(KERN_INFO "PM: Creating hibernation image:\\n/printk(KERN_INFO "PM: Creating hibernation image: \\n/' \
91                 | patch -Np1 -F4 || return 1
92   fi
93   # copy config
94   cp ../config ./.config
95   # --> BFQ
96   if [ $BFQ_IO_SCHEDULER = "y" ] ; then
97     msg "Patching source with BFQ patches"
98     for i in $(ls ${srcdir}/000*.patch); do
99       patch -Np1 -i $i
100     done
101     #sed -i s'/CONFIG_DEFAULT_CFQ=y/# CONFIG_DEFAULT_CFQ is not set/g' ${srcdir}/linux-$_basekernel/.config
102     #sed -i s'/\# CONFIG_DEFAULT_BFQ is not set/CONFIG_DEFAULT_BFQ=y/g' ${srcdir}/linux-$_basekernel/.config
103     #sed -i s'/CONFIG_DEFAULT_IOSCHED=*/CONFIG_DEFAULT_IOSCHED="bfq"/g' ${srcdir}/linux-$_basekernel/.config
104   fi
108   make prepare
110   # make defconfig
111   # configure kernel    
112   # use menuconfig, if you want to change the configuration
113   make menuconfig
114   # make gconfig
115   yes "" | make config
116   # build kernel
117   msg "Now starts something magic:"
118   make ${MAKEFLAGS} bzImage modules
121 package_kernel-netbook-ice() {
122   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!'
123   depends=('coreutils' 'module-init-tools')
124   install=kernel-netbook-ice.install
125   optdepends=('crda: for wireless regulatory domain support' 'linux-firmware: firmware for rt2860 and tigon3')
126   groups=(eee)
128   cd ${srcdir}/linux-$_basekernel
129   # install our modules
130   mkdir -p $pkgdir/{lib/modules,boot}
131   make INSTALL_MOD_PATH=$pkgdir modules_install
132   
133   # Get kernel version
134   _kernver="$(make kernelrelease)"
136   # remove the junk symlinks
137   rm -r $pkgdir/lib/modules/$_kernver/{source,build}
138   
139   # remove the firmware directory
140   rm -rf ${pkgdir}/lib/firmware
142   # install the kernel
143   install -D -m644 ${srcdir}/linux-$_basekernel/System.map $pkgdir/boot/System.map-netbook-ice
144   install -D -m644 ${srcdir}/linux-$_basekernel/arch/x86/boot/bzImage ${pkgdir}/boot/vmlinuz-netbook-ice
145   install -D -m644 ${srcdir}/linux-$_basekernel/.config $pkgdir/boot/kconfig-netbook-ice
147   # install preset file for mkinitcpio
148   sed -i -e "s/ALL_kver=.*/ALL_kver=\'${_kernver}\'/g" $startdir/$pkgname.preset
149   install -m644 -D ${srcdir}/kernel-netbook-ice.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
151   # set correct depmod command for install
152   sed -i -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" $startdir/$pkgname.install
154 ##Section: Broadcom-wl
155   msg "Compiling broadcom-wl module:"
156   cd ${srcdir}/
157   #patching broadcom as broadcom-wl package on AUR
158   patch -p1 < license.patch
159   patch -p1 < semaphore.patch
160   patch -p1 < mutex-sema.patch
161   make -C ${srcdir}/linux-$_basekernel M=`pwd`
162   install -D -m 755 wl.ko ${pkgdir}/lib/modules/$_kernver/kernel/drivers/net/wireless/wl.ko
163   
164 ##Section: stk11xx
165   #msg "Compiling stk11xx module:"
166   #cd $srcdir/stk11xx-$stk11xx_ver
167   #make -C $srcdir/linux-${_basekernel}/ SUBDIRS=$srcdir/stk11xx-2.1.0 modules
168   #install -D -m 644 $srcdir/stk11xx-$stk11xx_ver/stk11xx.ko $pkgdir/lib/modules/$_kernver/kernel/drivers/media/video
169   #install -D -m 644 $srcdir/stk11xx-$stk11xx_ver/README $pkgdir/usr/share/stk11xx.readme
171   # gzip -9 all modules to safe a lot of MB of space
172   find "$pkgdir" -name '*.ko' -exec gzip -9 {} \;
175 package_kernel-netbook-headers-ice() {
176   KARCH=x86
177   pkgdesc='Header files and scripts for building modules for kernel-netbook'
178   mkdir -p ${pkgdir}/lib/modules/${_kernver}
179   cd ${pkgdir}/lib/modules/${_kernver}
180   ln -sf ../../../usr/src/linux-${_kernver} build
181   cd ${srcdir}/linux-$_basekernel
182   install -D -m644 Makefile \
183     ${pkgdir}/usr/src/linux-${_kernver}/Makefile
184   install -D -m644 kernel/Makefile \
185     ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
186   install -D -m644 .config \
187     ${pkgdir}/usr/src/linux-${_kernver}/.config
188   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include
190   for i in acpi asm-generic config generated linux math-emu media net pcmcia scsi sound trace video xen; do
191     cp -a include/$i ${pkgdir}/usr/src/linux-${_kernver}/include/
192   done
194   # copy arch includes for external modules
195   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/x86
196   cp -a arch/x86/include ${pkgdir}/usr/src/linux-${_kernver}/arch/x86/
198   # copy files necessary for later builds, like nvidia and vmware
199   cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
200   cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}
201   # fix permissions on scripts dir
202   chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
203   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions
205   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel
207   cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
208   if [ "$CARCH" = "i686" ]; then
209     cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
210   fi
211   cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/
213   # add headers for lirc package
214   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video
215   cp drivers/media/video/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/
216   for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
217    mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
218    cp -a drivers/media/video/$i/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
219   done
220   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/staging/usbvideo/
221   cp -a drivers/staging/usbvideo/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/staging/usbvideo/
222   # add docbook makefile
223   install -D -m644 Documentation/DocBook/Makefile \
224     ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
225   # add dm headers
226   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
227   cp drivers/md/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
228   # add inotify.h
229   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/linux
230   cp include/linux/inotify.h ${pkgdir}/usr/src/linux-${_kernver}/include/linux/
231   # add wireless headers
232   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
233   cp net/mac80211/*.h ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
234   # add dvb headers for external modules
235   # in reference to:
236   # http://bugs.archlinux.org/task/9912
237   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
238   cp drivers/media/dvb/dvb-core/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
239   # add dvb headers for external modules
240   # in reference to:
241   # http://bugs.archlinux.org/task/11194
242   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
243   cp include/config/dvb/*.h ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
244   # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
245   # in reference to:
246   # http://bugs.archlinux.org/task/13146
247   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
248   cp drivers/media/dvb/frontends/lgdt330x.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
249   cp drivers/media/video/msp3400-driver.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
250   # add dvb headers  
251   # in reference to:
252   # http://bugs.archlinux.org/task/20402
253   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb
254   cp drivers/media/dvb/dvb-usb/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/
255   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends
256   cp drivers/media/dvb/frontends/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
257   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners
258   cp drivers/media/common/tuners/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/
259   # add xfs and shmem for aufs building
260   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs
261   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/mm
262   cp fs/xfs/xfs_sb.h ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h
263   # add headers vor virtualbox
264   # in reference to:
265   # http://bugs.archlinux.org/task/14568
266   cp -a include/drm $pkgdir/usr/src/linux-${_kernver}/include/
267   # add headers for broadcom wl
268   # in reference to:
269   # http://bugs.archlinux.org/task/14568
270   cp -a include/trace $pkgdir/usr/src/linux-${_kernver}/include/
271   # add headers for crypto modules
272   # in reference to:
273   # http://bugs.archlinux.org/task/22081
274   cp -a include/crypto $pkgdir/usr/src/linux-${_kernver}/include/
275   # copy in Kconfig files
276   for i in `find . -name "Kconfig*"`; do 
277     mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
278     cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
279   done
281   chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
282   find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
283   # strip scripts directory
284   find ${pkgdir}/usr/src/linux-${_kernver}/scripts  -type f -perm -u+w 2>/dev/null | while read binary ; do
285   case "$(file -bi "$binary")" in
286     *application/x-sharedlib*) # Libraries (.so)
287     /usr/bin/strip $STRIP_SHARED "$binary";;
288     *application/x-archive*) # Libraries (.a)
289     /usr/bin/strip $STRIP_STATIC "$binary";;
290     *application/x-executable*) # Binaries
291     /usr/bin/strip $STRIP_BINARIES "$binary";;
292     esac 
293   done 
294   # remove unneeded architectures
295   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}
298 sha256sums=('72f0cfaefb8dc86b219d5a742dd0375332627641ecbdf5badd3158e2127b9304'
299             'cfa1bbe81a6734a2c9ed9b224468fcac32be1316c986646c56627e2580301b39'
300             'f736af1da2fa05fb65d8e919b3eb0116eb5ef47e4acc14f5a2adc4bac1b4fb37'
301             'c20587e76a9c758852c2af01ffaed15e91016be56cbce60754150d26c6fbd78f'
302             '13ebbb28af179e6c7d122644bcd06409fd5741baa277b9cc75a4d9905764918c'
303             'dc2be48efa5c07828d14a5eac9a75b2672c37cf87d100712230c9e2d35fd57ab'
304             '6b1e3ac9073534367649bdef7c4461c9af872c60f065ac6f0d2eaf4ee3fa02fb'
305             '69fc12e6b2178b307e1d191fe85c937a68808a94eefea3ee5c069f63d960d121'
306             'b3728a7c473d9291901a434363aa2033cf00937ca223768fc605059dd772b50e'
307             'bb2aad665b4cd7fc039c69899bce340bb90692fd35cf28d7686db488a9f80b57'
308             'd0fed526ae8406dbb1aefa8ffe9f84e1eae5930a1e5e746bae3fcdb57a4dc101'
309             '7901ab87bddb6497e93d1f94c32bc9d94bd7db3312c065281d703c6989638fab'
310             '7855168a9b4bdb6943310bf167f71e36e17c80513a918c12b5d12c6adf881753'
311             '9e601e5f40720b888ca7cfae8c44e365e6b4073da286bec6c5c7f7191a1c56fb')