1 # Contributor: graysky <graysky AT archlinux DOT us>
2 # Contributor: MP2E <metroidcrazy AT gmail DOT com>
3 # Contributor: Tobias Powalowski <tpowa@archlinux.org>
4 # Contributor: Thomas Baechler <thomas@archlinux.org>
5 ###########################################################################################################
6 # Patch and Build Options
7 ###########################################################################################################
9 ## Note all kernels get the ck patch set with BFS so there is no option to enable/disable it!
11 _usearchlogo="y" # use the blue Arch logo rather than default tux logo when booting
12 _makenconfig="n" # select additional kernel options prior to a build via nconfig
13 _localmodcfg="n" # compile ONLY probed modules - see notes below!
14 _localyescfg="n" # convert all modules to core - see notes below!
15 _use_current="n" # use the current kernel's .config file - see notes below!
16 _BFQ_patches="n" # add BFQ patches for the BFQ I/O scheduler
17 ###########################################################################################################
18 # More Details and References
19 ###########################################################################################################
20 ## LOCALMODCONFIG OPTION
21 # As of mainline 2.6.32, running with this option will only build the modules that you currently have
22 # probed in your system VASTLY reducing the number of modules build.
24 # WARNING - make CERTAIN that all modules are modprobed BEFORE you begin making the pkg!
25 # Read, https://bbs.archlinux.org/viewtopic.php?pid=830221#p830221
26 # To keep track of which modules are needed for your specific system/hardware, give my module_db script
27 # a try: http://aur.archlinux.org/packages.php?ID=41689
29 # Note that if you use my script, this PKGBUILD will auto run the reload_data base for you to probe
30 # all the modules you have logged!
32 ## LOCALMODCONFIG OPTION
33 # This adds the option localyesconfig to make. This is similar to localmodconfig, but after it removes
34 # unnecessary modules it runs "sed -i s/=m/=y/" on the .config file. It then runs "make silentoldconfig"
35 # to fix any holes that were created by the conversion of modules to core.
36 ## USE CURRENT KERNEL'S .CONFIG
37 # Enabling this option will use the .config of the RUNNING kernel rather than the ARCH defaults.
38 # Useful when the package gets updated and you already went through the trouble of customizing your
39 # config options. NOT recommended when a new kernel is released, but again, convenient for package bumps.
41 # read, http://algo.ing.unimo.it/people/paolo/disk_sched/
43 ###########################################################################################################
45 pkgname=kernel26-ideapad
46 true && pkgname=(kernel26-ideapad kernel26-ideapad-headers)
48 pkgver=${_basekernel}.3
51 arch=('i686' 'x86_64')
53 url="http://ck-hack.blogspot.com"
57 _patchname="patch-${pkgver}-${_archpatchversion}-ARCH"
58 _ckpatchname="patch-${_basekernel}-ck${_ckpatchversion}"
59 _bfqpath="http://algo.ing.unimo.it/people/paolo/disk_sched/patches/2.6.39"
61 source=(ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$_basekernel.tar.bz2 # kernel source
62 ftp://ftp.archlinux.org/other/kernel26/${_patchname}.bz2 # arch patchset
63 config config.x86_64 kernel26.preset # configs
64 http://www.kernel.org/pub/linux/kernel/people/ck/patches/2.6/${_basekernel}/${_basekernel}-ck${_ckpatchversion}/${_ckpatchname}.bz2
65 ${_bfqpath}/0001-block-prepare-I-O-context-code-for-BFQ-v2-for-2.6.39.patch
66 ${_bfqpath}/0002-block-cgroups-kconfig-build-bits-for-BFQ-v2-2.6.39.patch
67 ${_bfqpath}/0003-block-introduce-the-BFQ-v2-I-O-sched-for-2.6.39.patch
68 fix_ck2.patch # thanks for hador for this fix
69 logo_linux_mono.pbm # optional Arch logo for boot
70 logo_linux_{clut224,vga16}.ppm) # optional Arch logo for boot
73 ### Hador's fix for 2.6.39.3/init/calibrate.c
74 patch -N -i ${srcdir}/fix_ck2.patch
76 ### Patch source with -ARCH patches
77 # See http://projects.archlinux.org/linux-2.6-ARCH.git/
78 msg "Patching source with-ARCH patches"
79 cd ${srcdir}/linux-$_basekernel
80 patch -Np1 -i ${srcdir}/${_patchname}
81 ### Optionally replace the tux logo with the blue Arch logo
82 if [ $_usearchlogo = "y" ]; then
83 install -m644 ${srcdir}/logo_linux_clut224.ppm drivers/video/logo/
84 install -m644 ${srcdir}/logo_linux_mono.pbm drivers/video/logo/
85 install -m644 ${srcdir}/logo_linux_vga16.ppm drivers/video/logo/
88 ### Patch source with ck patchset with BFS
89 # Fix double name in EXTRAVERSION
90 sed -i -re "s/^(.EXTRAVERSION).*$/\1 = /" ${srcdir}/${_ckpatchname}
91 msg "Patching source with the ck2 patch set using bfs v0.406"
92 patch -Np1 -i ${srcdir}/${_ckpatchname}
94 ### Optionally patch source for BFQ patches
95 if [ ${_BFQ_patches} = "y" ]; then
96 msg "Patching source with BFQ patches"
97 for p in $(ls ${srcdir}/000*.patch); do
102 ### Clean tree and copy ARCH config over
103 msg "Running make mrproper to clean source tree"
106 if [ "$CARCH" = "x86_64" ]; then
107 cat ../config.x86_64 >./.config
109 cat ../config >./.config
112 ### Optionally use running kernel's config
113 # code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
114 if [ ${_use_current} = "y" ]; then
115 if [[ -s /proc/config.gz ]]; then
116 msg "Extracting config from /proc/config.gz..."
118 zcat /proc/config.gz > ./.config
120 warning "You kernel was not compiled with IKCONFIG_PROC!"
121 warning "You cannot read the current config!"
127 if [ "${_kernelname}" != "" ]; then
128 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
131 # If user patched to BFQ, set it as default io scheduler
132 if [ ${_BFQ_patches} = "y" ]; then
133 sed -i -e s'/CONFIG_CFQ_GROUP_IOSCHED=y/CONFIG_CFQ_GROUP_IOSCHED=y\nCONFIG_IOSCHED_BFQ=y\nCONFIG_CGROUP_BFQIO=y/' \
134 -i -e s'/CONFIG_DEFAULT_CFQ=y/# CONFIG_DEFAULT_CFQ is not set\nCONFIG_DEFAULT_BFQ=y/' \
135 -i -e '/CONFIG_DEFAULT_IOSCHED/ s,cfq,bfq,' ./.config
138 msg "Running make prepare for you to enable patched options of your choosing"
141 ### Optionally load needed modules for the make localmodconfig
142 # See http://aur.archlinux.org/packages.php?ID=41689
143 if [ $_localmodcfg = "y" ]; then
144 msg "If you have modprobe_db installed, running reload_database now"
145 if [ -e /usr/bin/reload_database ]; then
146 /usr/bin/reload_database
148 msg "Running Steven Rostedt's make localmodconfig now"
152 if [ $_localyescfg = "y" ]; then
153 msg "Running make localyesconfig"
157 if [ $_makenconfig = "y" ]; then
158 msg "Running make nconfig"
162 msg "Running make bzImage and modules"
166 package_kernel26-ideapad() {
167 _Kpkgdesc='ARCH kernel with Brain Fuck Scheduler v0.406 and the ck2 patch set, built for Lenovo Y5xx laptops.'
168 pkgdesc="${_Kpkgdesc}"
169 provides=("kernel26-ideapad=${pkgver}")
170 backup=(etc/mkinitcpio.d/kernel26-ideapad.preset)
171 depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.12-2' 'mkinitcpio>=0.6.8-2')
172 install=kernel26.install
173 #conflicts=('kernel26-ideapad')
174 #groups=('ck-generic')
175 optdepends=('crda: to set the correct wireless channels of your country'
176 'lirc-ck: Linux Infrared Remote Control kernel modules for kernel26-ideapad'
177 'nvidia-ck: nVidia drivers for kernel26-ideapad'
178 'nvidia-beta-ck: nVidia beta drivers for kernel26-ideapad'
179 'modprobed_db: Keeps track of EVERY kernel module that has ever been probed - useful for those of us who make localmodconfig')
182 cd ${srcdir}/linux-$_basekernel
184 _kernver="$(make kernelrelease)"
185 mkdir -p ${pkgdir}/{lib/modules,lib/firmware,boot}
186 msg "Running make modules_install"
187 make INSTALL_MOD_PATH=${pkgdir} modules_install
188 cp System.map ${pkgdir}/boot/System.map26${_kernelname}
189 cp arch/$KARCH/boot/bzImage ${pkgdir}/boot/vmlinuz26${_kernelname}
192 install -m644 -D vmlinux ${pkgdir}/usr/src/linux-${_kernver}/vmlinux
194 # install fallback mkinitcpio.conf file and preset file for kernel
195 install -m644 -D ${srcdir}/kernel26.preset ${pkgdir}/etc/mkinitcpio.d/kernel26-ideapad.preset
197 # set correct depmod command for install
199 -e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
200 -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
201 -i $startdir/kernel26.install
202 sed -e "s|source .*|source /etc/mkinitcpio.d/kernel26${_kernelname}.kver|g" \
203 -e "s|default_image=.*|default_image=\"/boot/kernel26-ideapad.img\"|g" \
204 -e "s|fallback_image=.*|fallback_image=\"/boot/kernel26-ideapad-fallback.img\"|g" \
205 -i ${pkgdir}/etc/mkinitcpio.d/kernel26-ideapad.preset
207 echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${pkgdir}/etc/mkinitcpio.d/kernel26-ideapad.kver
209 # remove build and source links
210 rm -f ${pkgdir}/lib/modules/${_kernver}/{source,build}
212 # remove the firmware
213 rm -rf ${pkgdir}/lib/firmware
215 # gzip -9 all modules to save 100MB of space
216 find "$pkgdir" -name '*.ko' -exec gzip -9 {} \;
219 package_kernel26-ideapad-headers() {
220 _Hpkgdesc='Header files and scripts to build modules for kernel26-ideapad.'
221 pkgdesc="${_Hpkgdesc}"
222 #conflicts=('kernel26-ideapad-headers')
223 #groups=('ck-generic')
224 provides=("kernel26-ideapad-headers=${pkgver}" "kernel26-headers=${pkgver}")
226 mkdir -p ${pkgdir}/lib/modules/${_kernver}
227 cd ${pkgdir}/lib/modules/${_kernver}
228 ln -sf ../../../usr/src/linux-${_kernver} build
229 cd ${srcdir}/linux-$_basekernel
230 install -D -m644 Makefile \
231 ${pkgdir}/usr/src/linux-${_kernver}/Makefile
232 install -D -m644 kernel/Makefile \
233 ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
234 install -D -m644 .config \
235 ${pkgdir}/usr/src/linux-${_kernver}/.config
236 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include
238 for i in acpi asm-generic config crypto drm generated linux math-emu \
239 media net pcmcia scsi sound trace video xen; do
240 cp -a include/$i ${pkgdir}/usr/src/linux-${_kernver}/include/
243 # copy arch includes for external modules
244 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/x86
245 cp -a arch/x86/include ${pkgdir}/usr/src/linux-${_kernver}/arch/x86/
247 # copy files necessary for later builds, like nvidia and vmware
248 cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
249 cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}
251 # fix permissions on scripts dir
252 chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
253 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions
255 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel
257 cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
258 if [ "$CARCH" = "i686" ]; then
259 cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
261 cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/
263 # add headers for lirc package
264 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video
265 cp drivers/media/video/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/
266 for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
267 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
268 cp -a drivers/media/video/$i/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
270 # add docbook makefile
271 install -D -m644 Documentation/DocBook/Makefile \
272 ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
274 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
275 cp drivers/md/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
277 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/linux
278 cp include/linux/inotify.h ${pkgdir}/usr/src/linux-${_kernver}/include/linux/
279 # add wireless headers
280 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
281 cp net/mac80211/*.h ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
282 # add dvb headers for external modules
284 # http://bugs.archlinux.org/task/9912
285 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
286 cp drivers/media/dvb/dvb-core/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
287 # add dvb headers for external modules
289 # http://bugs.archlinux.org/task/11194
290 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
291 # fix if user disables dvb support
292 [[ -e include/config/dvb/ ]] && cp include/config/dvb/*.h ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
293 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
295 # http://bugs.archlinux.org/task/13146
296 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
297 cp drivers/media/dvb/frontends/lgdt330x.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
298 cp drivers/media/video/msp3400-driver.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
301 # http://bugs.archlinux.org/task/20402
302 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb
303 cp drivers/media/dvb/dvb-usb/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/
304 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends
305 cp drivers/media/dvb/frontends/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
306 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners
307 cp drivers/media/common/tuners/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/
308 # add xfs and shmem for aufs building
309 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs
310 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/mm
311 cp fs/xfs/xfs_sb.h ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h
312 # copy in Kconfig files
313 for i in `find . -name "Kconfig*"`; do
314 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
315 cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
318 chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
319 find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
320 # strip scripts directory
321 find ${pkgdir}/usr/src/linux-${_kernver}/scripts -type f -perm -u+w 2>/dev/null | while read binary ; do
322 case "$(file -bi "$binary")" in
323 *application/x-sharedlib*) # Libraries (.so)
324 /usr/bin/strip $STRIP_SHARED "$binary";;
325 *application/x-archive*) # Libraries (.a)
326 /usr/bin/strip $STRIP_STATIC "$binary";;
327 *application/x-executable*) # Binaries
328 /usr/bin/strip $STRIP_BINARIES "$binary";;
332 # remove unneeded architectures
333 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}
335 # Global pkgdesc and depends are here so that they will be picked up by AUR
336 pkgdesc='ARCH kernel with Brain Fuck Scheduler v0.406 and the ck2 patch set, built for Lenovo Y5xx laptops.'
338 md5sums=('1aab7a741abe08d42e8eccf20de61e05'
339 'b23d7def30e57242cfe088f4d8ca8baa'
340 'cb90a186fc83ac0f181150a82d23735b'
341 '137daaabe56f8c83dfc2cbae206219f9'
342 '83abff309b5a504db70b051005a594d0'
343 'ffa0384d5a243d17ca47c9bd0e2217e7'
344 '199921265a39fbe7e8370c6432548ec3'
345 'f71db44b8aabf407c7ea9591b6ba2488'
346 'cbae3fd91c29e692fb19488dedc4f9db'
347 '0ab7720f0d80d142a280cfe35b9a8730'
348 'e8c333eaeac43f5c6a1d7b2f47af12e2'
349 '5974286ba3e9716bfbad83d3f4ee985a'
350 'a6f0377c814da594cffcacbc0785ec1a')