updated on Sun Jan 8 16:01:26 UTC 2012
[aur-mirror.git] / linux-bfs / PKGBUILD
blob69b774c68e059ad6dec9e51941918aa88956f1e4
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 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.
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}
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          'b0f39e0f830d8986caeea90bf55864e2'
58          'ea24aee5987ad4c10a808b1dfc354768'
59          '18d5f982d4d21446a32843f9eb766ff0'
60          '19af8b861a9a46ddf9c480b57b728f3e'
61          '9d3c56a4b999c8bfbd4018089a62f662'
62          '263725f20c0b9eb9c353040792d644e5')
64 build() {
65   cd "${srcdir}/linux-${_basekernel}"
67   # add upstream patch
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
76   #
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
79   # needed.
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"
92   make mrproper
94   if [ "${CARCH}" = "x86_64" ]; then
95     cat "${srcdir}/config.x86_64" > ./.config
96   else
97     cat "${srcdir}/config" > ./.config
98   fi
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"
105       modprobe configs
106       zcat /proc/config.gz > ./.config
107     else
108       warning "You kernel was not compiled with IKCONFIG_PROC!"
109       warning "You cannot read the current config!"
110       warning "Aborting!"
111       return 1
112     fi
113   fi
115   if [ "${_kernelname}" != "" ]; then
116     sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
117   fi
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"
123   make prepare
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
132     fi
133     msg "Running Steven Rostedt's make localmodconfig now"
134     make localmodconfig
135   fi
137   if [ "${_USE_MAKENCONFIG}" = "y" ]; then
138     msg "Running make nconfig"
139     make nconfig
140     #msg "Stopping build"
141     #return 1
142   fi
144   yes "" | make config
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}"
162   KARCH=x86
164   # get kernel version
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}"
171   # add vmlinux
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
178   sed \
179     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
180     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
181     -i "${startdir}/${pkgname}.install"
182   sed \
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/"
225   done
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}/"
245   fi
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}"
257   done
259   # add docbook makefile
260   install -D -m644 Documentation/DocBook/Makefile \
261     "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
263   # add dm headers
264   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
265   cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
267   # add inotify.h
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
276   # in reference to:
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/"
280   # and...
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
286   # in reference to:
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/"
292   # add dvb headers
293   # in reference to:
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}"
311   done
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}";;
325     esac
326   done
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: