updated on Fri Jan 20 04:00:45 UTC 2012
[aur-mirror.git] / linux-libre / PKGBUILD
blob5ccd9e2c4781d4b104ccdf5269578d0fca28818d
1 # $Id: PKGBUILD 130991 2011-07-09 12:23:51Z thomas $
2 # Maintainer: Tobias Powalowski <tpowa@archlinux.org>
3 # Maintainer: Thomas Baechler <thomas@archlinux.org>
4 # Maintainer (Parabola): Nicolás Reynolds <fauno@kiwwwi.com.ar>
5 # Maintainer (Parabola): Sorin-Mihai Vârgolici <smv@yobicore.org>
7 pkgbase=linux-libre
8 pkgname=linux-libre
9 true &&pkgname=('linux-libre' 'linux-libre-headers' 'linux-libre-docs') # Build stock -LIBRE kernel
10 # pkgname=linux-custom       # Build kernel with a different name
11 _kernelname=${pkgname#linux-libre}
12 _basekernel=3.1
13 pkgver=${_basekernel}.5
14 pkgrel=1
15 arch=('i686' 'x86_64')
16 url="http://linux-libre.fsfla.org/"
17 license=('GPL2')
18 makedepends=('xmlto' 'docbook-xsl')
19 options=('!strip')
20 source=("http://linux-libre.fsfla.org/pub/linux-libre/releases/${_basekernel}-libre/linux-${_basekernel}-libre.tar.xz"
21         "http://linux-libre.fsfla.org/pub/linux-libre/releases/${pkgver}-libre/patch-${_basekernel}-libre-${pkgver}-libre.xz"
22         # the main kernel config files
23         'config.i686' 'config.x86_64'
24         # standard config files for mkinitcpio ramdisk
25         "${pkgname}.preset"
26         'boot-logo.patch'
27         'change-default-console-loglevel.patch'
28         'i915-fix-ghost-tv-output.patch'
29         'i915-fix-incorrect-error-message.patch'
30         'usb-add-reset-resume-quirk-for-several-webcams.patch')
32 build() {
33   cd "${srcdir}/linux-${_basekernel}"
35   patch -Np1 -i "${srcdir}/patch-${_basekernel}-libre-${pkgver}-libre"
37   # Add freedo as boot logo
38   patch -Np1 -i "${srcdir}/boot-logo.patch"
40   # Some chips detect a ghost TV output
41   # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
42   # Arch Linux bug report: FS#19234
43   #
44   # It is unclear why this patch wasn't merged upstream, it was accepted,
45   # then dropped because the reasoning was unclear. However, it is clearly
46   # needed.
47   patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
49   # In 3.1.1, a DRM_DEBUG message is falsely declared as DRM_ERROR. This
50   # worries users, as this message is displayed even at loglevel 4. Fix
51   # this.
52   patch -Np1 -i "${srcdir}/i915-fix-incorrect-error-message.patch"
54   # Add the USB_QUIRK_RESET_RESUME for several webcams
55   # FS#26528
56   patch -Np1 -i "${srcdir}/usb-add-reset-resume-quirk-for-several-webcams.patch"
58   # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
59   # remove this when a Kconfig knob is made available by upstream
60   # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
61   patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
63   cat "${srcdir}/config.${CARCH}" > ./.config # simpler
65   if [ "${_kernelname}" != "" ]; then
66     sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
67   fi
69   # set extraversion to pkgrel
70   sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
72   # get kernel version
73   make prepare
75   # load configuration
76   # Configure the kernel. Replace the line below with one of your choice.
77   #make menuconfig # CLI menu for configuration
78   #make nconfig # new CLI menu for configuration
79   #make xconfig # X-based configuration
80   #make oldconfig # using old config from previous kernel version
81   # ... or manually edit .config
83   ####################
84   # stop here
85   # this is useful to configure the kernel
86   #msg "Stopping build"
87   #return 1
88   ####################
90   yes "" | make config
92   # build!
93   make ${MAKEFLAGS} bzImage modules
96 package_linux-libre() {
97   pkgdesc="The Linux-libre Kernel and modules"
98   groups=('base')
99   depends=('coreutils' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
100   optdepends=('crda: to set the correct wireless channels of your country')
101   provides=('kernel26' "linux=$pkgver")
102   conflicts=('kernel26' 'kernel26-libre' 'linux')
103   replaces=('kernel26' 'kernel26-libre' 'linux')
104   backup=("etc/mkinitcpio.d/${pkgname}.preset")
105   install=${pkgname}.install
107   cd "${srcdir}/linux-${_basekernel}"
109   KARCH=x86
111   # get kernel version
112   _kernver="$(make kernelrelease)"
114   mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
115   make INSTALL_MOD_PATH="${pkgdir}" modules_install
116   cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"
118   # add vmlinux
119   install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
121   # install fallback mkinitcpio.conf file and preset file for kernel
122   install -D -m644 "${srcdir}/${pkgname}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
124   # set correct depmod command for install
125   sed \
126     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
127     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
128     -i "${startdir}/${pkgname}.install"
129   sed \
130     -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|g" \
131     -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|g" \
132     -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|g" \
133     -i "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
135   # remove build and source links
136   rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
137   # remove the firmware
138   rm -rf "${pkgdir}/lib/firmware"
139   # gzip -9 all modules to save 100MB of space
140   find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
141   # make room for external modules
142   ln -s "../extramodules-${_basekernel}${_kernelname:--LIBRE}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
143   # add real version for building modules and running depmod from post_install/upgrade
144   mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--LIBRE}"
145   echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--LIBRE}/version"
148 package_linux-libre-headers() {
149   pkgdesc="Header files and scripts for building modules for linux-libre kernel"
150   provides=('kernel26-headers' "linux-headers=${pkgver}")
151   conflicts=('kernel26-headers' 'kernel26-libre-headers' 'linux-headers')
152   replaces=('kernel26-headers' 'kernel26-libre-headers' 'linux-headers')
154   mkdir -p "${pkgdir}/lib/modules/${_kernver}"
156   cd "${pkgdir}/lib/modules/${_kernver}"
157   ln -sf ../../../usr/src/linux-${_kernver} build
159   cd "${srcdir}/linux-${_basekernel}"
160   install -D -m644 Makefile \
161     "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
162   install -D -m644 kernel/Makefile \
163     "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
164   install -D -m644 .config \
165     "${pkgdir}/usr/src/linux-${_kernver}/.config"
167   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
169   for i in acpi asm-generic config crypto drm generated linux math-emu \
170     media net pcmcia scsi sound trace video xen; do
171     cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
172   done
174   # copy arch includes for external modules
175   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
176   cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
178   # copy files necessary for later builds
179   cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
180   cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
182   # fix permissions on scripts dir
183   chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
184   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
186   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
188   cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
190   if [ "${CARCH}" = "i686" ]; then
191     cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
192   fi
194   cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
196   # add headers for lirc package
197   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
199   cp drivers/media/video/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
201   for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
202     mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
203     cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
204   done
206   # add docbook makefile
207   install -D -m644 Documentation/DocBook/Makefile \
208     "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
210   # add dm headers
211   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
212   cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
214   # add inotify.h
215   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
216   cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
218   # add wireless headers
219   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
220   cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
222   # add dvb headers for external modules
223   # in reference to:
224   # http://bugs.archlinux.org/task/9912
225   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
226   cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
227   # and...
228   # http://bugs.archlinux.org/task/11194
229   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
230   cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
232   # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
233   # in reference to:
234   # http://bugs.archlinux.org/task/13146
235   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
236   cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
237   cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
239   # add dvb headers
240   # in reference to:
241   # http://bugs.archlinux.org/task/20402
242   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
243   cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
244   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
245   cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
246   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
247   cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
249   # add xfs and shmem for aufs building
250   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
251   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
252   cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
254   # copy in Kconfig files
255   for i in `find . -name "Kconfig*"`; do
256     mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
257     cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
258   done
260   chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
261   find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
263   # strip scripts directory
264   find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
265     case "$(file -bi "${binary}")" in
266       *application/x-sharedlib*) # Libraries (.so)
267         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
268       *application/x-archive*) # Libraries (.a)
269         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
270       *application/x-executable*) # Binaries
271         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
272     esac
273   done
275   # remove unneeded architectures
276   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}
279 package_linux-libre-docs() {
280   pkgdesc="Kernel hackers manual - HTML documentation that comes with the Linux-libre kernel."
281   provides=('kernel26-docs' "linux-docs=$pkgver")
282   conflicts=('kernel26-docs' 'kernel26-libre-docs' 'linux-docs')
283   replaces=('kernel26-docs' 'kernel26-libre-docs' 'linux-docs')
285   cd "${srcdir}/linux-${_basekernel}"
287   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}"
288   cp -al Documentation "${pkgdir}/usr/src/linux-${_kernver}"
289   find "${pkgdir}" -type f -exec chmod 444 {} \;
290   find "${pkgdir}" -type d -exec chmod 755 {} \;
292   # remove a file already in linux package
293   rm -f "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
295 md5sums=('d73df15ab1d36fe3c102755d8f42117f'
296          '06b461d4db995ddcbecbf345ae3b8987'
297          '7d8fac41f4c4c2d14d8c65645fb676bd'
298          '2a0302eda795903d3b01e41ba807c91e'
299          'a8a3843046926eb7ab81312cd438c5c5'
300          '04b21c79df0a952c22d681dd4f4562df'
301          '9d3c56a4b999c8bfbd4018089a62f662'
302          '263725f20c0b9eb9c353040792d644e5'
303          'a50c9076012cb2dda49952dc6ec3e9c1'
304          '52d41fa61e80277ace2b994412a0c856')
305 pkgdesc="The Linux-libre Kernel and modules"