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 # Do NOT enable the BFQ patch - currently Paolo has not yet released a BFQ for the 3.2 tree!
10 _BFQ_enable_="n" # enable BFQ as the default I/O scheduler
13 # DETAILS FOR _localmodcfg="y"
14 # As of mainline 2.6.32, running with this option will only build the modules that you currently have
15 # probed in your system VASTLY reducing the number of modules built and the build time to do it.
17 # WARNING - make CERTAIN that all modules are modprobed BEFORE you begin making the pkg!
19 # To keep track of which modules are needed for your specific system/hardware, give my module_db script
20 # a try: http://aur.archlinux.org/packages.php?ID=41689 Note that if you use my script, this PKGBUILD
21 # will auto run the reload_data base for you to probe all the modules you have logged!
23 # More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed_db
25 # DETAILS FOR _use_current="y"
26 # Enabling this option will use the .config of the RUNNING kernel rather than the ARCH defaults.
27 # Useful when the package gets updated and you already went through the trouble of customizing your
28 # config options. NOT recommended when a new kernel is released, but again, convenient for package bumps.
30 # DETAILS FOR _BFQ_enable="y"
31 # Alternative I/O scheduler by Paolo. For more, see: http://algo.ing.unimo.it/people/paolo/disk_sched/
34 true && pkgname=(linux-ck linux-ck-headers)
39 arch=('i686' 'x86_64')
40 url="https://wiki.archlinux.org/index.php/linux-ck"
43 _ckpatchname="3.2-sched-bfs-416.patch"
45 #_ckpatchname="patch-${_basekernel}.0-ck${_ckpatchversion}"
46 #_bfqpath="http://algo.ing.unimo.it/people/paolo/disk_sched/patches/3.1.0-v3r1"
48 source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.2.tar.xz"
49 "http://ck.kolivas.org/patches/bfs/3.2.0/${_ckpatchname}"
50 #"http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.gz"
51 #"http://ck.kolivas.org/patches/3.0/3.1/${_basekernel}.0-ck${_ckpatchversion}/${_ckpatchname}.bz2"
52 'config' 'config.x86_64' 'change-default-console-loglevel.patch' 'i915-fix-ghost-tv-output.patch'
53 'linux-ck.install' 'linux-ck.preset')
54 #"${_bfqpath}/0001-block-prepare-I-O-context-code-for-BFQ-v3r1-for-3.1.patch"
55 #"${_bfqpath}/0002-block-cgroups-kconfig-build-bits-for-BFQ-v3r1-3.1.patch"
56 #"${_bfqpath}/0003-block-introduce-the-BFQ-v3r1-I-O-sched-for-3.1.patch")
57 sha256sums=('dd96ed02b53fb5d57762e4b1f573460909de472ca588f81ec6660e4a172e7ba7'
58 'a3e9f003bcebe93bc9b7565e822387758fd0e76d36d081044149f49016d2585a'
59 'ac2c8a6e8d0024bdba0b749a127903221a51c24d37e74fbfd4cf7f7befe93226'
60 '39069e3a02626d162598748e2ca6e060afb989dc7743d195920bbf40c85164f7'
61 'b9d79ca33b0b51ff4f6976b7cd6dbb0b624ebf4fbf440222217f8ffc50445de4'
62 '9ccadbe3eb30bb283af3eb869c3a4bdb764628854811cc616a2e02e9ef398705'
63 '1aaea6798c6cbc0197c2b04c0635ed7beac59a832ff91ac610320a1d2e11e047'
64 'c2cf8cc2600502de348f3dc3aae9a3bde5486759db15cb8a93df7aa35bd6e7da')
67 cd "${srcdir}/linux-${_basekernel}"
70 # patch -p1 -i "${srcdir}/patch-${pkgver}"
72 # add latest fixes from stable queue, if needed
73 # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
75 # Some chips detect a ghost TV output
76 # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
77 # Arch Linux bug report: FS#19234
79 # It is unclear why this patch wasn't merged upstream, it was accepted,
80 # then dropped because the reasoning was unclear. However, it is clearly
82 patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
84 # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
85 # remove this when a Kconfig knob is made available by upstream
86 # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
87 patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
89 ### Patch source with ck patchset with BFS
90 # Fix double name in EXTRAVERSION
91 sed -i -re "s/^(.EXTRAVERSION).*$/\1 = /" "${srcdir}/${_ckpatchname}"
92 msg "Patching source with bfs v0.416"
93 patch -Np1 -i "${srcdir}/${_ckpatchname}"
95 ### Patch with BFQ IO Scheduler
96 #msg "Patching source with BFQ patches"
97 #for p in $(ls ${srcdir}/000*.patch); do
101 ### Clean tree and copy ARCH config over
102 msg "Running make mrproper to clean source tree"
105 if [ "${CARCH}" = "x86_64" ]; then
106 cat "${srcdir}/config.x86_64" > ./.config
108 cat "${srcdir}/config" > ./.config
111 ### Optionally use running kernel's config
112 # code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
113 if [ $_use_current = "y" ]; then
114 if [[ -s /proc/config.gz ]]; then
115 msg "Extracting config from /proc/config.gz..."
117 zcat /proc/config.gz > ./.config
119 warning "You kernel was not compiled with IKCONFIG_PROC!"
120 warning "You cannot read the current config!"
126 if [ "${_kernelname}" != "" ]; then
127 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
130 ### BFQ to be compiled in but not enabled
131 #sed -i -e s'/CONFIG_CFQ_GROUP_IOSCHED=y/CONFIG_CFQ_GROUP_IOSCHED=y\nCONFIG_IOSCHED_BFQ=y\nCONFIG_CGROUP_BFQIO=y/' \
132 # -i -e s'/CONFIG_DEFAULT_CFQ=y/CONFIG_DEFAULT_CFQ=y\n# CONFIG_DEFAULT_BFQ is not set/' ./.config
134 ### Optionally enable BFQ as the default io scheduler
135 #if [ $_BFQ_enable_ = "y" ]; then
136 # sed -i -e '/CONFIG_DEFAULT_IOSCHED/ s,cfq,bfq,' \
137 # -i -e s'/CONFIG_DEFAULT_CFQ=y/# CONFIG_DEFAULT_CFQ is not set\nCONFIG_DEFAULT_BFQ=y/' ./.config
140 # set extraversion to pkgrel
141 sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
144 msg "Running make prepare for you to enable patched options of your choosing"
147 ### Optionally load needed modules for the make localmodconfig
148 # See http://aur.archlinux.org/packages.php?ID=41689
149 if [ $_localmodcfg = "y" ]; then
150 msg "If you have modprobe_db installed, running reload_database now"
151 if [ -e /usr/bin/reload_database ]; then
152 [[ ! -x /usr/bin/sudo ]] && echo "Cannot call modprobe with sudo. Install via pacman -S sudo and configure to work with this user." && exit 1
153 sudo /usr/bin/reload_database
155 msg "Running Steven Rostedt's make localmodconfig now"
159 if [ $_makenconfig = "y" ]; then
160 msg "Running make nconfig"
164 msg "Running make bzImage and modules"
165 make ${MAKEFLAGS} bzImage modules
169 _Kpkgdesc='Linux Kernel and modules with Brain Fuck Scheduler v0.416.'
170 pkgdesc="${_Kpkgdesc}"
171 depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
172 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')
173 provides=("linux-ck=${pkgver}")
174 conflicts=('kernel26-ck')
175 replaces=('kernel26-ck')
176 backup=("etc/mkinitcpio.d/linux-ck.preset")
177 install=linux-ck.install
178 #groups=('ck-generic')
180 cd "${srcdir}/linux-${_basekernel}"
185 _kernver="$(make kernelrelease)"
187 mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
188 make INSTALL_MOD_PATH="${pkgdir}" modules_install
189 cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-linux-ck"
192 install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
194 # install fallback mkinitcpio.conf file and preset file for kernel
195 install -D -m644 "${srcdir}/linux-ck.preset" "${pkgdir}/etc/mkinitcpio.d/linux-ck.preset"
197 # set correct depmod command for install
199 -e "s/KERNEL_NAME=.*/KERNEL_NAME=-ck/g" \
200 -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
201 -i "${startdir}/linux-ck.install"
203 -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-linux-ck\"|g" \
204 -e "s|default_image=.*|default_image=\"/boot/initramfs-linux-ck.img\"|g" \
205 -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-linux-ck-fallback.img\"|g" \
206 -i "${pkgdir}/etc/mkinitcpio.d/linux-ck.preset"
208 # remove build and source links
209 rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
210 # remove the firmware
211 rm -rf "${pkgdir}/lib/firmware"
212 # gzip -9 all modules to save 100MB of space
213 find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
214 # make room for external modules
215 ln -s "../extramodules-${_basekernel}${_kernelname:ck}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
216 # add real version for building modules and running depmod from post_install/upgrade
217 mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:ck}"
218 echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:ck}/version"
221 package_linux-ck-headers() {
222 _Hpkgdesc='Header files and scripts to build modules for linux-ck.'
223 pkgdesc="${_Hpkgdesc}"
224 provides=("linux-ck-headers=${pkgver}")
225 conflicts=('kernel26-ck-headers')
226 replaces=('kernel26-ck-headers')
227 #groups=('ck-generic')
229 mkdir -p "${pkgdir}/lib/modules/${_kernver}"
231 cd "${pkgdir}/lib/modules/${_kernver}"
232 ln -sf ../../../usr/src/linux-${_kernver} build
234 cd "${srcdir}/linux-${_basekernel}"
235 install -D -m644 Makefile \
236 "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
237 install -D -m644 kernel/Makefile \
238 "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
239 install -D -m644 .config \
240 "${pkgdir}/usr/src/linux-${_kernver}/.config"
242 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
244 for i in acpi asm-generic config crypto drm generated linux math-emu \
245 media net pcmcia scsi sound trace video xen; do
246 cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
249 # copy arch includes for external modules
250 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
251 cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
253 # copy files necessary for later builds, like nvidia and vmware
254 cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
255 cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
257 # fix permissions on scripts dir
258 chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
259 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
261 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
263 cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
265 if [ "${CARCH}" = "i686" ]; then
266 cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
269 cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
271 # add headers for lirc package
272 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
274 cp drivers/media/video/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
276 for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
277 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
278 cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
281 # add docbook makefile
282 install -D -m644 Documentation/DocBook/Makefile \
283 "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
286 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
287 cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
290 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
291 cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
293 # add wireless headers
294 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
295 cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
297 # add dvb headers for external modules
299 # http://bugs.archlinux.org/task/9912
300 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
301 cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
303 # http://bugs.archlinux.org/task/11194
304 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
305 [[ -e include/config/dvb/ ]] && cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
307 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
309 # http://bugs.archlinux.org/task/13146
310 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
311 cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
312 cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
316 # http://bugs.archlinux.org/task/20402
317 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
318 cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
319 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
320 cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
321 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
322 cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
324 # add xfs and shmem for aufs building
325 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
326 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
327 cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
329 # copy in Kconfig files
330 for i in `find . -name "Kconfig*"`; do
331 mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
332 cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
335 chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
336 find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
338 # strip scripts directory
339 find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
340 case "$(file -bi "${binary}")" in
341 *application/x-sharedlib*) # Libraries (.so)
342 /usr/bin/strip ${STRIP_SHARED} "${binary}";;
343 *application/x-archive*) # Libraries (.a)
344 /usr/bin/strip ${STRIP_STATIC} "${binary}";;
345 *application/x-executable*) # Binaries
346 /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
350 # remove unneeded architectures
351 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}
353 # Global pkgdesc and depends are here so that they will be picked up by AUR
354 pkgdesc='Linux Kernel and modules with Brain Fuck Scheduler v0.416.'