1 # Contributor: JokerBoy <jokerboy at punctweb dot ro>
2 # Contributor: <fsckdaemon at gmail dot com>
3 # Contributor: graysky <graysky AT archlinux dot us>
4 # Contributor: Tobias Powalowski <tpowa@archlinux.org>
5 # Contributor: Thomas Baechler <thomas@archlinux.org>
7 ### Patch and Build Options ###
8 _USE_MAKENCONFIG="n" # tweak kernel options prior to a build via nconfig
9 _USE_LOCALMODCFG="n" # compile ONLY probed modules
10 _USE_CURRENT_CFG="n" # use the current kernel's .config file
12 ### More Details and References ###
14 # Allow you to select additional kernel options prior to a build via a nconfig.
16 ## LOCALMODCONFIG OPTION
17 # As of mainline 2.6.32, running with this option will only build the modules that you currently have
18 # probed in your system VASTLY reducing the number of modules build.
20 # WARNING - make CERTAIN that all modules are modprobed BEFORE you begin making the pkg!
21 # Read, https://bbs.archlinux.org/viewtopic.php?pid=830221#p830221
22 # To keep track of which modules are needed for your specific system/hardware, give graysky's module_db script.
23 # a try: http://aur.archlinux.org/packages.php?ID=41689
25 # Note that if you use module_db script, this PKGBUILD will auto run the reload_data base for you to probe
26 # all the modules you have logged!
28 ## CURRENT KERNEL'S .CONFIG
29 # Enabling this option will use the .config of the RUNNING kernel rather than the ARCH defaults.
30 # Useful when the package gets updated and you already went through the trouble of customizing your
31 # config options. NOT recommended when a new kernel is released, but again, convenient for package bumps.
34 true && pkgbase=linux-bfs
35 true && pkgname=('linux-bfs' 'linux-bfs-headers')
36 _kernelname=${pkgname#linux}
41 arch=('i686' 'x86_64')
42 url="http://ck-hack.blogspot.com/"
45 _bfspatch="${_basekernel}-sched-bfs-${_bfsrel}.patch"
46 source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.2.tar.xz"
47 #"http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.xz"
48 # the main kernel config files
49 'config' 'config.x86_64'
51 "http://ck.kolivas.org/patches/bfs/3.2.0/${_bfspatch}"
52 # standard config files for mkinitcpio ramdisk
54 'change-default-console-loglevel.patch'
55 'i915-fix-ghost-tv-output.patch')
56 md5sums=('364066fa18767ec0ae5f4e4abcf9dc51'
57 'b0f39e0f830d8986caeea90bf55864e2'
58 'ea24aee5987ad4c10a808b1dfc354768'
59 '18d5f982d4d21446a32843f9eb766ff0'
60 '19af8b861a9a46ddf9c480b57b728f3e'
61 '9d3c56a4b999c8bfbd4018089a62f662'
62 '263725f20c0b9eb9c353040792d644e5')
65 cd "${srcdir}/linux-${_basekernel}"
68 #patch -p1 -i "${srcdir}/patch-${pkgver}"
70 # add latest fixes from stable queue, if needed
71 # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
73 # Some chips detect a ghost TV output
74 # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
75 # Arch Linux bug report: FS#19234
77 # It is unclear why this patch wasn't merged upstream, it was accepted,
78 # then dropped because the reasoning was unclear. However, it is clearly
80 patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
82 # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
83 # remove this when a Kconfig knob is made available by upstream
84 # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
85 patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
87 # Patch source with BFS patches
88 msg "Patching source with BFS patches"
89 patch -Np1 -i "${srcdir}/${_bfspatch}"
91 msg "Running make mrproper to clean source tree"
94 if [ "${CARCH}" = "x86_64" ]; then
95 cat "${srcdir}/config.x86_64" > ./.config
97 cat "${srcdir}/config" > ./.config
100 # Use current kernel's config
101 # Code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
102 if [ "${_USE_CURRENT_CFG}" = "y" ]; then
103 if [[ -s /proc/config.gz ]]; then
104 msg "Extracting config from /proc/config.gz"
106 zcat /proc/config.gz > ./.config
108 warning "You kernel was not compiled with IKCONFIG_PROC!"
109 warning "You cannot read the current config!"
115 if [ "${_kernelname}" != "" ]; then
116 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
119 # set extraversion to pkgrel
120 sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
122 msg "Running make prepare for you to enable patched options of your choosing"
125 if [ "${_USE_LOCALMODCFG}" = "y" ]; then
126 msg "If you have modprobe_db installed, running reload_database now"
127 # Optionally load needed modules for the make localmodconfig
128 # See http://aur.archlinux.org/packages.php?ID=41689
129 if [ -e /usr/bin/reload_database ]; then
130 [[ ! -x /usr/bin/sudo ]] && echo "Cannot call modprobe with sudo. Install via pacman -S sudo and configure to work with this user." && return 1
131 sudo /usr/bin/reload_database
133 msg "Running Steven Rostedt's make localmodconfig now"
137 if [ "${_USE_MAKENCONFIG}" = "y" ]; then
138 msg "Running make nconfig"
140 #msg "Stopping build"
146 msg "Running make bzImage and modules"
147 make ${MAKEFLAGS} bzImage modules
150 package_linux-bfs() {
151 pkgdesc="The Linux Kernel and modules with BFS scheduler"
152 depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
153 optdepends=('crda: to set the correct wireless channels of your country')
154 provides=('kernel26-bfs')
155 conflicts=('kernel26-bfs')
156 replaces=('kernel26-bfs')
157 backup=("etc/mkinitcpio.d/${pkgname}.preset")
158 install=${pkgname}.install
160 cd "${srcdir}/linux-${_basekernel}"
165 _kernver="$(make kernelrelease)"
167 mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
168 make INSTALL_MOD_PATH="${pkgdir}" modules_install
169 cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"
172 install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
174 # install fallback mkinitcpio.conf file and preset file for kernel
175 install -D -m644 "${srcdir}/${pkgname}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
177 # set correct depmod command for install
179 -e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
180 -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
181 -i "${startdir}/${pkgname}.install"
183 -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|g" \
184 -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|g" \
185 -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|g" \
186 -i "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
188 # remove build and source links
189 rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
190 # remove the firmware
191 rm -rf "${pkgdir}/lib/firmware"
192 # gzip -9 all modules to save 100MB of space
193 find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
194 # make room for external modules
195 ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
196 # add real version for building modules and running depmod from post_install/upgrade
197 mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}"
198 echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}/version"
201 package_linux-bfs-headers() {
202 true && pkgdesc="Header files and scripts for building modules for linux-bfs kernel"
203 true && provides=('kernel26-bfs-headers')
204 true && conflicts=('kernel26-bfs-headers')
205 true && replaces=('kernel26-bfs-headers')
207 mkdir -p "${pkgdir}/lib/modules/${_kernver}"
209 cd "${pkgdir}/lib/modules/${_kernver}"
210 ln -sf ../../../usr/src/linux-${_kernver} build
212 cd "${srcdir}/linux-${_basekernel}"
213 install -D -m644 Makefile \
214 "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
215 install -D -m644 kernel/Makefile \
216 "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
217 install -D -m644 .config \
218 "${pkgdir}/usr/src/linux-${_kernver}/.config"
220 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
222 for i in acpi asm-generic config crypto drm generated linux math-emu \
223 media net pcmcia scsi sound trace video xen; do
224 cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
227 # copy arch includes for external modules
228 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
229 cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
231 # copy files necessary for later builds, like nvidia and vmware
232 cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
233 cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
235 # fix permissions on scripts dir
236 chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
237 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
239 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
241 cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
243 if [ "${CARCH}" = "i686" ]; then
244 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"
252 cp drivers/media/video/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
254 for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
255 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
256 cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
259 # add docbook makefile
260 install -D -m644 Documentation/DocBook/Makefile \
261 "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
264 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
265 cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
268 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
269 cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
271 # add wireless headers
272 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
273 cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
275 # add dvb headers for external modules
277 # http://bugs.archlinux.org/task/9912
278 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
279 cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
281 # http://bugs.archlinux.org/task/11194
282 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
283 [[ -e include/config/dvb/ ]] && cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
285 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
287 # http://bugs.archlinux.org/task/13146
288 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
289 cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
290 cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
294 # http://bugs.archlinux.org/task/20402
295 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
296 cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
297 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
298 cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
299 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
300 cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
302 # add xfs and shmem for aufs building
303 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
304 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
305 cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
307 # copy in Kconfig files
308 for i in `find . -name "Kconfig*"`; do
309 mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
310 cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
313 chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
314 find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
316 # strip scripts directory
317 find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
318 case "$(file -bi "${binary}")" in
319 *application/x-sharedlib*) # Libraries (.so)
320 /usr/bin/strip ${STRIP_SHARED} "${binary}";;
321 *application/x-archive*) # Libraries (.a)
322 /usr/bin/strip ${STRIP_STATIC} "${binary}";;
323 *application/x-executable*) # Binaries
324 /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
328 # remove unneeded architectures
329 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}
332 # vim:set ts=2 sw=2 et: