updated on Thu Jan 26 00:18:00 UTC 2012
[aur-mirror.git] / linux-ck-systemtap / PKGBUILD
blob90d6c38c7e28fcdf4caf474ed0f97f5a19ccf80f
1 # Contributor: iamedu <iamedu at gmail dot com>
2 # Contributor: graysky <graysky AT archlinux DOT us>
3 # Contributor: Tobias Powalowski <tpowa@archlinux.org>
4 # Contributor: Thomas Baechler <thomas@archlinux.org>
6 ### PATCH AND BUILD OPTIONS
7 _makenconfig="n"        # tweak kernel options prior to a build via nconfig
8 _localmodcfg="n"        # compile ONLY probed modules
9 _use_current="n"        # use the current kernel's .config file
10 _BFQ_enable_="n"        # enable BFQ as the default I/O scheduler
12 ### DOCS
13 # READ THIS BEFORE INSTALLING!!!!
14 # To build the kernel with debuginfo you need quite a bit of space, my build directory is about 3.6 GB
15 # the kernel also ends up as quite a big kernel so I recommend doing two things:
16
17 # Enabling localmodcfg and if you use yaourt use the --tmp flag or you could end up with
18 # your /tmp partition full ...
19 # That's it if you find any bug email it to me (iamedu)
21 # DETAILS FOR _localmodcfg="y"
22 # As of mainline 2.6.32, running with this option will only build the modules that you currently have
23 # probed in your system VASTLY reducing the number of modules built and the build time to do it.
25 # WARNING - make CERTAIN that all modules are modprobed BEFORE you begin making the pkg!
27 # To keep track of which modules are needed for your specific system/hardware, give my module_db script
28 # a try: http://aur.archlinux.org/packages.php?ID=41689  Note that if you use my script, this PKGBUILD 
29 # will auto run the 'sudo modprobed_db reload' for you to probe all the modules you have logged!
31 # More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed_db
33 # DETAILS FOR _use_current="y"
34 # Enabling this option will use the .config of the RUNNING kernel rather than the ARCH defaults.
35 # Useful when the package gets updated and you already went through the trouble of customizing your
36 # config options.  NOT recommended when a new kernel is released, but again, convenient for package bumps.
38 # DETAILS FOR _BFQ_enable="y"
39 # Alternative I/O scheduler by Paolo.  For more, see: http://algo.ing.unimo.it/people/paolo/disk_sched/
41 pkgname=linux-ck-systemtap
42 true && pkgname=(linux-ck-systemtap linux-ck-systemtap-headers)
43 _kernelname=-ck
44 _basekernel=3.2
45 pkgver=${_basekernel}.1
46 pkgrel=3
47 arch=('i686' 'x86_64')
48 url="http://iamedu.wordpress.com/2012/01/23/linux-ck-systemtap/"
49 license=('GPL2')
50 options=('!strip')
51 _ckpatchversion=1
52 _ckpatchname="patch-${_basekernel}-ck${_ckpatchversion}"
53 _bfqpath="http://algo.ing.unimo.it/people/paolo/disk_sched/patches/3.2.0-v3r2"
54 source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.2.tar.xz"
55 "http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.gz"
56 "http://ck.kolivas.org/patches/3.0/3.2/${_basekernel}-ck${_ckpatchversion}/${_ckpatchname}.bz2"
57 'config' 'config.x86_64' 'change-default-console-loglevel.patch' 'i915-fix-ghost-tv-output.patch'
58 'i915-gpu-finish.patch' 'linux-ck.install' 'linux-ck.preset' 'utrace-3.2.patch.bz2'
59 "${_bfqpath}/0001-block-prepare-I-O-context-code-for-BFQ-v3r2-for-3.2.patch"
60 "${_bfqpath}/0002-block-cgroups-kconfig-build-bits-for-BFQ-v3r2-3.2.patch"
61 "${_bfqpath}/0003-block-introduce-the-BFQ-v3r2-I-O-sched-for-3.2.patch")
62 sha256sums=('dd96ed02b53fb5d57762e4b1f573460909de472ca588f81ec6660e4a172e7ba7'
63             '20f633517dc186157618762338a05927f539dd7eba85a6c0a02635d961637ec0'
64             '81aa6ee7b19b70a01f751bd26b79252d43457e3fda57bd35e125b2a20a7115cd'
65             '50c2a787acaeccb48d84e4325b325b24942b5d525fa64b266752910cbb197865'
66             'a33f764cc88f9f6e97e8e4fea2f5b3776e5c546a575292d1e911fde21183291b'
67             'b9d79ca33b0b51ff4f6976b7cd6dbb0b624ebf4fbf440222217f8ffc50445de4'
68             '9ccadbe3eb30bb283af3eb869c3a4bdb764628854811cc616a2e02e9ef398705'
69             '177f1d6a03a1d5e7a78e8687f223d0a675c43430b9e5dd09e3a038a8b7d2da30'
70             '0ad48d4f77ed70bef3227c7293fe6513cf1840f710020bfabbac3d4bd0cb2589'
71             'c2cf8cc2600502de348f3dc3aae9a3bde5486759db15cb8a93df7aa35bd6e7da'
72             '7da2b684fd3d9ebcb9a2523c652b2ae89f46e5904301fb9baf43caf3a1225633'
73             '4167d857d2a6348eac9828a177bbb0e597d49fa4e4a1bf61c5933eb5e6b94d9a'
74             'ced0347b5b49cac8ff9165f79bda27d0cf74e5f902381de1de32288c07524037'
75             '2a1aa22286a49617ff722cc5af81af206cdaf4de86a120f11c12c1e9cada71cd')
77 build() {
78         cd "${srcdir}/linux-${_basekernel}"
80         # add upstream patch
81         patch -p1 -i "${srcdir}/patch-${pkgver}"
83         # add latest fixes from stable queue, if needed
84         # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
86         # fix FS#27883
87   # drm/i915: Only clear the GPU domains upon a successful finish
88   patch -Np1 -i "${srcdir}/i915-gpu-finish.patch"
90   # Some chips detect a ghost TV output
91         # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
92         # Arch Linux bug report: FS#19234
93         #
94         # It is unclear why this patch wasn't merged upstream, it was accepted,
95         # then dropped because the reasoning was unclear. However, it is clearly
96         # needed.
97         patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.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 ck1 including bfs v0.416"
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         ### Patch source with utrace
117         msg "Patching source with utrace"
118         patch -Np1 -i "${srcdir}/utrace-3.2.patch"
120         ### Clean tree and copy ARCH config over
121         msg "Running make mrproper to clean source tree"
122         make mrproper
124         if [ "${CARCH}" = "x86_64" ]; then
125                 cat "${srcdir}/config.x86_64" > ./.config
126         else
127                 cat "${srcdir}/config" > ./.config
128         fi
130         ### Optionally use running kernel's config
131         # code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
132         if [ $_use_current = "y" ]; then
133                 if [[ -s /proc/config.gz ]]; then
134                         msg "Extracting config from /proc/config.gz..."
135                         # modprobe configs
136                         zcat /proc/config.gz > ./.config
137                 else
138                         warning "You kernel was not compiled with IKCONFIG_PROC!"
139                         warning "You cannot read the current config!"
140                         warning "Aborting!"
141                         exit
142                 fi
143         fi
145         if [ "${_kernelname}" != "" ]; then
146                 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
147         fi
149         ### BFQ to be compiled in but not enabled
150         sed -i -e s'/CONFIG_CFQ_GROUP_IOSCHED=y/CONFIG_CFQ_GROUP_IOSCHED=y\nCONFIG_IOSCHED_BFQ=y\nCONFIG_CGROUP_BFQIO=y/' \
151                 -i -e s'/CONFIG_DEFAULT_CFQ=y/CONFIG_DEFAULT_CFQ=y\n# CONFIG_DEFAULT_BFQ is not set/' ./.config
153         ### Optionally enable BFQ as the default io scheduler
154         if [ $_BFQ_enable_ = "y" ]; then
155                 sed -i -e '/CONFIG_DEFAULT_IOSCHED/ s,cfq,bfq,' \
156          -i -e s'/CONFIG_DEFAULT_CFQ=y/# CONFIG_DEFAULT_CFQ is not set\nCONFIG_DEFAULT_BFQ=y/' ./.config
157         fi
159         # set extraversion to pkgrel
160         sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
162         # get kernel version
163         msg "Running make prepare for you to enable patched options of your choosing"
164         make prepare
166         ### Optionally load needed modules for the make localmodconfig
167         # See http://aur.archlinux.org/packages.php?ID=41689
168         if [ $_localmodcfg = "y" ]; then
169                 msg "If you have modprobe_db installed, running it in recall mode now"
170                 if [ -e /usr/bin/modprobed_db ]; then
171                         [[ ! -x /usr/bin/sudo ]] && echo "Cannot call modprobe with sudo.  Install via pacman -S sudo and configure to work with this user." && exit 1
172                         sudo /usr/bin/modprobed_db recall
173                 fi
174                 msg "Running Steven Rostedt's make localmodconfig now"
175                 make localmodconfig
176         fi
178         if [ $_makenconfig = "y" ]; then
179                 msg "Running make nconfig"
180                 make nconfig
181         fi
183         msg "Running make bzImage and modules"
184         make ${MAKEFLAGS} bzImage modules
187 package_linux-ck-systemtap() {
188 _Kpkgdesc='Linux Kernel and modules with the ck1 patchset featuring Brain Fuck Scheduler v0.416.'
189 pkgdesc="${_Kpkgdesc}"
190 depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
191 optdepends=('crda: to set the correct wireless channels of your country' 'lirc-ck: Linux Infrared Remote Control kernel modules for linux-ck' 'nvidia-ck: nVidia drivers for linux-ck' 'nvidia-beta-ck: nVidia beta drivers for linux-ck' 'modprobed_db: Keeps track of EVERY kernel module that has ever been probed - useful for those of us who make localmodconfig')
192 provides=("linux-ck-systemtap=${pkgver}" "linux-ck=${pkgver}")
193 conflicts=('kernel26-ck' 'linux-ck')
194 replaces=('kernel26-ck' 'linux-ck')
195 backup=("etc/mkinitcpio.d/linux-ck.preset")
196 install=linux-ck.install
197 #groups=('ck-generic')
199 cd "${srcdir}/linux-${_basekernel}"
201 KARCH=x86
203 # get kernel version
204 _kernver="$(make kernelrelease)"
206 mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
207 make INSTALL_MOD_PATH="${pkgdir}" modules_install
208 cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-linux-ck"
210 # add vmlinux
211 install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
213 # install fallback mkinitcpio.conf file and preset file for kernel
214 install -D -m644 "${srcdir}/linux-ck.preset" "${pkgdir}/etc/mkinitcpio.d/linux-ck.preset"
216 # set correct depmod command for install
217 sed \
218         -e  "s/KERNEL_NAME=.*/KERNEL_NAME=-ck/g" \
219         -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
220         -i "${startdir}/linux-ck.install"
221 sed \
222         -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-linux-ck\"|g" \
223         -e "s|default_image=.*|default_image=\"/boot/initramfs-linux-ck.img\"|g" \
224         -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-linux-ck-fallback.img\"|g" \
225         -i "${pkgdir}/etc/mkinitcpio.d/linux-ck.preset"
227 # remove build and source links
228 rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
229 # remove the firmware
230 rm -rf "${pkgdir}/lib/firmware"
231 # gzip -9 all modules to save 100MB of space
232 find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
233 # make room for external modules
234 ln -s "../extramodules-${_basekernel}${_kernelname:ck}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
235 # add real version for building modules and running depmod from post_install/upgrade
236 mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:ck}"
237 echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:ck}/version"
240 package_linux-ck-systemtap-headers() {
241 _Hpkgdesc='Header files and scripts to build modules for linux-ck-systemtap.'
242 pkgdesc="${_Hpkgdesc}"
243 provides=("linux-ck-systemtap-headers=${pkgver}" "linux-ck-headers=${pkgver}")
244 conflicts=('kernel26-ck-headers' 'linux-ck-headers')
245 replaces=('kernel26-ck-headers' 'linux-ck-headers')
246 #groups=('ck-generic')
248 mkdir -p "${pkgdir}/lib/modules/${_kernver}"
250 cd "${pkgdir}/lib/modules/${_kernver}"
251 ln -sf ../../../usr/src/linux-${_kernver} build
253 cd "${srcdir}/linux-${_basekernel}"
254 install -D -m644 Makefile \
255         "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
256 install -D -m644 kernel/Makefile \
257         "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
258 install -D -m644 .config \
259         "${pkgdir}/usr/src/linux-${_kernver}/.config"
261 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
263 for i in acpi asm-generic config crypto drm generated linux math-emu \
264         media net pcmcia scsi sound trace video xen; do
265 cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
266         done
268         # copy arch includes for external modules
269         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
270         cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
272         # copy files necessary for later builds, like nvidia and vmware
273         cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
274         cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
276         # fix permissions on scripts dir
277         chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
278         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
280         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
282         cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
284         if [ "${CARCH}" = "i686" ]; then
285                 cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
286         fi
288         cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
290         # add headers for lirc package
291         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
293         cp drivers/media/video/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
295         for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
296                 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
297                 cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
298         done
300         # add docbook makefile
301         install -D -m644 Documentation/DocBook/Makefile \
302                 "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
304         # add dm headers
305         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
306         cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
308         # add inotify.h
309         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
310         cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
312         # add wireless headers
313         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
314         cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
316         # add dvb headers for external modules
317         # in reference to:
318         # http://bugs.archlinux.org/task/9912
319         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
320         cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
321         # and...
322         # http://bugs.archlinux.org/task/11194
323         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
324         [[ -e include/config/dvb/ ]] && cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/" 
326         # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
327         # in reference to:
328         # http://bugs.archlinux.org/task/13146
329         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
330         cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
331         cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
333         # add dvb headers
334         # in reference to:
335         # http://bugs.archlinux.org/task/20402
336         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
337         cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
338         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
339         cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
340         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
341         cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
343         # add xfs and shmem for aufs building
344         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
345         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
346         cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
348         # copy in Kconfig files
349         for i in `find . -name "Kconfig*"`; do
350                 mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
351                 cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
352         done
354         chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
355         find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
357         # strip scripts directory
358         find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
359         case "$(file -bi "${binary}")" in
360                 *application/x-sharedlib*) # Libraries (.so)
361                         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
362                 *application/x-archive*) # Libraries (.a)
363                         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
364                 *application/x-executable*) # Binaries
365                         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
366         esac
367 done
369 # remove unneeded architectures
370 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}
372 # Global pkgdesc and depends are here so that they will be picked up by AUR
373 pkgdesc='Linux Kernel and modules with the ck1 patchset featuring Brain Fuck Scheduler v0.416, kernel debug info is enabled, and UTRACE is baked in for userland support so we have a systemtap friendly kernel :D.'