1 # Almost wholly taken from kernel26-ice by Giuseppe Calderaro
2 # Maintainer: Ng Oon-Ee <ngoonee.talk@gmail.com>
3 # Source Contributor: Giuseppe Calderaro <giuseppecalderaro@gmail.com>
5 pkgdesc="The Linux Kernel and modules with tuxonice support and rt-patchset"
6 depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0,7')
7 optdepends=('crda: to set the correct wireless channels of your country')
9 backup=(etc/mkinitcpio.d/$pkgname.preset)
10 _kernelname=${pkgname#linux}
12 pkgver=${_basekernel}.17
14 arch=('i686' 'x86_64')
15 url="https://rt.wiki.kernel.org"
17 install=$pkgname.install
18 provides=('kernel26-rt-ice')
19 conflicts=('kernel26-rt-ice')
20 replaces=('kernel26-rt-ice')
21 makedepends=('xmlto' 'docbook-xsl')
24 ### User/Environment defined variables
25 enable_toi=${enable_toi:-1}
26 bfs_scheduler=${bfs_scheduler:-0}
27 keep_source_code=${keep_source_code:-0}
30 menuconfig=${menuconfig:-0}
31 realtime_patch=${realtime_patch:-1}
32 local_patch_dir="${local_patch_dir:-}"
33 use_config="${use_config:-}"
34 use_config_gz=${use_config_gz:-0}
35 enable_reiser4=${enable_reiser4:-0}
36 ### Compile time defined variables
40 file_rt="patch-3.0.17-rt33.patch.gz"
41 file_reiser4="reiser4-for-2.6.33.patch.bz2"
42 file_toi="current-tuxonice-for-3.0.patch.bz2"
43 file_bfs="2.6.38.3-sched-bfs-401.patch"
46 source=("ftp://ftp.kernel.org/pub/linux/kernel/v3.0/linux-${_basekernel}.tar.bz2"
47 "ftp://ftp.kernel.org/pub/linux/kernel/v3.0/patch-${pkgver}.gz"
48 http://www.kernel.org/pub/linux/kernel/projects/rt/3.0/${file_rt}
49 # https://tglx.de/~tglx/rt/3.0/${file_rt}
50 # http://www.kernel.org/pub/linux/kernel/people/edward/reiser4/reiser4-for-2.6/${file_reiser4}
51 http://www.tuxonice.net/files/${file_toi}
52 # http://ck.kolivas.org/patches/bfs/${_basekernel}/${file_bfs}
53 # the main kernel config files
54 'config' 'config.x86_64'
55 # standard config files for mkinitcpio ramdisk
57 'change-default-console-loglevel.patch'
58 'i915-fix-ghost-tv-output.patch')
59 md5sums=('398e95866794def22b12dfbc15ce89c0'
60 '10ca2c655365c47795cddbb5ff68b08e'
61 '9416c35ab0924f25bc423b7cfe433b03'
62 'afbd01926c57fc5b82ee6034dc9311e5'
63 '801c67a6be8b0ce562665b7900c42751'
64 'a8eb16e1c42b5d05867cf49d631df3ee'
65 '7c9725208ab6834602c8b9d645ed001d'
66 '9d3c56a4b999c8bfbd4018089a62f662'
67 '263725f20c0b9eb9c353040792d644e5')
70 cd "${srcdir}/linux-${_basekernel}"
73 patch -p1 -i "${srcdir}/patch-${pkgver}"
75 if [ -n "${local_patch_dir}" ] && [ -d "${local_patch_dir}" ] ; then
76 echo "Applying patches from ${local_patch_dir} ..."
77 for my_patch in "${local_patch_dir}"/* ; do
78 echo -e "Applying custom patch:\t'${my_patch}'" || true
79 patch -Np1 -i "${my_patch}" || { echo -e "Failed custom patch:\t'${my_patch}'" ; return 1 ; }
83 # Applying realtime patch
84 if [ "$realtime_patch" = "1" ]; then
85 echo "Applying real time patch"
86 # Strip './Makefile' changes
87 gzip -dc ${srcdir}/${file_rt} \
88 | sed '/diff --git a\/Makefile b\/Makefile/,/*DOCUMENTATION*/d' \
89 | patch -Np1 || { echo "Failed Realtime patch '${file_rt}'"; return 1 ; }
92 # applying reiserfs4 patch
93 if [ "$enable_reiser4" = "1" ]; then
94 echo "Applying ${file_reiser4%.gz}"
95 bzip2 -dc ${srcdir}/${file_reiser4} | patch -Np1 || { echo "Failed reiser4 patch '${file_reiser4%.gz}'"; return 1 ; }
98 # applying tuxonice patch
99 if [ "${enable_toi}" = "1" ]; then
100 echo "Applying ${file_toi%.bz2}"
101 # fix to tuxonice patch to work with rt
102 #if [ "$realtime_patch" = "1" ]; then
103 #bzip2 -dck ${srcdir}/${file_toi} \
104 #| sed '/diff --git a\/kernel\/fork.c b\/kernel\/fork.c/,/{/d' \
105 #| sed 's/printk(KERN_INFO "PM: Creating hibernation image:\\n/printk(KERN_INFO "PM: Creating hibernation image: \\n/' \
106 #| patch -Np1 || { echo "Failed TOI w/rt" ; return 1 ; }
108 bzip2 -dck ${srcdir}/${file_toi} \
109 | sed 's/printk(KERN_INFO "PM: Creating hibernation image:\\n/printk(KERN_INFO "PM: Creating hibernation image: \\n/' \
110 | patch -Np1 -F4 || { echo "Failed TOI"; return 1 ; }
114 if [ "${bfs_scheduler}" = "1" ] && [ "${realtime_patch}" = "0" ]; then
115 # applying BFS scheduler patch
116 echo "BFS scheduler patch not available yet, sorry"
117 # echo "Applying BFS scheduler patch"
118 # patch -Np1 -i ${srcdir}/${file_bfs} || { echo "Failed BFS"; return 1 ; }
121 # Some chips detect a ghost TV output
122 # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
123 # Arch Linux bug report: FS#19234
125 # It is unclear why this patch wasn't merged upstream, it was accepted,
126 # then dropped because the reasoning was unclear. However, it is clearly
128 patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
130 # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
131 # remove this when a Kconfig knob is made available by upstream
132 # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
133 patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
135 if [ "${CARCH}" = "x86_64" ]; then
136 cat "${srcdir}/config.x86_64" > ./.config
138 cat "${srcdir}/config" > ./.config
141 # use custom config instead
142 if [ -n "${use_config}" ] ; then
143 echo "Using config: '${use_config}'"
144 cat "${use_config}" > ./.config
148 # use existing config.gz
149 if [ "$use_config_gz" = "1" ]; then
150 zcat /proc/config.gz > ./.config
154 if [ "${_kernelname}" != "" ]; then
155 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
158 # set extraversion to pkgrel
159 sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
161 # hack to prevent output kernel from being marked as dirty or git
162 #chmod +x ${srcdir}/linux-${_basekernel}/scripts/setlocalversion
163 #sed 's/head=`git rev-parse --verify --short HEAD 2>\/dev\/null`/0/' \
164 # ${srcdir}/linux-${_basekernel}/scripts/setlocalversion \
165 # > ${srcdir}/linux-${_basekernel}/scripts/setlocalversion.new
166 #mv ${srcdir}/linux-${_basekernel}/scripts/setlocalversion.new \
167 # ${srcdir}/linux-${_basekernel}/scripts/setlocalversion
173 # Configure the kernel. Replace the line below with one of your choice.
174 if [ "$gconfig" = "1" ]; then
177 if [ "$xconfig" = "1" ]; then
180 if [ "$menuconfig" = "1" ]; then
186 make prepare # Necessary in case config has been changed
188 make ${MAKEFLAGS} bzImage modules
191 package_linux-rt-ice() {
194 cd ${srcdir}/linux-${_basekernel}
195 if [ "$keep_source_code" = "1" ]; then
196 echo -n "Copying source code..."
197 # Keep the source code
199 mkdir -p $pkgdir/usr/src || return 1
200 cp -a ${srcdir}/linux-${_basekernel} $pkgdir/usr/src/linux-${_kernver} || return 1
202 #Add a link from the modules directory
203 mkdir -p $pkgdir/lib/modules/${_kernver} || return 1
204 cd $pkgdir/lib/modules/${_kernver} || return 1
206 ln -s ../../../usr/src/linux-${_kernver} source || return 1
211 _kernver="$(make kernelrelease)"
213 mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
214 make INSTALL_MOD_PATH="${pkgdir}" modules_install
215 cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"
218 install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
220 # install fallback mkinitcpio.conf file and preset file for kernel
221 install -D -m644 "${srcdir}/${pkgname}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
223 # set correct depmod command for install
225 -e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
226 -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
227 -i "${startdir}/${pkgname}.install"
229 -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|g" \
230 -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|g" \
231 -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|g" \
232 -i "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
234 echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${pkgdir}/etc/mkinitcpio.d/${pkgname}.kver
235 # remove build and source links
236 rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
237 # remove the firmware
238 rm -rf "${pkgdir}/lib/firmware"
239 # gzip -9 all modules to save 100MB of space
240 find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
241 # make room for external modules
242 ln -s "../extramodules-${_basekernel}${_kernelname:--rt-ice}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
243 # add real version for building modules and running depmod from post_install/upgrade
244 mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--rt-ice}"
245 echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--rt-ice}/version"
247 mkdir -p "${pkgdir}/lib/modules/${_kernver}"
249 cd "${pkgdir}/lib/modules/${_kernver}"
250 ln -sf ../../../usr/src/linux-${_kernver} build
252 cd "${srcdir}/linux-${_basekernel}"
253 install -D -m644 Makefile \
254 "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
255 install -D -m644 kernel/Makefile \
256 "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
257 install -D -m644 .config \
258 "${pkgdir}/usr/src/linux-${_kernver}/.config"
260 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
262 for i in acpi asm-generic config crypto drm generated linux math-emu \
263 media net pcmcia scsi sound trace video xen; do
264 cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
267 # copy arch includes for external modules
268 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
269 cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
271 # copy files necessary for later builds, like nvidia and vmware
272 cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
273 cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
275 # fix permissions on scripts dir
276 chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
277 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
279 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
281 cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
283 if [ "${CARCH}" = "i686" ]; then
284 cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
287 cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
289 # add headers for lirc package
290 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
292 cp drivers/media/video/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
294 for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
295 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
296 cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
299 # add docbook makefile
300 install -D -m644 Documentation/DocBook/Makefile \
301 "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
304 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
305 cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
308 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
309 cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
311 # add wireless headers
312 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
313 cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
315 # add dvb headers for external modules
317 # http://bugs.archlinux.org/task/9912
318 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
319 cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
321 # http://bugs.archlinux.org/task/11194
322 #mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
323 #cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
325 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
327 # http://bugs.archlinux.org/task/13146
328 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
329 cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
330 cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
334 # http://bugs.archlinux.org/task/20402
335 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
336 cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
337 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
338 cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
339 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
340 cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
342 # add xfs and shmem for aufs building
343 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
344 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
345 cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
347 # copy in Kconfig files
348 for i in `find . -name "Kconfig*"`; do
349 mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
350 cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
353 chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
354 find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
356 # strip scripts directory
357 find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
358 case "$(file -bi "${binary}")" in
359 *application/x-sharedlib*) # Libraries (.so)
360 /usr/bin/strip ${STRIP_SHARED} "${binary}";;
361 *application/x-archive*) # Libraries (.a)
362 /usr/bin/strip ${STRIP_STATIC} "${binary}";;
363 *application/x-executable*) # Binaries
364 /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
368 # remove unneeded architectures
369 if [ "$keep_source_code" = "0" ]; then
370 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}