1 # Contributor: graysky <graysky AT archlinux DOT us>
2 # Contributor: Tobias Powalowski <tpowa@archlinux.org>
3 # Contributor: Thomas Baechler <thomas@archlinux.org>
5 ### PATCH AND BUILD OPTIONS
6 _makenconfig="n" # tweak kernel options prior to a build via nconfig
7 _localmodcfg="n" # compile ONLY probed modules
8 _use_current="n" # use the current kernel's .config file
9 _BFQ_enable_="n" # enable BFQ as the default I/O scheduler
12 # DETAILS FOR _localmodcfg="y"
13 # As of mainline 2.6.32, running with this option will only build the modules that you currently have
14 # probed in your system VASTLY reducing the number of modules built and the build time to do it.
16 # WARNING - make CERTAIN that all modules are modprobed BEFORE you begin making the pkg!
18 # To keep track of which modules are needed for your specific system/hardware, give my module_db script
19 # a try: http://aur.archlinux.org/packages.php?ID=41689 Note that if you use my script, this PKGBUILD
20 # will auto run the 'sudo modprobed_db reload' for you to probe all the modules you have logged!
22 # More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed_db
24 # DETAILS FOR _use_current="y"
25 # Enabling this option will use the .config of the RUNNING kernel rather than the ARCH defaults.
26 # Useful when the package gets updated and you already went through the trouble of customizing your
27 # config options. NOT recommended when a new kernel is released, but again, convenient for package bumps.
29 # DETAILS FOR _BFQ_enable="y"
30 # Alternative I/O scheduler by Paolo. For more, see: http://algo.ing.unimo.it/people/paolo/disk_sched/
33 true && pkgname=(linux-ck linux-ck-headers)
36 pkgver=${_basekernel}.1
38 arch=('i686' 'x86_64')
39 url="https://wiki.archlinux.org/index.php/linux-ck"
43 _ckpatchname="patch-${_basekernel}-ck${_ckpatchversion}"
44 _bfqpath="http://algo.ing.unimo.it/people/paolo/disk_sched/patches/3.2.0-v3r2"
45 source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.2.tar.xz"
46 "http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.gz"
47 "http://ck.kolivas.org/patches/3.0/3.2/${_basekernel}-ck${_ckpatchversion}/${_ckpatchname}.bz2"
48 'config' 'config.x86_64' 'change-default-console-loglevel.patch' 'i915-fix-ghost-tv-output.patch'
49 'i915-gpu-finish.patch' 'linux-ck.install' 'linux-ck.preset'
50 "${_bfqpath}/0001-block-prepare-I-O-context-code-for-BFQ-v3r2-for-3.2.patch"
51 "${_bfqpath}/0002-block-cgroups-kconfig-build-bits-for-BFQ-v3r2-3.2.patch"
52 "${_bfqpath}/0003-block-introduce-the-BFQ-v3r2-I-O-sched-for-3.2.patch")
53 sha256sums=('dd96ed02b53fb5d57762e4b1f573460909de472ca588f81ec6660e4a172e7ba7'
54 '20f633517dc186157618762338a05927f539dd7eba85a6c0a02635d961637ec0'
55 '81aa6ee7b19b70a01f751bd26b79252d43457e3fda57bd35e125b2a20a7115cd'
56 '649e5fdded58765672d2d67b76c505ae99cc136bdaa3151e3e06380f1cbca2f8'
57 '4d552c3061cf4c881ae1ca70b8bd922c98d4f01860eb68f63820f3bb0c849847'
58 'b9d79ca33b0b51ff4f6976b7cd6dbb0b624ebf4fbf440222217f8ffc50445de4'
59 '9ccadbe3eb30bb283af3eb869c3a4bdb764628854811cc616a2e02e9ef398705'
60 '177f1d6a03a1d5e7a78e8687f223d0a675c43430b9e5dd09e3a038a8b7d2da30'
61 '0ad48d4f77ed70bef3227c7293fe6513cf1840f710020bfabbac3d4bd0cb2589'
62 'c2cf8cc2600502de348f3dc3aae9a3bde5486759db15cb8a93df7aa35bd6e7da'
63 '4167d857d2a6348eac9828a177bbb0e597d49fa4e4a1bf61c5933eb5e6b94d9a'
64 'ced0347b5b49cac8ff9165f79bda27d0cf74e5f902381de1de32288c07524037'
65 '2a1aa22286a49617ff722cc5af81af206cdaf4de86a120f11c12c1e9cada71cd')
68 cd "${srcdir}/linux-${_basekernel}"
71 patch -p1 -i "${srcdir}/patch-${pkgver}"
73 # add latest fixes from stable queue, if needed
74 # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
77 # drm/i915: Only clear the GPU domains upon a successful finish
78 patch -Np1 -i "${srcdir}/i915-gpu-finish.patch"
80 # Some chips detect a ghost TV output
81 # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
82 # Arch Linux bug report: FS#19234
84 # It is unclear why this patch wasn't merged upstream, it was accepted,
85 # then dropped because the reasoning was unclear. However, it is clearly
87 patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
89 # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
90 # remove this when a Kconfig knob is made available by upstream
91 # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
92 patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
94 ### Patch source with ck patchset with BFS
95 # Fix double name in EXTRAVERSION
96 sed -i -re "s/^(.EXTRAVERSION).*$/\1 = /" "${srcdir}/${_ckpatchname}"
97 msg "Patching source with ck1 including bfs v0.416"
98 patch -Np1 -i "${srcdir}/${_ckpatchname}"
100 ### Patch with BFQ IO Scheduler
101 msg "Patching source with BFQ patches"
102 for p in $(ls ${srcdir}/000*.patch); do
106 ### Clean tree and copy ARCH config over
107 msg "Running make mrproper to clean source tree"
110 if [ "${CARCH}" = "x86_64" ]; then
111 cat "${srcdir}/config.x86_64" > ./.config
113 cat "${srcdir}/config" > ./.config
116 ### Optionally use running kernel's config
117 # code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
118 if [ $_use_current = "y" ]; then
119 if [[ -s /proc/config.gz ]]; then
120 msg "Extracting config from /proc/config.gz..."
122 zcat /proc/config.gz > ./.config
124 warning "You kernel was not compiled with IKCONFIG_PROC!"
125 warning "You cannot read the current config!"
131 if [ "${_kernelname}" != "" ]; then
132 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
135 ### BFQ to be compiled in but not enabled
136 sed -i -e s'/CONFIG_CFQ_GROUP_IOSCHED=y/CONFIG_CFQ_GROUP_IOSCHED=y\nCONFIG_IOSCHED_BFQ=y\nCONFIG_CGROUP_BFQIO=y/' \
137 -i -e s'/CONFIG_DEFAULT_CFQ=y/CONFIG_DEFAULT_CFQ=y\n# CONFIG_DEFAULT_BFQ is not set/' ./.config
139 ### Optionally enable BFQ as the default io scheduler
140 if [ $_BFQ_enable_ = "y" ]; then
141 sed -i -e '/CONFIG_DEFAULT_IOSCHED/ s,cfq,bfq,' \
142 -i -e s'/CONFIG_DEFAULT_CFQ=y/# CONFIG_DEFAULT_CFQ is not set\nCONFIG_DEFAULT_BFQ=y/' ./.config
145 # set extraversion to pkgrel
146 sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
149 msg "Running make prepare for you to enable patched options of your choosing"
152 ### Optionally load needed modules for the make localmodconfig
153 # See http://aur.archlinux.org/packages.php?ID=41689
154 if [ $_localmodcfg = "y" ]; then
155 msg "If you have modprobe_db installed, running it in recall mode now"
156 if [ -e /usr/bin/modprobed_db ]; then
157 [[ ! -x /usr/bin/sudo ]] && echo "Cannot call modprobe with sudo. Install via pacman -S sudo and configure to work with this user." && exit 1
158 sudo /usr/bin/modprobed_db recall
160 msg "Running Steven Rostedt's make localmodconfig now"
164 if [ $_makenconfig = "y" ]; then
165 msg "Running make nconfig"
169 msg "Running make bzImage and modules"
170 make ${MAKEFLAGS} bzImage modules
174 _Kpkgdesc='Linux Kernel and modules with the ck1 patchset featuring Brain Fuck Scheduler v0.416.'
175 pkgdesc="${_Kpkgdesc}"
176 depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
177 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')
178 provides=("linux-ck=${pkgver}")
179 conflicts=('kernel26-ck')
180 replaces=('kernel26-ck')
181 backup=("etc/mkinitcpio.d/linux-ck.preset")
182 install=linux-ck.install
183 #groups=('ck-generic')
185 cd "${srcdir}/linux-${_basekernel}"
190 _kernver="$(make kernelrelease)"
192 mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
193 make INSTALL_MOD_PATH="${pkgdir}" modules_install
194 cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-linux-ck"
197 install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
199 # install fallback mkinitcpio.conf file and preset file for kernel
200 install -D -m644 "${srcdir}/linux-ck.preset" "${pkgdir}/etc/mkinitcpio.d/linux-ck.preset"
202 # set correct depmod command for install
204 -e "s/KERNEL_NAME=.*/KERNEL_NAME=-ck/g" \
205 -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
206 -i "${startdir}/linux-ck.install"
208 -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-linux-ck\"|g" \
209 -e "s|default_image=.*|default_image=\"/boot/initramfs-linux-ck.img\"|g" \
210 -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-linux-ck-fallback.img\"|g" \
211 -i "${pkgdir}/etc/mkinitcpio.d/linux-ck.preset"
213 # remove build and source links
214 rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
215 # remove the firmware
216 rm -rf "${pkgdir}/lib/firmware"
217 # gzip -9 all modules to save 100MB of space
218 find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
219 # make room for external modules
220 ln -s "../extramodules-${_basekernel}${_kernelname:ck}" "${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-${_basekernel}${_kernelname:ck}"
223 echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:ck}/version"
226 package_linux-ck-headers() {
227 _Hpkgdesc='Header files and scripts to build modules for linux-ck.'
228 pkgdesc="${_Hpkgdesc}"
229 provides=("linux-ck-headers=${pkgver}")
230 conflicts=('kernel26-ck-headers')
231 replaces=('kernel26-ck-headers')
232 #groups=('ck-generic')
234 mkdir -p "${pkgdir}/lib/modules/${_kernver}"
236 cd "${pkgdir}/lib/modules/${_kernver}"
237 ln -sf ../../../usr/src/linux-${_kernver} build
239 cd "${srcdir}/linux-${_basekernel}"
240 install -D -m644 Makefile \
241 "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
242 install -D -m644 kernel/Makefile \
243 "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
244 install -D -m644 .config \
245 "${pkgdir}/usr/src/linux-${_kernver}/.config"
247 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
249 for i in acpi asm-generic config crypto drm generated linux math-emu \
250 media net pcmcia scsi sound trace video xen; do
251 cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
254 # copy arch includes for external modules
255 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
256 cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
258 # copy files necessary for later builds, like nvidia and vmware
259 cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
260 cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
262 # fix permissions on scripts dir
263 chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
264 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
266 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
268 cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
270 if [ "${CARCH}" = "i686" ]; then
271 cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
274 cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
276 # add headers for lirc package
277 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
279 cp drivers/media/video/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
281 for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
282 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
283 cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
286 # add docbook makefile
287 install -D -m644 Documentation/DocBook/Makefile \
288 "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
291 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
292 cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
295 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
296 cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
298 # add wireless headers
299 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
300 cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
302 # add dvb headers for external modules
304 # http://bugs.archlinux.org/task/9912
305 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
306 cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
308 # http://bugs.archlinux.org/task/11194
309 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
310 [[ -e include/config/dvb/ ]] && cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
312 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
314 # http://bugs.archlinux.org/task/13146
315 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
316 cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
317 cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
321 # http://bugs.archlinux.org/task/20402
322 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
323 cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
324 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
325 cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
326 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
327 cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
329 # add xfs and shmem for aufs building
330 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
331 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
332 cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
334 # copy in Kconfig files
335 for i in `find . -name "Kconfig*"`; do
336 mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
337 cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
340 chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
341 find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
343 # strip scripts directory
344 find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
345 case "$(file -bi "${binary}")" in
346 *application/x-sharedlib*) # Libraries (.so)
347 /usr/bin/strip ${STRIP_SHARED} "${binary}";;
348 *application/x-archive*) # Libraries (.a)
349 /usr/bin/strip ${STRIP_STATIC} "${binary}";;
350 *application/x-executable*) # Binaries
351 /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
355 # remove unneeded architectures
356 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}
358 # Global pkgdesc and depends are here so that they will be picked up by AUR
359 pkgdesc='Linux Kernel and modules with the ck1 patchset featuring Brain Fuck Scheduler v0.416.'