updated on Sat Jan 14 00:11:12 UTC 2012
[aur-mirror.git] / linux-ec2 / PKGBUILD
blob8248c53f2f8cf5defdbf3019e2b7e6a4483cfeef
1 # $Id: PKGBUILD 130991 2011-07-09 12:23:51Z thomas $
2 # Maintainer: Martin Kozák <martinkozak@martinkozak.net>
4 pkgbase=linux-ec2
5 # pkgname=('linux' 'linux-headers' 'linux-docs') # Build stock -ARCH kernel
6 #pkgname=('linux-ec2' 'linux-ec2-headers')       # Build kernel with a different name
7 pkgname='linux-ec2'       # Build kernel with a different name
8 _kernelname=${pkgname#linux}
9 _basekernel=3.1
10 pkgver=${_basekernel}.7
11 pkgrel=1
12 arch=('x86_64')
13 url="https://github.com/martinkozak/linux-ec2"
14 license=('GPL2')
15 makedepends=('xmlto' 'docbook-xsl')
16 options=('!strip')
17 source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.1.tar.xz"
18         "http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.xz"
19         # the main kernel config files
20         'config.x86_64'
21         # standard config files for mkinitcpio ramdisk
22         "${pkgname}.preset"
23         'change-default-console-loglevel.patch'
24         'i915-fix-ghost-tv-output.patch'
25         'i915-fix-incorrect-error-message.patch'
26         'usb-add-reset-resume-quirk-for-several-webcams.patch'
27         'xen-xsave.patch')
28 md5sums=('edbdc798f23ae0f8045c82f6fa22c536'
29          '499626638e433ffc77f938d0bc63a041'
30          'ea50fe713aadd43250ae1c54c1070074'
31          '24557c9eade2e6ecb632f16924741c7b'
32          '9d3c56a4b999c8bfbd4018089a62f662'
33          '263725f20c0b9eb9c353040792d644e5'
34          'a50c9076012cb2dda49952dc6ec3e9c1'
35          '52d41fa61e80277ace2b994412a0c856'
36          '446cb1590245d41beb7192c7b57af83b')
38 build() {
39   cd "${srcdir}/linux-${_basekernel}"
41   # add upstream patch
42   patch -p1 -i "${srcdir}/patch-${pkgver}"
44   # add latest fixes from stable queue, if needed
45   # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
47   # Some chips detect a ghost TV output
48   # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
49   # Arch Linux bug report: FS#19234
50   #
51   # It is unclear why this patch wasn't merged upstream, it was accepted,
52   # then dropped because the reasoning was unclear. However, it is clearly
53   # needed.
54   patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
56   # In 3.1.1, a DRM_DEBUG message is falsely declared as DRM_ERROR. This
57   # worries users, as this message is displayed even at loglevel 4. Fix
58   # this.
59   patch -Np1 -i "${srcdir}/i915-fix-incorrect-error-message.patch"
61   # Add the USB_QUIRK_RESET_RESUME for several webcams
62   # FS#26528
63   patch -Np1 -i "${srcdir}/usb-add-reset-resume-quirk-for-several-webcams.patch"
65   # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
66   # remove this when a Kconfig knob is made available by upstream
67   # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
68   patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
69   
70   # fixes XSAVE for Xen (for EC2)
71   patch -Np1 -i "${srcdir}/xen-xsave.patch"
73   if [ "${CARCH}" = "x86_64" ]; then
74     cat "${srcdir}/config.x86_64" > ./.config
75   else
76     cat "${srcdir}/config" > ./.config
77   fi
79   if [ "${_kernelname}" != "" ]; then
80     sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
81   fi
83   # set extraversion to pkgrel
84   sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
86   # get kernel version
87   make prepare
89   # load configuration
90   # Configure the kernel. Replace the line below with one of your choice.
91   #make menuconfig # CLI menu for configuration
92   #make nconfig # new CLI menu for configuration
93   #make xconfig # X-based configuration
94   #make oldconfig # using old config from previous kernel version
95   # ... or manually edit .config
97   ####################
98   # stop here
99   # this is useful to configure the kernel
100   #msg "Stopping build"
101   #return 1
102   ####################
104   yes "" | make config
106   # build!
107   make ${MAKEFLAGS} bzImage modules
110 package_linux-ec2() {
111   pkgdesc="The Linux Kernel and modules suitable for Amazon EC2"
112   groups=('ec2')
113   depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
114   optdepends=('crda: to set the correct wireless channels of your country')
115   #provides=('kernel26')
116   #conflicts=('kernel26')
117   #replaces=('kernel26')
118   backup=("etc/mkinitcpio.d/${pkgname}.preset")
119   install=${pkgname}.install
121   cd "${srcdir}/linux-${_basekernel}"
123   KARCH=x86
125   # get kernel version
126   _kernver="$(make kernelrelease)"
128   mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
129   make INSTALL_MOD_PATH="${pkgdir}" modules_install
130   cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"
132   # add vmlinux
133   install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
135   # install fallback mkinitcpio.conf file and preset file for kernel
136   install -D -m644 "${srcdir}/${pkgname}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
138   # set correct depmod command for install
139   sed \
140     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
141     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
142     -i "${startdir}/${pkgname}.install"
143   sed \
144     -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|g" \
145     -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|g" \
146     -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|g" \
147     -i "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
149   # remove build and source links
150   rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
151   # remove the firmware
152   rm -rf "${pkgdir}/lib/firmware"
153   # gzip -9 all modules to save 100MB of space
154   find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
155   # make room for external modules
156   ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
157   # add real version for building modules and running depmod from post_install/upgrade
158   mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}"
159   echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}/version"
162 package_linux-ec2-headers() {
163   pkgdesc="Header files and scripts for building modules for linux kernel suitable for Amazon EC2"
164   #provides=('kernel26-headers')
165   #conflicts=('kernel26-headers')
166   #replaces=('kernel26-headers')
168   mkdir -p "${pkgdir}/lib/modules/${_kernver}"
170   cd "${pkgdir}/lib/modules/${_kernver}"
171   ln -sf ../../../usr/src/linux-${_kernver} build
173   cd "${srcdir}/linux-${_basekernel}"
174   install -D -m644 Makefile \
175     "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
176   install -D -m644 kernel/Makefile \
177     "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
178   install -D -m644 .config \
179     "${pkgdir}/usr/src/linux-${_kernver}/.config"
181   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
183   for i in acpi asm-generic config crypto drm generated linux math-emu \
184     media net pcmcia scsi sound trace video xen; do
185     cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
186   done
188   # copy arch includes for external modules
189   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
190   cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
192   # copy files necessary for later builds, like nvidia and vmware
193   cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
194   cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
196   # fix permissions on scripts dir
197   chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
198   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
200   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
202   cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
204   if [ "${CARCH}" = "i686" ]; then
205     cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
206   fi
208   cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
210   # add headers for lirc package
211   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
213   cp drivers/media/video/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
215   for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
216     mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
217     cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
218   done
220   # add docbook makefile
221   install -D -m644 Documentation/DocBook/Makefile \
222     "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
224   # add dm headers
225   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
226   cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
228   # add inotify.h
229   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
230   cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
232   # add wireless headers
233   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
234   cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
236   # add dvb headers for external modules
237   # in reference to:
238   # http://bugs.archlinux.org/task/9912
239   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
240   cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
241   # and...
242   # http://bugs.archlinux.org/task/11194
243   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
244   cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
246   # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
247   # in reference to:
248   # http://bugs.archlinux.org/task/13146
249   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
250   cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
251   cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
253   # add dvb headers
254   # in reference to:
255   # http://bugs.archlinux.org/task/20402
256   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
257   cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
258   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
259   cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
260   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
261   cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
263   # add xfs and shmem for aufs building
264   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
265   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
266   cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
268   # copy in Kconfig files
269   for i in `find . -name "Kconfig*"`; do
270     mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
271     cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
272   done
274   chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
275   find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
277   # strip scripts directory
278   find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
279     case "$(file -bi "${binary}")" in
280       *application/x-sharedlib*) # Libraries (.so)
281         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
282       *application/x-archive*) # Libraries (.a)
283         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
284       *application/x-executable*) # Binaries
285         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
286     esac
287   done
289   # remove unneeded architectures
290   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}