updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / linux-sony / PKGBUILD
blob551050f0f4ad115c866821b1ce247a3e0bd8ce7c
1 # $Id: PKGBUILD 130991 2011-07-09 12:23:51Z thomas $
2 # Maintainer: Gadget3000 <gadget3000 at msn dot com>
3 # Maintainer: Tobias Powalowski <tpowa@archlinux.org>
4 # Maintainer: Thomas Baechler <thomas@archlinux.org>
6 pkgbase=linux-sony
7 pkgname=('linux-sony')
8 true && pkgname=('linux-sony' 'linux-sony-headers' 'linux-sony-docs')
9 #pkgname=linux-custom       # Build kernel with a different name
10 _kernelname=${pkgname#linux}
11 _basekernel=3.2
12 pkgver=${_basekernel}.1
13 pkgrel=2
14 arch=('i686' 'x86_64')
15 url="http://code.google.com/p/vaio-f11-linux/wiki/KernelSupport"
16 license=('GPL2')
17 makedepends=('xmlto' 'docbook-xsl')
18 options=('!strip')
19 source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.2.tar.xz"
20         "http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.xz"
21         # the main kernel config files
22         'config' 'config.x86_64'
23         # standard config files for mkinitcpio ramdisk
24         "${pkgname}.preset"
25         'change-default-console-loglevel.patch'
26         'i915-fix-ghost-tv-output.patch'
27         'i915-gpu-finish.patch'
28         'vaio-full-3.0.4.patch'
29         'CVE-2012-0056.patch')
30 md5sums=('364066fa18767ec0ae5f4e4abcf9dc51'
31          '62ac6ac9b870162f693ecf5e8606423a'
32          'a5c8ab601a60d73f4ef8f0e1dae3b2cb'
33          'a2c51207b79074e8c86006cc206dbb6f'
34          'a96b5ae5ad2d57be4109d762a21d5fa2'
35          '9d3c56a4b999c8bfbd4018089a62f662'
36          '263725f20c0b9eb9c353040792d644e5'
37          '4cd79aa147825837dc8bc9f6b736c0a0'
38          '8c51a944e542a396e9388a1c0b74a33b'
39          'a050d76e56d2ce0715c8ff663ae7f436')
41 build() {
42   cd "${srcdir}/linux-${_basekernel}"
44   # add upstream patch
45   patch -p1 -i "${srcdir}/patch-${pkgver}"
47   # patch for CVE-2012-0056
48   # see http://blog.zx2c4.com/749 for details
49   patch -p1 -i "${srcdir}/CVE-2012-0056.patch"
51   # add latest fixes from stable queue, if needed
52   # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
54   # fix FS#27883
55   # drm/i915: Only clear the GPU domains upon a successful finish
56   patch -Np1 -i "${srcdir}/i915-gpu-finish.patch"
58   # Some chips detect a ghost TV output
59   # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
60   # Arch Linux bug report: FS#19234
61   #
62   # It is unclear why this patch wasn't merged upstream, it was accepted,
63   # then dropped because the reasoning was unclear. However, it is clearly
64   # needed.
65   patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
67   # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
68   # remove this when a Kconfig knob is made available by upstream
69   # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
70   patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
71   
72   patch -Np1 -i "${srcdir}/vaio-full-3.0.4.patch"
74   if [ "${CARCH}" = "x86_64" ]; then
75     cat "${srcdir}/config.x86_64" > ./.config
76   else
77     cat "${srcdir}/config" > ./.config
78   fi
80   if [ "${_kernelname}" != "" ]; then
81     sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
82   fi
84   # set extraversion to pkgrel
85   sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
87   # get kernel version
88   make prepare
90   # load configuration
91   # Configure the kernel. Replace the line below with one of your choice.
92   #make menuconfig # CLI menu for configuration
93   #make nconfig # new CLI menu for configuration
94   #make xconfig # X-based configuration
95   #make oldconfig # using old config from previous kernel version
96   # ... or manually edit .config
98   ####################
99   # stop here
100   # this is useful to configure the kernel
101   #msg "Stopping build"
102   #return 1
103   ####################
105   yes "" | make config
107   # build!
108   make ${MAKEFLAGS} bzImage modules
111 package_linux-sony() {
112   pkgdesc="The Linux Kernel and modules patched for full Sony hardware support"
113   groups=('base')
114   depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
115   optdepends=('crda: to set the correct wireless channels of your country')
116   provides=('kernel26-sony')
117   conflicts=('kernel26-sony')
118   replaces=('kernel26-sony')
119   backup=("etc/mkinitcpio.d/${pkgname}.preset")
120   install=${pkgname}.install
122   cd "${srcdir}/linux-${_basekernel}"
124   KARCH=x86
126   # get kernel version
127   _kernver="$(make kernelrelease)"
129   mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
130   make INSTALL_MOD_PATH="${pkgdir}" modules_install
131   cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"
133   # add vmlinux
134   install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
136   # install fallback mkinitcpio.conf file and preset file for kernel
137   install -D -m644 "${srcdir}/${pkgname}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
139   # set correct depmod command for install
140   sed \
141     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
142     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
143     -i "${startdir}/${pkgname}.install"
144   sed \
145     -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|g" \
146     -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|g" \
147     -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|g" \
148     -i "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
150   # remove build and source links
151   rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
152   # remove the firmware
153   rm -rf "${pkgdir}/lib/firmware"
154   # gzip -9 all modules to save 100MB of space
155   find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
156   # make room for external modules
157   ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
158   # add real version for building modules and running depmod from post_install/upgrade
159   mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}"
160   echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}/version"
163 package_linux-sony-headers() {
164   true && pkgdesc="Header files and scripts for building modules for linux kernel"
165   provides=('kernel26-sony-headers')
166   conflicts=('kernel26-sony-headers')
167   replaces=('kernel26-sony-headers')
169   mkdir -p "${pkgdir}/lib/modules/${_kernver}"
171   cd "${pkgdir}/lib/modules/${_kernver}"
172   ln -sf ../../../usr/src/linux-${_kernver} build
174   cd "${srcdir}/linux-${_basekernel}"
175   install -D -m644 Makefile \
176     "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
177   install -D -m644 kernel/Makefile \
178     "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
179   install -D -m644 .config \
180     "${pkgdir}/usr/src/linux-${_kernver}/.config"
182   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
184   for i in acpi asm-generic config crypto drm generated linux math-emu \
185     media net pcmcia scsi sound trace video xen; do
186     cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
187   done
189   # copy arch includes for external modules
190   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
191   cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
193   # copy files necessary for later builds, like nvidia and vmware
194   cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
195   cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
197   # fix permissions on scripts dir
198   chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
199   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
201   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
203   cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
205   if [ "${CARCH}" = "i686" ]; then
206     cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
207   fi
209   cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
211   # add headers for lirc package
212   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
214   cp drivers/media/video/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
216   for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
217     mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
218     cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
219   done
221   # add docbook makefile
222   install -D -m644 Documentation/DocBook/Makefile \
223     "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
225   # add dm headers
226   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
227   cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
229   # add inotify.h
230   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
231   cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
233   # add wireless headers
234   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
235   cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
237   # add dvb headers for external modules
238   # in reference to:
239   # http://bugs.archlinux.org/task/9912
240   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
241   cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
242   # and...
243   # http://bugs.archlinux.org/task/11194
244   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
245   cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
247   # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
248   # in reference to:
249   # http://bugs.archlinux.org/task/13146
250   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
251   cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
252   cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
254   # add dvb headers
255   # in reference to:
256   # http://bugs.archlinux.org/task/20402
257   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
258   cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
259   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
260   cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
261   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
262   cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
264   # add xfs and shmem for aufs building
265   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
266   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
267   cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
269   # copy in Kconfig files
270   for i in `find . -name "Kconfig*"`; do
271     mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
272     cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
273   done
275   chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
276   find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
278   # strip scripts directory
279   find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
280     case "$(file -bi "${binary}")" in
281       *application/x-sharedlib*) # Libraries (.so)
282         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
283       *application/x-archive*) # Libraries (.a)
284         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
285       *application/x-executable*) # Binaries
286         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
287     esac
288   done
290   # remove unneeded architectures
291   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}
294 package_linux-sony-docs() {
295   true && pkgdesc="Kernel hackers manual - HTML documentation that comes with the Linux kernel."
296   provides=('kernel26-sony-docs')
297   conflicts=('kernel26-sony-docs')
298   replaces=('kernel26-sony-docs')
300   cd "${srcdir}/linux-${_basekernel}"
302   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}"
303   cp -al Documentation "${pkgdir}/usr/src/linux-${_kernver}"
304   find "${pkgdir}" -type f -exec chmod 444 {} \;
305   find "${pkgdir}" -type d -exec chmod 755 {} \;
307   # remove a file already in linux package
308   rm -f "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"