updated on Fri Jan 13 00:14:41 UTC 2012
[aur-mirror.git] / linux-bfs / PKGBUILD
blob54bc5ecc8d5ab1977c1b5667c372d97379df7871
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 ###
13 ## MAKENCONFIG OPTION
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.
19  #
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
24  #
25  # Note that if you use module_db script, this PKGBUILD will auto run the modprobed_db 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.
33 pkgname=linux-bfs
34 true && pkgbase=linux-bfs
35 true && pkgname=('linux-bfs' 'linux-bfs-headers')
36 _kernelname=${pkgname#linux}
37 _basekernel=3.2
38 _bfsrel=416
39 pkgver=${_basekernel}.1
40 pkgrel=${_bfsrel}
41 arch=('i686' 'x86_64')
42 url="http://ck-hack.blogspot.com/"
43 license=('GPL2')
44 options=('!strip')
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'
50         # BFS patch
51         "http://ck.kolivas.org/patches/bfs/3.2.0/${_bfspatch}"
52         # standard config files for mkinitcpio ramdisk
53         "${pkgname}.preset"
54         'change-default-console-loglevel.patch'
55         'i915-fix-ghost-tv-output.patch')
56 md5sums=('364066fa18767ec0ae5f4e4abcf9dc51'
57          '62ac6ac9b870162f693ecf5e8606423a'
58          '4079a2ae3e2ee308e6db188f7bc04959'
59          '875b121a32a619e0ee262c541f330427'
60          '18d5f982d4d21446a32843f9eb766ff0'
61          '19af8b861a9a46ddf9c480b57b728f3e'
62          '9d3c56a4b999c8bfbd4018089a62f662'
63          '263725f20c0b9eb9c353040792d644e5')
65 build() {
66   cd "${srcdir}/linux-${_basekernel}"
68   # add upstream patch
69   patch -p1 -i "${srcdir}/patch-${pkgver}"
71   # add latest fixes from stable queue, if needed
72   # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
74   # Some chips detect a ghost TV output
75   # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
76   # Arch Linux bug report: FS#19234
77   #
78   # It is unclear why this patch wasn't merged upstream, it was accepted,
79   # then dropped because the reasoning was unclear. However, it is clearly
80   # needed.
81   patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
83   # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
84   # remove this when a Kconfig knob is made available by upstream
85   # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
86   patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
88   # Patch source with BFS patches
89   msg "Patching source with BFS patches"
90   patch -Np1 -i "${srcdir}/${_bfspatch}"
92   msg "Running make mrproper to clean source tree"
93   make mrproper
95   if [ "${CARCH}" = "x86_64" ]; then
96     cat "${srcdir}/config.x86_64" > ./.config
97   else
98     cat "${srcdir}/config" > ./.config
99   fi
101   # Use current kernel's config
102   # Code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
103   if [ "${_USE_CURRENT_CFG}" = "y" ]; then
104     msg "Running sudo modprobe configs"
105     sudo modprobe configs
106     if [[ -s /proc/config.gz ]]; then
107       msg "Extracting config from /proc/config.gz"
108       zcat /proc/config.gz > ./.config
109     else
110       warning "You kernel was not compiled with IKCONFIG_PROC!"
111       warning "You cannot read the current config!"
112       warning "Aborting!"
113       return 1
114     fi
115   fi
117   if [ "${_kernelname}" != "" ]; then
118     sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
119   fi
121   # set extraversion to pkgrel
122   sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
124   msg "Running make prepare for you to enable patched options of your choosing"
125   make prepare
127   if [ "${_USE_LOCALMODCFG}" = "y" ]; then
128     msg "If you have modprobe_db installed, running modprobed_db now"
129     # Optionally load needed modules for the make localmodconfig
130     # See http://aur.archlinux.org/packages.php?ID=41689
131     if [ -e /usr/bin/modprobed_db ]; then
132       [[ ! -x /usr/bin/sudo ]] && echo "Cannot call modprobe with sudo. Install via pacman -S sudo and configure to work with this user." && return 1
133       sudo /usr/bin/modprobed_db recall
134     fi
135     msg "Running Steven Rostedt's make localmodconfig now"
136     make localmodconfig
137   fi
139   if [ "${_USE_MAKENCONFIG}" = "y" ]; then
140     msg "Running make nconfig"
141     make nconfig
142     #msg "Stopping build"
143     #return 1
144   fi
146   yes "" | make config
148   msg "Running make bzImage and modules"
149   make ${MAKEFLAGS} bzImage modules
152 package_linux-bfs() {
153   pkgdesc="The Linux Kernel and modules with BFS scheduler"
154   depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
155   optdepends=('crda: to set the correct wireless channels of your country')
156   provides=('kernel26-bfs')
157   conflicts=('kernel26-bfs')
158   replaces=('kernel26-bfs')
159   backup=("etc/mkinitcpio.d/${pkgname}.preset")
160   install=${pkgname}.install
162   cd "${srcdir}/linux-${_basekernel}"
164   KARCH=x86
166   # get kernel version
167   _kernver="$(make kernelrelease)"
169   mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
170   make INSTALL_MOD_PATH="${pkgdir}" modules_install
171   cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"
173   # add vmlinux
174   install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
176   # install fallback mkinitcpio.conf file and preset file for kernel
177   install -D -m644 "${srcdir}/${pkgname}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
179   # set correct depmod command for install
180   sed \
181     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
182     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
183     -i "${startdir}/${pkgname}.install"
184   sed \
185     -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|g" \
186     -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|g" \
187     -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|g" \
188     -i "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
190   # remove build and source links
191   rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
192   # remove the firmware
193   rm -rf "${pkgdir}/lib/firmware"
194   # gzip -9 all modules to save 100MB of space
195   find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
196   # make room for external modules
197   ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
198   # add real version for building modules and running depmod from post_install/upgrade
199   mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}"
200   echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}/version"
203 package_linux-bfs-headers() {
204   true && pkgdesc="Header files and scripts for building modules for linux-bfs kernel"
205   true && provides=('kernel26-bfs-headers')
206   true && conflicts=('kernel26-bfs-headers')
207   true && replaces=('kernel26-bfs-headers')
209   mkdir -p "${pkgdir}/lib/modules/${_kernver}"
211   cd "${pkgdir}/lib/modules/${_kernver}"
212   ln -sf ../../../usr/src/linux-${_kernver} build
214   cd "${srcdir}/linux-${_basekernel}"
215   install -D -m644 Makefile \
216     "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
217   install -D -m644 kernel/Makefile \
218     "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
219   install -D -m644 .config \
220     "${pkgdir}/usr/src/linux-${_kernver}/.config"
222   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
224   for i in acpi asm-generic config crypto drm generated linux math-emu \
225     media net pcmcia scsi sound trace video xen; do
226     cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
227   done
229   # copy arch includes for external modules
230   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
231   cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
233   # copy files necessary for later builds, like nvidia and vmware
234   cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
235   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}/"
245   if [ "${CARCH}" = "i686" ]; then
246     cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
247   fi
249   cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
251   # add headers for lirc package
252   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
254   cp drivers/media/video/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
256   for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
257     mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
258     cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
259   done
261   # add docbook makefile
262   install -D -m644 Documentation/DocBook/Makefile \
263     "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
265   # add dm headers
266   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
267   cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
269   # add inotify.h
270   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
271   cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
273   # add wireless headers
274   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
275   cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
277   # add dvb headers for external modules
278   # in reference to:
279   # http://bugs.archlinux.org/task/9912
280   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
281   cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
282   # and...
283   # http://bugs.archlinux.org/task/11194
284   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
285   [[ -e include/config/dvb/ ]] && cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
287   # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
288   # in reference to:
289   # http://bugs.archlinux.org/task/13146
290   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
291   cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
292   cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
294   # add dvb headers
295   # in reference to:
296   # http://bugs.archlinux.org/task/20402
297   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
298   cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
299   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
300   cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
301   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
302   cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
304   # add xfs and shmem for aufs building
305   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
306   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
307   cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
309   # copy in Kconfig files
310   for i in `find . -name "Kconfig*"`; do
311     mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
312     cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
313   done
315   chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
316   find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
318   # strip scripts directory
319   find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
320     case "$(file -bi "${binary}")" in
321       *application/x-sharedlib*) # Libraries (.so)
322         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
323       *application/x-archive*) # Libraries (.a)
324         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
325       *application/x-executable*) # Binaries
326         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
327     esac
328   done
330   # remove unneeded architectures
331   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}
334 # vim:set ts=2 sw=2 et: