1 # $Id: PKGBUILD 130991 2011-07-09 12:23:51Z thomas $
2 # Maintainer: Martin Kozák <martinkozak@martinkozak.net>
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}
10 pkgver=${_basekernel}.1
13 url="https://github.com/martinkozak/linux-ec2"
15 makedepends=('xmlto' 'docbook-xsl')
17 source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.2.tar.xz"
18 "http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.xz"
19 # the main kernel config files
21 # standard config files for mkinitcpio ramdisk
23 'change-default-console-loglevel.patch'
24 'i915-fix-ghost-tv-output.patch'
25 'i915-gpu-finish.patch'
27 md5sums=('364066fa18767ec0ae5f4e4abcf9dc51'
28 '62ac6ac9b870162f693ecf5e8606423a'
29 'd75a5844160ae83fe0704a86edd2c6f5'
30 '24557c9eade2e6ecb632f16924741c7b'
31 '9d3c56a4b999c8bfbd4018089a62f662'
32 '263725f20c0b9eb9c353040792d644e5'
33 'e787ef4bc66e2d9a7883eaece7a915b9'
34 '446cb1590245d41beb7192c7b57af83b')
37 cd "${srcdir}/linux-${_basekernel}"
40 patch -p1 -i "${srcdir}/patch-${pkgver}"
42 # add latest fixes from stable queue, if needed
43 # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
46 # drm/i915: Only clear the GPU domains upon a successful finish
47 patch -Np1 -i "${srcdir}/i915-gpu-finish.patch"
49 # Some chips detect a ghost TV output
50 # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
51 # Arch Linux bug report: FS#19234
53 # It is unclear why this patch wasn't merged upstream, it was accepted,
54 # then dropped because the reasoning was unclear. However, it is clearly
56 patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.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 # fixes XSAVE for Xen (for EC2)
64 patch -Np1 -i "${srcdir}/xen-xsave.patch"
66 if [ "${CARCH}" = "x86_64" ]; then
67 cat "${srcdir}/config.x86_64" > ./.config
69 cat "${srcdir}/config" > ./.config
72 if [ "${_kernelname}" != "" ]; then
73 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
76 # set extraversion to pkgrel
77 sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
83 # Configure the kernel. Replace the line below with one of your choice.
84 #make menuconfig # CLI menu for configuration
85 #make nconfig # new CLI menu for configuration
86 #make xconfig # X-based configuration
87 #make oldconfig # using old config from previous kernel version
88 # ... or manually edit .config
92 # this is useful to configure the kernel
100 make ${MAKEFLAGS} bzImage modules
103 package_linux-ec2() {
104 pkgdesc="The Linux Kernel and modules suitable for Amazon EC2"
106 depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
107 optdepends=('crda: to set the correct wireless channels of your country')
108 #provides=('kernel26')
109 #conflicts=('kernel26')
110 #replaces=('kernel26')
111 backup=("etc/mkinitcpio.d/${pkgname}.preset")
112 install=${pkgname}.install
114 cd "${srcdir}/linux-${_basekernel}"
119 _kernver="$(make kernelrelease)"
121 mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
122 make INSTALL_MOD_PATH="${pkgdir}" modules_install
123 cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"
126 install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
128 # install fallback mkinitcpio.conf file and preset file for kernel
129 install -D -m644 "${srcdir}/${pkgname}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
131 # set correct depmod command for install
133 -e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
134 -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
135 -i "${startdir}/${pkgname}.install"
137 -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|g" \
138 -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|g" \
139 -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|g" \
140 -i "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
142 # remove build and source links
143 rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
144 # remove the firmware
145 rm -rf "${pkgdir}/lib/firmware"
146 # gzip -9 all modules to save 100MB of space
147 find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
148 # make room for external modules
149 ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
150 # add real version for building modules and running depmod from post_install/upgrade
151 mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}"
152 echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}/version"
155 package_linux-ec2-headers() {
156 pkgdesc="Header files and scripts for building modules for linux kernel suitable for Amazon EC2"
157 #provides=('kernel26-headers')
158 #conflicts=('kernel26-headers')
159 #replaces=('kernel26-headers')
161 mkdir -p "${pkgdir}/lib/modules/${_kernver}"
163 cd "${pkgdir}/lib/modules/${_kernver}"
164 ln -sf ../../../usr/src/linux-${_kernver} build
166 cd "${srcdir}/linux-${_basekernel}"
167 install -D -m644 Makefile \
168 "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
169 install -D -m644 kernel/Makefile \
170 "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
171 install -D -m644 .config \
172 "${pkgdir}/usr/src/linux-${_kernver}/.config"
174 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
176 for i in acpi asm-generic config crypto drm generated linux math-emu \
177 media net pcmcia scsi sound trace video xen; do
178 cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
181 # copy arch includes for external modules
182 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
183 cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
185 # copy files necessary for later builds, like nvidia and vmware
186 cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
187 cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
189 # fix permissions on scripts dir
190 chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
191 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
193 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
195 cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
197 if [ "${CARCH}" = "i686" ]; then
198 cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
201 cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
203 # add headers for lirc package
204 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
206 cp drivers/media/video/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
208 for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
209 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
210 cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
213 # add docbook makefile
214 install -D -m644 Documentation/DocBook/Makefile \
215 "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
218 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
219 cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
222 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
223 cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
225 # add wireless headers
226 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
227 cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
229 # add dvb headers for external modules
231 # http://bugs.archlinux.org/task/9912
232 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
233 cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
235 # http://bugs.archlinux.org/task/11194
236 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
237 cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
239 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
241 # http://bugs.archlinux.org/task/13146
242 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
243 cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
244 cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
248 # http://bugs.archlinux.org/task/20402
249 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
250 cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
251 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
252 cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
253 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
254 cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
256 # add xfs and shmem for aufs building
257 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
258 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
259 cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
261 # copy in Kconfig files
262 for i in `find . -name "Kconfig*"`; do
263 mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
264 cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
267 chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
268 find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
270 # strip scripts directory
271 find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
272 case "$(file -bi "${binary}")" in
273 *application/x-sharedlib*) # Libraries (.so)
274 /usr/bin/strip ${STRIP_SHARED} "${binary}";;
275 *application/x-archive*) # Libraries (.a)
276 /usr/bin/strip ${STRIP_STATIC} "${binary}";;
277 *application/x-executable*) # Binaries
278 /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
282 # remove unneeded architectures
283 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}