1 # Contributor: JokerBoy <jokerboy at punctweb dot ro>
2 # Contributor: <fsckdaemon at gmail dot com>
3 # Contributor: graysky <graysky AT archlinux dot us>
5 ### Patch and Build Options ###
6 _USE_MAKENCONFIG="n" # nconfig option
7 _USE_BFQ_IOSCHED="n" # add BFQ patches for the BFQ I/O scheduler
8 _USE_LOCALMODCFG="n" # make localmod config - compile ONLY probed modules - see notes below!
9 _USE_CURRENT_CFG="n" # use the current kernel's .config file - see notes below!
11 ### More Details and References ###
13 # Allow you to select additional kernel options prior to a build via a nconfig.
16 # Read, http://algo.ing.unimo.it/people/paolo/disk_sched/
18 ## LOCALMODCONFIG OPTION
19 # As of mainline 2.6.32, running with this option will only build the modules that you currently have
20 # probed in your system VASTLY reducing the number of modules build.
22 # WARNING - make CERTAIN that all modules are modprobed BEFORE you begin making the pkg!
23 # Read, https://bbs.archlinux.org/viewtopic.php?pid=830221#p830221
24 # To keep track of which modules are needed for your specific system/hardware, give graysky's module_db script.
25 # a try: http://aur.archlinux.org/packages.php?ID=41689
27 # Note that if you use module_db script, this PKGBUILD will auto run the reload_data base for you to probe
28 # all the modules you have logged!
30 ## CURRENT KERNEL'S .CONFIG
31 # Enabling this option will use the .config of the RUNNING kernel rather than the ARCH defaults.
32 # Useful when the package gets updated and you already went through the trouble of customizing your
33 # config options. NOT recommended when a new kernel is released, but again, convenient for package bumps.
36 true && pkgbase=kernel26-bfs
37 true && pkgname=('kernel26-bfs' 'kernel26-bfs-headers')
38 _kernelname=${pkgname#kernel26}
41 pkgver=${_basekernel}.3
43 arch=('i686' 'x86_64')
44 url="http://ck-hack.blogspot.com"
46 pkgdesc="Linux kernel and modules with BFS scheduler, with BFQ I/O scheduler as optional."
47 makedepends=('coreutils' 'linux-firmware' 'module-init-tools>=3.12-2' 'mkinitcpio>=0.6.8-2')
49 _archpatch="patch-${pkgver}-1-ARCH"
50 _gcc460patch="${_basekernel}-disable-wunused-but-set-var-gcc-4-6-0.patch"
51 _bfspatch="${_basekernel}-sched-bfs-${_bfsrel}.patch"
52 _bfqpath="http://algo.ing.unimo.it/people/paolo/disk_sched/patches/${_basekernel}"
53 _bfqpatch1="0001-block-prepare-I-O-context-code-for-BFQ-v2-for-${_basekernel}.patch"
54 _bfqpatch2="0002-block-cgroups-kconfig-build-bits-for-BFQ-v2-${_basekernel}.patch"
55 _bfqpatch3="0003-block-introduce-the-BFQ-v2-I-O-sched-for-${_basekernel}.patch"
56 source=("ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-${_basekernel}.tar.bz2"
57 "ftp://ftp.archlinux.org/other/kernel26/${_archpatch}.bz2"
58 'config' 'config.x86_64' 'kernel26.preset'
60 "http://ck.kolivas.org/patches/bfs/${_basekernel}/${_bfspatch}"
61 "${_bfqpath}/${_bfqpatch1}"
62 "${_bfqpath}/${_bfqpatch2}"
63 "${_bfqpath}/${_bfqpatch3}")
64 sha256sums=('584d17f2a3ee18a9501d7ff36907639e538cfdba4529978b8550c461d45c61f6' # Linux kernel
65 '752445f22d2746bedd79846c1e78ece31b434eae613c2c256e17ad77cf1a9029' # Arch kernel patches
66 '4ecc29d6a509692c7d7e5e0c0eb96ffbdb1a2fee8c4c5be18befc187b301a737' # config
67 '69c971f9e219344d36b13e1d6ee1928b30c9a9b210c44d1196fa1162c61db680' # config.x86_64
68 'e25580bb1f9e904e23ebb648b8327b2adbb1579143ad8c8edbb6c912703f3488' # kernel26.preset
69 'ba74e08c4a6104d605d332dfb3e49a016d385be2421f1b53e20cd2148c15219b' # gcc patch
70 '19f05242cc4969c2d1348c88e5cc6948ff7fd5d778f4ca90d34b8b123a7f7a3f' # BFS patch
71 '7051be08f3318503c30d18f6b18937648074cfccc8c1e052cd296afab47d50fe' # BFQ patch 1
72 '0b2bae2acabae85f05913b6c2a1d49e5b19f913df38564bd5eed1ebf884406e0' # BFQ patch 2
73 '93d0c86c11e17dc0c3d89ba509537f7f0516bde52189b8c5ef27584871e4b368') # BFQ patch 3
76 cd "${srcdir}/linux-${_basekernel}"
78 # Patch source with -ARCH patches
79 # See http://projects.archlinux.org/linux-2.6-ARCH.git/
80 msg "Patching source with -ARCH patches"
81 patch -Np1 -i "${srcdir}/${_archpatch}"
83 msg "Patching source with gcc460patch"
84 patch -Np1 -i "${srcdir}/${_gcc460patch}"
86 # Patch source with BFS patches
87 msg "Patching source with BFS patches"
88 patch -Np1 -i "${srcdir}/${_bfspatch}"
90 # Optionally patch source with BFQ patches
91 if [ "${_USE_BFQ_IOSCHED}" = "y" ]; then
92 msg "Patching source with BFQ patches"
93 patch -Np1 -i "${srcdir}/${_bfqpatch1}"
94 patch -Np1 -i "${srcdir}/${_bfqpatch2}"
95 patch -Np1 -i "${srcdir}/${_bfqpatch3}"
98 msg "Running make mrproper to clean source tree"
101 if [ "$CARCH" = "x86_64" ]; then
102 cat ../config.x86_64 >./.config
104 cat ../config >./.config
106 # Use current kernel's config
107 # Code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
108 if [ "${_USE_CURRENT_CFG}" = "y" ]; then
109 if [[ -s /proc/config.gz ]]; then
110 msg "Extracting config from /proc/config.gz..."
112 zcat /proc/config.gz > ./.config
114 warning "You kernel was not compiled with IKCONFIG_PROC!"
115 warning "You cannot read the current config!"
121 if [ "${_kernelname}" != "" ]; then
122 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
125 msg "Running make prepare for you to enable patched options of your choosing"
128 # If user patched to BFQ and enabled it in the prev step, set it as default io scheduler
129 if [ "${_USE_BFQ_IOSCHED}" = "y" ]; then
130 sed -i s'/CONFIG_DEFAULT_CFQ=y/# CONFIG_DEFAULT_CFQ is not set/g' ./.config
131 sed -i s'/# CONFIG_DEFAULT_BFQ is not set/CONFIG_DEFAULT_BFQ=y/g' ./.config
132 sed -i s'/CONFIG_DEFAULT_IOSCHED="cfq"/CONFIG_DEFAULT_IOSCHED="bfq"/g' ./.config
135 if [ "${_USE_LOCALMODCFG}" = "y" ]; then
136 msg "If you have modprobe_db installed, running reload_database now"
137 # Optionally load needed modules for the make localmodconfig
138 # See http://aur.archlinux.org/packages.php?ID=41689
139 if [ -e /usr/bin/reload_database ]; then
140 /usr/bin/reload_database
142 msg "Running Steven Rostedt's make localmodconfig now"
146 if [ "${_USE_MAKENCONFIG}" = "y" ]; then
147 msg "Running make nconfig"
149 #msg "Stopping build"
155 msg "Running make bzImage and modules"
156 make ${MAKEFLAGS} bzImage modules
159 package_kernel26-bfs() {
160 backup=("etc/mkinitcpio.d/${pkgname}.preset")
161 depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.12-2' 'mkinitcpio>=0.6.8-2')
162 # pwc, ieee80211 and hostap-driver26 modules are included in kernel26 now
163 # nforce package support was abandoned by nvidia, kernel modules should cover everything now.
164 # kernel24 support is dropped since glibc24
165 replaces=('kernel24' 'kernel24-scsi' 'kernel26-scsi'
166 'alsa-driver' 'ieee80211' 'hostap-driver26'
167 'pwc' 'nforce' 'squashfs' 'unionfs' 'ivtv'
168 'zd1211' 'kvm-modules' 'iwlwifi' 'rt2x00-cvs'
169 'gspcav1' 'atl2' 'wlan-ng26' 'rt2500' 'nouveau-drm')
170 install=kernel26.install
171 optdepends=('crda: to set the correct wireless channels of your country'
172 'nvidia-bfs: nvidia drivers for kernel26-bfs'
173 'nvidia-bfs-beta: nvidia BETA drivers for kernel26-bfs'
174 'modprobed_db: Keeps track of EVERY kernel module that has ever been probed - useful for those who use make localmodconfig')
177 cd ${srcdir}/linux-${_basekernel}
179 _kernver="$(make kernelrelease)"
180 mkdir -p ${pkgdir}/{lib/modules,lib/firmware,boot}
181 make INSTALL_MOD_PATH=${pkgdir} modules_install
182 cp System.map ${pkgdir}/boot/System.map26${_kernelname}
183 cp arch/$KARCH/boot/bzImage ${pkgdir}/boot/vmlinuz26${_kernelname}
185 install -m644 -D vmlinux ${pkgdir}/usr/src/linux-${_kernver}/vmlinux
187 # install fallback mkinitcpio.conf file and preset file for kernel
188 install -m644 -D ${srcdir}/kernel26.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
189 # set correct depmod command for install
191 -e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
192 -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
193 -i ${startdir}/kernel26.install
195 -e "s|source .*|source /etc/mkinitcpio.d/kernel26${_kernelname}.kver|g" \
196 -e "s|default_image=.*|default_image=\"/boot/${pkgname}.img\"|g" \
197 -e "s|fallback_image=.*|fallback_image=\"/boot/${pkgname}-fallback.img\"|g" \
198 -i ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
200 echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${pkgdir}/etc/mkinitcpio.d/${pkgname}.kver
201 # remove build and source links
202 rm -f ${pkgdir}/lib/modules/${_kernver}/{source,build}
203 # remove the firmware
204 rm -rf ${pkgdir}/lib/firmware
205 # gzip -9 all modules to safe 100MB of space
206 find "$pkgdir" -name '*.ko' -exec gzip -9 {} \;
209 package_kernel26-bfs-headers() {
210 true && pkgdesc="Header files and scripts for building modules for kernel26-bfs"
211 true && depends=("kernel26-bfs=${pkgver}")
213 mkdir -p ${pkgdir}/lib/modules/${_kernver}
214 cd ${pkgdir}/lib/modules/${_kernver}
215 ln -sf ../../../usr/src/linux-${_kernver} build
216 cd ${srcdir}/linux-$_basekernel
217 install -D -m644 Makefile \
218 ${pkgdir}/usr/src/linux-${_kernver}/Makefile
219 install -D -m644 kernel/Makefile \
220 ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
221 install -D -m644 .config \
222 ${pkgdir}/usr/src/linux-${_kernver}/.config
223 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include
225 for i in acpi asm-generic config crypto drm generated linux math-emu \
226 media net pcmcia scsi sound trace video xen; do
227 cp -a include/$i ${pkgdir}/usr/src/linux-${_kernver}/include/
230 # copy arch includes for external modules
231 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/x86
232 cp -a arch/x86/include ${pkgdir}/usr/src/linux-${_kernver}/arch/x86/
234 # copy files necessary for later builds, like nvidia and vmware
235 cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
236 cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}
237 # fix permissions on scripts dir
238 chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
239 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions
241 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel
243 cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
244 if [ "$CARCH" = "i686" ]; then
245 cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
247 cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/
249 # add headers for lirc package
250 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video
251 cp drivers/media/video/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/
252 for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
253 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
254 cp -a drivers/media/video/$i/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
256 # add docbook makefile
257 install -D -m644 Documentation/DocBook/Makefile \
258 ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
260 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
261 cp drivers/md/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
263 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/linux
264 cp include/linux/inotify.h ${pkgdir}/usr/src/linux-${_kernver}/include/linux/
265 # add wireless headers
266 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
267 cp net/mac80211/*.h ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
268 # add dvb headers for external modules
270 # http://bugs.archlinux.org/task/9912
271 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
272 cp drivers/media/dvb/dvb-core/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
273 # add dvb headers for external modules
275 # http://bugs.archlinux.org/task/11194
276 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
277 [[ -e include/config/dvb/ ]] && cp include/config/dvb/*.h ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
278 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
280 # http://bugs.archlinux.org/task/13146
281 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
282 cp drivers/media/dvb/frontends/lgdt330x.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
283 cp drivers/media/video/msp3400-driver.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
286 # http://bugs.archlinux.org/task/20402
287 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb
288 cp drivers/media/dvb/dvb-usb/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/
289 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends
290 cp drivers/media/dvb/frontends/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
291 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners
292 cp drivers/media/common/tuners/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/
293 # add xfs and shmem for aufs building
294 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs
295 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/mm
296 cp fs/xfs/xfs_sb.h ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h
297 # copy in Kconfig files
298 for i in `find . -name "Kconfig*"`; do
299 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
300 cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
303 chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
304 find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
305 # strip scripts directory
306 find ${pkgdir}/usr/src/linux-${_kernver}/scripts -type f -perm -u+w 2>/dev/null | while read binary ; do
307 case "$(file -bi "$binary")" in
308 *application/x-sharedlib*) # Libraries (.so)
309 /usr/bin/strip $STRIP_SHARED "$binary";;
310 *application/x-archive*) # Libraries (.a)
311 /usr/bin/strip $STRIP_STATIC "$binary";;
312 *application/x-executable*) # Binaries
313 /usr/bin/strip $STRIP_BINARIES "$binary";;
316 # remove unneeded architectures
317 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}
320 # vim: ts=2 sts=2 sw=2 et: