updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / linux-ideapad / PKGBUILD
blobbd97ec26938ddfd65478c108b6be0d71e1169ec9
1 # Contributor: graysky <graysky AT archlinux DOT us>
2 # Contributor: Tobias Powalowski <tpowa@archlinux.org>
3 # Contributor: Thomas Baechler <thomas@archlinux.org>
4 ###########################################################################################################
5 #                                          Patch and Build Options
6 ###########################################################################################################
8 ## Note all kernels get the ck patch set with BFS so there is no option to enable/disable it!
10 _usearchlogo="y"  # use the blue Arch logo rather than default tux logo when booting
11 _makenconfig="n"        # select additional kernel options prior to a build via nconfig
12 _localmodcfg="n"        # compile ONLY probed modules - see notes below!
13 _localyescfg="n"        # convert all modules to core - see notes below!
14 _use_current="n"        # use the current kernel's .config file - see notes below!
15 _BFQ_enable_="n"        # enable BFQ as the default I/O scheduler
16 ###########################################################################################################
17 #                                        More Details and References
18 ###########################################################################################################
19 ## LOCALMODCONFIG OPTION
20 #  As of mainline 2.6.32, running with this option will only build the modules that you currently have
21 #  probed in your system VASTLY reducing the number of modules built and the build time to do it.
23 #  WARNING - make CERTAIN that all modules are modprobed BEFORE you begin making the pkg!
25 #  To keep track of which modules are needed for your specific system/hardware, give my module_db script
26 #  a try: http://aur.archlinux.org/packages.php?ID=41689  Note that if you use my script, this PKGBUILD 
27 #  will auto run the reload_data base for you to probe all the modules you have logged!
28 #  More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed_db
30 ## LOCALYESCONFIG OPTION
31 #  This adds the option localyesconfig to make. This is similar to localmodconfig, but after it removes
32 #  unnecessary modules it runs "sed -i s/=m/=y/" on the .config file. It then runs "make silentoldconfig"
33 #  to fix any holes that were created by the conversion of modules to core.
35 ## USE CURRENT KERNEL'S .CONFIG
36 #  Enabling this option will use the .config of the RUNNING kernel rather than the ARCH defaults.
37 #  Useful when the package gets updated and you already went through the trouble of customizing your
38 #  config options.  NOT recommended when a new kernel is released, but again, convenient for package bumps.
40 ## BFQ
41 #  Alternative I/O scheduler by Paolo.  For more, see: http://algo.ing.unimo.it/people/paolo/disk_sched/
42 ###########################################################################################################
44 pkgname=linux-ideapad
45 true && pkgname=(linux-ideapad linux-ideapad-headers)
46 _kernelname=-ideapad
47 _basekernel=3.1
48 pkgver=${_basekernel}.5
49 pkgrel=2
50 arch=('i686' 'x86_64')
51 url="https://wiki.archlinux.org/index.php/linux-ideapad"
52 license=('GPL2')
53 options=('!strip')
54 _ckpatchversion=2
55 _ckpatchname="patch-${_basekernel}.0-ck${_ckpatchversion}"
56 _bfqpath="http://algo.ing.unimo.it/people/paolo/disk_sched/patches/3.1.0-v3r1"
58 source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.1.tar.bz2"
59 "http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.gz"
60 "http://ck.kolivas.org/patches/3.0/3.1/${_basekernel}.0-ck${_ckpatchversion}/${_ckpatchname}.bz2"
61 'change-default-console-loglevel.patch'
62 'i915-fix-ghost-tv-output.patch'
63 'i915-fix-incorrect-error-message.patch'
64 'usb-add-reset-resume-quirk-for-several-webcams.patch'
65 'config' 'config.x86_64'
66 'linux-ideapad.install' 'linux-ideapad.preset'
67 "${_bfqpath}/0001-block-prepare-I-O-context-code-for-BFQ-v3r1-for-3.1.patch"
68 "${_bfqpath}/0002-block-cgroups-kconfig-build-bits-for-BFQ-v3r1-3.1.patch"
69 "${_bfqpath}/0003-block-introduce-the-BFQ-v3r1-I-O-sched-for-3.1.patch"
70 'logo_linux_mono.pbm' # optional Arch logo for boot
71 logo_linux_{clut224,vga16}.ppm) # optional Arch logo for boot
73 build() {
74         cd "${srcdir}/linux-${_basekernel}"
75         # add upstream patch
76         patch -p1 -i "${srcdir}/patch-${pkgver}"
78         # add latest fixes from stable queue, if needed
79         # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
81         # Some chips detect a ghost TV output
82         # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
83         # Arch Linux bug report: FS#19234
84         #
85         # It is unclear why this patch wasn't merged upstream, it was accepted,
86         # then dropped because the reasoning was unclear. However, it is clearly
87         # needed.
88         patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
90         # In 3.1.1, a DRM_DEBUG message is falsely declared as DRM_ERROR. This
91         # worries users, as this message is displayed even at loglevel 4. Fix
92         # this.
93         patch -Np1 -i "${srcdir}/i915-fix-incorrect-error-message.patch"
95         # Add the USB_QUIRK_RESET_RESUME for several webcams
96         # FS#26528
97         patch -Np1 -i "${srcdir}/usb-add-reset-resume-quirk-for-several-webcams.patch"
99         # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
100         # remove this when a Kconfig knob is made available by upstream
101         # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
102         patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
104         ### Patch source with ck patchset with BFS
105         # Fix double name in EXTRAVERSION
106         sed -i -re "s/^(.EXTRAVERSION).*$/\1 = /" "${srcdir}/${_ckpatchname}"
107         msg "Patching source with the ck2 patch set using bfs v0.415"
108         patch -Np1 -i "${srcdir}/${_ckpatchname}"
110         ### Patch with BFQ IO Scheduler
111         msg "Patching source with BFQ patches"
112         for p in $(ls ${srcdir}/000*.patch); do
113                 patch -Np1 -i $p
114         done
116         ### Clean tree and copy ARCH config over
117         msg "Running make mrproper to clean source tree"
118         make mrproper
120         if [ "${CARCH}" = "x86_64" ]; then
121                 cat "${srcdir}/config.x86_64" > ./.config
122         else
123                 cat "${srcdir}/config" > ./.config
124         fi
126         ### Optionally use the blue Arch logo at kernel load
127         if [ $_usearchlogo = "y" ]; then
128                 install -m644 ${srcdir}/logo_linux_clut224.ppm drivers/video/logo/
129                 install -m644 ${srcdir}/logo_linux_mono.pbm drivers/video/logo/
130                 install -m644 ${srcdir}/logo_linux_vga16.ppm drivers/video/logo/
131                 sed -i -e 's/# CONFIG_LOGO is not set/CONFIG_LOGO=y\nCONFIG_LOGO_LINUX_MONO=y\nCONFIG_LOGO_LINUX_VGA16=y\nCONFIG_LOGO_LINUX_CLUT224=y/' ./.config
132         fi
134         ### Optionally use running kernel's config
135         # code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
136         if [ $_use_current = "y" ]; then
137                 if [[ -s /proc/config.gz ]]; then
138                         msg "Extracting config from /proc/config.gz..."
139                         modprobe configs
140                         zcat /proc/config.gz > ./.config
141                 else
142                         warning "You kernel was not compiled with IKCONFIG_PROC!"
143                         warning "You cannot read the current config!"
144                         warning "Aborting!"
145                         exit
146                 fi
147         fi
149         if [ "${_kernelname}" != "" ]; then
150                 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
151         fi
153         ### BFQ to be compiled in but not enabled
154         sed -i -e s'/CONFIG_CFQ_GROUP_IOSCHED=y/CONFIG_CFQ_GROUP_IOSCHED=y\nCONFIG_IOSCHED_BFQ=y\nCONFIG_CGROUP_BFQIO=y/' \
155                 -i -e s'/CONFIG_DEFAULT_CFQ=y/CONFIG_DEFAULT_CFQ=y\n# CONFIG_DEFAULT_BFQ is not set/' ./.config
157         ### Optionally enable BFQ as the default io scheduler
158         [[ $_BFQ_enable_ = "y" ]] && sed -i -e '/CONFIG_DEFAULT_IOSCHED/ s,cfq,bfq,' \
159                 -i -e s'/CONFIG_DEFAULT_CFQ=y/# CONFIG_DEFAULT_CFQ is not set\nCONFIG_DEFAULT_BFQ=y/' ./.config
161         # set extraversion to pkgrel
162         sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
164         # get kernel version
165         msg "Running make prepare for you to enable patched options of your choosing"
166         make prepare
168         ### Optionally load needed modules for the make localmodconfig
169         # See http://aur.archlinux.org/packages.php?ID=41689
170         if [ $_localmodcfg = "y" ]; then
171                 msg "If you have modprobe_db installed, running reload_database now"
172                 if [ -e /usr/bin/reload_database ]; then
173                         [[ ! -x /usr/bin/sudo ]] && echo "Cannot call modprobe with sudo.  Install via pacman -S sudo and configure to work with this user." && exit
174                         sudo /usr/bin/reload_database
175                 fi
176                 msg "Running Steven Rostedt's make localmodconfig now"
177                 make localmodconfig
178         fi
180         if [ $_localyescfg = "y" ]; then
181                 msg "Running make localyesconfig"
182                 make localyesconfig
183         fi
185         if [ $_makenconfig = "y" ]; then
186                 msg "Running make nconfig"
187                 make nconfig
188         fi
190         msg "Running make bzImage and modules"
191         make ${MAKEFLAGS} bzImage modules
194 package_linux-ideapad() {
195 _Kpkgdesc='Linux Kernel and modules with Brain Fuck Scheduler v0.415 and the ck2 patch set, built for Lenovo Y5xx laptops.'
196 pkgdesc="${_Kpkgdesc}"
197 depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
198 optdepends=('crda: to set the correct wireless channels of your country' 'lirc-ck: Linux Infrared Remote Control kernel modules for linux-ideapad' 'nvidia-ck: nVidia drivers for linux-ideapad' 'nvidia-beta-ck: nVidia beta drivers for linux-ideapad' 'modprobed_db: Keeps track of EVERY kernel module that has ever been probed - useful for those of us who make localmodconfig')
199 provides=("linux-ideapad=${pkgver}")
200 conflicts=('kernel26-ideapad')
201 replaces=('kernel26-ideapad')
202 backup=("etc/mkinitcpio.d/linux-ideapad.preset")
203 install=linux-ideapad.install
204 #groups=('ck-generic')
206 cd "${srcdir}/linux-${_basekernel}"
208 KARCH=x86
210 # get kernel version
211 _kernver="$(make kernelrelease)"
213 mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
214 make INSTALL_MOD_PATH="${pkgdir}" modules_install
215 cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-linux-ideapad"
217 # add vmlinux
218 install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
220 # install fallback mkinitcpio.conf file and preset file for kernel
221 install -D -m644 "${srcdir}/linux-ideapad.preset" "${pkgdir}/etc/mkinitcpio.d/linux-ideapad.preset"
223 # set correct depmod command for install
224 sed \
225         -e  "s/KERNEL_NAME=.*/KERNEL_NAME=-ideapad/g" \
226         -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
227         -i "${startdir}/linux-ideapad.install"
228 sed \
229         -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-linux-ideapad\"|g" \
230         -e "s|default_image=.*|default_image=\"/boot/initramfs-linux-ideapad.img\"|g" \
231         -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-linux-ideapad-fallback.img\"|g" \
232         -i "${pkgdir}/etc/mkinitcpio.d/linux-ideapad.preset"
234 # remove build and source links
235 rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
236 # remove the firmware
237 rm -rf "${pkgdir}/lib/firmware"
238 # gzip -9 all modules to save 100MB of space
239 find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
240 # make room for external modules
241 ln -s "../extramodules-${_basekernel}${_kernelname:ck}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
242 # add real version for building modules and running depmod from post_install/upgrade
243 mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:ck}"
244 echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:ck}/version"
247 package_linux-ideapad-headers() {
248 _Hpkgdesc='Header files and scripts to build modules for linux-ideapad.'
249 pkgdesc="${_Hpkgdesc}"
250 provides=("linux-ideapad-headers=${pkgver}")
251 conflicts=('kernel26-ideapad-headers')
252 replaces=('kernel26-ideapad-headers')
253 #groups=('ck-generic')
255 mkdir -p "${pkgdir}/lib/modules/${_kernver}"
257 cd "${pkgdir}/lib/modules/${_kernver}"
258 ln -sf ../../../usr/src/linux-${_kernver} build
260 cd "${srcdir}/linux-${_basekernel}"
261 install -D -m644 Makefile \
262         "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
263 install -D -m644 kernel/Makefile \
264         "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
265 install -D -m644 .config \
266         "${pkgdir}/usr/src/linux-${_kernver}/.config"
268 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
270 for i in acpi asm-generic config crypto drm generated linux math-emu \
271         media net pcmcia scsi sound trace video xen; do
272 cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
273         done
275         # copy arch includes for external modules
276         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
277         cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
279         # copy files necessary for later builds, like nvidia and vmware
280         cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
281         cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
283         # fix permissions on scripts dir
284         chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
285         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
287         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
289         cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
291         if [ "${CARCH}" = "i686" ]; then
292                 cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
293         fi
295         cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
297         # add headers for lirc package
298         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
300         cp drivers/media/video/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
302         for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
303                 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
304                 cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
305         done
307         # add docbook makefile
308         install -D -m644 Documentation/DocBook/Makefile \
309                 "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
311         # add dm headers
312         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
313         cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
315         # add inotify.h
316         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
317         cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
319         # add wireless headers
320         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
321         cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
323         # add dvb headers for external modules
324         # in reference to:
325         # http://bugs.archlinux.org/task/9912
326         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
327         cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
328         # and...
329         # http://bugs.archlinux.org/task/11194
330         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
331         [[ -e include/config/dvb/ ]] && cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/" 
333         # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
334         # in reference to:
335         # http://bugs.archlinux.org/task/13146
336         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
337         cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
338         cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
340         # add dvb headers
341         # in reference to:
342         # http://bugs.archlinux.org/task/20402
343         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
344         cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
345         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
346         cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
347         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
348         cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
350         # add xfs and shmem for aufs building
351         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
352         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
353         cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
355         # copy in Kconfig files
356         for i in `find . -name "Kconfig*"`; do
357                 mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
358                 cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
359         done
361         chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
362         find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
364         # strip scripts directory
365         find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
366         case "$(file -bi "${binary}")" in
367                 *application/x-sharedlib*) # Libraries (.so)
368                         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
369                 *application/x-archive*) # Libraries (.a)
370                         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
371                 *application/x-executable*) # Binaries
372                         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
373         esac
374 done
376 # remove unneeded architectures
377 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}
379 # Global pkgdesc and depends are here so that they will be picked up by AUR
380 pkgdesc='Linux Kernel and modules with Brain Fuck Scheduler v0.415 and the ck2 patch set, built for Lenovo Y5xx laptops.'
382 md5sums=('8d43453f8159b2332ad410b19d86a931'
383          '054cc9cdec0a2776c61087931c06fad9'
384          'a4c69095403ff44d5dfd8a935c3aca5a'
385          '9d3c56a4b999c8bfbd4018089a62f662'
386          '263725f20c0b9eb9c353040792d644e5'
387          'a50c9076012cb2dda49952dc6ec3e9c1'
388          '52d41fa61e80277ace2b994412a0c856'
389          'ae48eb603bdbdac4b6dc2ac4aa8e8cd7'
390          '95f6ec9f4d6f5a165c36ecc888fb69cb'
391          '989c96451870e410c5adec9a6c3eb870'
392          '5ca990b7396492ffce651611da0a8d86'
393          'e470805b4ef9d469a85b6e2f811ac337'
394          '61ca56c06bf197c0548ecd9fe01b2515'
395          '93e1b461374ae8b5147bba9887964cbe'
396          'e8c333eaeac43f5c6a1d7b2f47af12e2'
397          '5974286ba3e9716bfbad83d3f4ee985a'
398          'a6f0377c814da594cffcacbc0785ec1a')