1 # Maintainer: Ray Rashif <schiv@archlinux.org>
2 # Contributor: timbosa <tinny_tim@dodo.com.au>
3 # Contributor: Tobias Powalowski <tpowa@archlinux.org>
4 # Contributor: Thomas Baechler <thomas@archlinux.org>
7 _kernelname=${pkgname#linux}
10 pkgver=${_basekernel}.14_$_rtpatch
11 _pkgver=${_basekernel}.14
13 arch=('i686' 'x86_64')
14 url="http://rt.wiki.kernel.org/"
16 pkgdesc="The Linux Kernel and modules (with realtime preemption)"
18 backup=(etc/mkinitcpio.d/${pkgname}.preset)
19 depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
20 optdepends=('crda: to set the correct wireless channels of your country')
21 provides=('kernel26rt')
22 conflicts=('kernel26rt')
23 replaces=('kernel26rt')
24 install=${pkgname}.install
25 source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-${_basekernel}.tar.xz"
26 "http://www.kernel.org/pub/linux/kernel/v3.x/patch-${_pkgver}.xz"
27 "http://www.kernel.org/pub/linux/kernel/projects/rt/3.0/patch-${_pkgver}-${_rtpatch}.patch.xz"
28 # the main kernel config files
29 'config' 'config.x86_64'
30 # standard config files for mkinitcpio ramdisk
33 'change-default-console-loglevel.patch')
34 md5sums=('ecf932280e2441bdd992423ef3d55f8f'
35 '2161fb86bef3d33c1ddede73797e2f2c'
36 'b16ffd9de4968cb29b60b3036c251e23'
37 '8bed8efe88e4fa1781d1f307f35f9b26'
38 'a542f23e4f270967b3e8a871e69d0a61'
39 'eb14dcfd80c00852ef81ded6e826826a'
40 '263725f20c0b9eb9c353040792d644e5'
41 '9d3c56a4b999c8bfbd4018089a62f662')
44 cd "${srcdir}/linux-${_basekernel}"
46 patch -p1 -i "${srcdir}/patch-${_pkgver}"
49 patch -p1 -i "${srcdir}/patch-${_pkgver}-$_rtpatch.patch"
51 # enable building proprietary nvidia driver against full rt preemption
52 # WARNING: GPL-INCOMPATIBLE
54 # 's/EXPORT_SYMBOL_GPL(migrate_enable);/EXPORT_SYMBOL(migrate_enable);/' \
58 # 's/EXPORT_SYMBOL_GPL(migrate_disable);/EXPORT_SYMBOL(migrate_disable);/' \
62 # 's/EXPORT_SYMBOL_GPL(__rt_mutex_init);/EXPORT_SYMBOL(__rt_mutex_init);/' \
65 # add latest fixes from stable queue, if needed
66 # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
68 # fix #19234 i1915 display size
69 patch -Np1 -i "${srcdir}/fix-i915.patch"
71 # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
72 # remove this when a Kconfig knob is made available by upstream
73 # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
74 patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
76 if [ "${CARCH}" = "x86_64" ]; then
77 cat "${srcdir}/config.x86_64" > ./.config
79 cat "${srcdir}/config" > ./.config
82 if [ "${_kernelname}" != "" ]; then
83 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
86 # remove the sublevel from Makefile
87 # this ensures our kernel version is always 3.X-ARCH
88 # this way, minor kernel updates will not break external modules
89 # we need to change this soon, see FS#16702
90 sed -ri 's|^(SUBLEVEL =).*|\1|' Makefile
97 # Configure the kernel. Replace the line below with one of your choice.
98 #make menuconfig # CLI menu for configuration
99 #make nconfig # new CLI menu for configuration
100 #make xconfig # X-based configuration
101 #make oldconfig # using old config from previous kernel version
102 # ... or manually edit .config
106 # this is useful to configure the kernel
107 #msg "Stopping build"
114 make ${MAKEFLAGS} bzImage modules
118 cd "${srcdir}/linux-${_basekernel}"
123 _kernver="$(make kernelrelease)"
125 mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
126 make INSTALL_MOD_PATH="${pkgdir}" modules_install
127 cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"
130 install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
132 # install fallback mkinitcpio.conf file and preset file for kernel
133 install -D -m644 "${srcdir}/${pkgname}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
135 # set correct depmod command for install
137 -e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
138 -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
139 -i "${startdir}/${pkgname}.install"
141 -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|g" \
142 -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|g" \
143 -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|g" \
144 -i "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
146 # remove build and source links
147 rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
148 # remove the firmware
149 rm -rf "${pkgdir}/lib/firmware"
150 # gzip -9 all modules to safe 100MB of space
151 find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
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/"
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, like nvidia and vmware
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}/"
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}"
206 # add docbook makefile
207 install -D -m644 Documentation/DocBook/Makefile \
208 "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
211 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
212 cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
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
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/"
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
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/"
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}"
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}";;
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 rm -r "${pkgdir}/usr/src/linux-${_kernver}/Documentation"
280 mv Documentation "${pkgdir}/usr/src/linux-${_kernver}"
281 find "${pkgdir}" -type f -exec chmod 444 {} \;
282 find "${pkgdir}" -type d -exec chmod 755 {} \;
284 # remove a file already in linux package
285 rm -f "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
288 # vim:set ts=2 sw=2 et: