1 # Contributor: Giuseppe Calderaro <giuseppecalderaro@gmail.com>
2 # Contributor: (misc updates) Michael Evans <mjevans1983@gmail.com>
3 # Maintainer: (RT and misc) Ng Oon-Ee <ngoonee.talk@gmail.com>
5 pkgdesc="The Linux Kernel and modules with tuxonice support and optional bfs/ck patches"
6 depends=('coreutils' 'linux-firmware' 'module-init-tools' 'mkinitcpio>=0.5.20')
7 optdepends=('crda: to set the correct wireless channels of your country')
9 backup=(etc/mkinitcpio.d/$pkgname.preset)
10 _kernelname=${pkgname#kernel26}
15 install=$pkgname.install
16 makedepends=('xmlto' 'docbook-xsl')
19 url="http://www.kernel.org"
21 ### User/Environment defined variables
22 _skip_minor_patch=${_skip_minor_patch:-0}
23 enable_toi=${enable_toi:-1}
24 bfs_scheduler=${bfs_scheduler:-0}
25 keep_source_code=${keep_source_code:-0}
28 menuconfig=${menuconfig:-0}
29 local_patch_dir="${local_patch_dir:-}"
30 use_config="${use_config:-}"
31 use_config_gz=${use_config_gz:-0}
32 enable_reiser4=${enable_reiser4:-0}
33 ### Compile time defined variables
37 file_reiser4="reiser4-for-2.6.38.patch.bz2"
38 file_toi="tuxonice-3.2-for-2.6.38.patch.bz2"
39 file_bfs="2.6.38.3-sched-bfs-401.patch"
43 source=(http://kernel.org/pub/linux/kernel/v2.6/linux-${_basekernel}.tar.bz2
44 http://www.kernel.org/pub/linux/kernel/v2.6/patch-${_basekernel}.${_minor_patch}.bz2
45 http://www.kernel.org/pub/linux/kernel/people/edward/reiser4/reiser4-for-2.6/${file_reiser4}
46 http://www.tuxonice.net/files/${file_toi}
47 http://ck.kolivas.org/patches/bfs/${_basekernel}/${file_bfs}
50 md5sums=('7d471477bfa67546f902da62227fa976'
51 'c0f416f6a2e916633f697287cc7cb914'
52 'f9f3f59a2a4cbbef3be3944fe350bfc9'
53 'e0e0bb351ff773cf3ad80a65b6671c51'
54 '55174ad997e84d7e29ee480ef13e64c7'
55 '620d67be59a2ca606b471c8998f51ee8'
56 'b0a4c6d9c17384d66599df27abf69919'
57 'fb68a8239ef0794deb70cbb7397c2f23')
60 cd ${srcdir}/linux-$_basekernel
62 # Applying official patch
63 if [ "$_minor_patch" != "0" ] && [ "$_skip_minor_patch" != "1" ] ; then
64 echo "Applying patch-${_basekernel}.${_minor_patch}.bz2"
65 patch -Np1 -i ${srcdir}/patch-${_basekernel}.${_minor_patch} || { echo Failed patch-${_basekernel}.${_minor_patch}.bz2 ; return 1 ; }
68 if [ -n "${local_patch_dir}" ] && [ -d "${local_patch_dir}" ] ; then
69 echo "Applying patches from ${local_patch_dir} ..."
70 for my_patch in "${local_patch_dir}"/* ; do
71 echo -e "Applying custom patch:\t'${my_patch}'" || true
72 patch -Np1 -i "${my_patch}" || { echo -e "Failed custom patch:\t'${my_patch}'" ; return 1 ; }
76 # applying reiserfs4 patch
77 if [ "$enable_reiser4" = "1" ]; then
78 echo "Applying ${file_reiser4%.gz}"
79 bzip2 -dc ${srcdir}/${file_reiser4} | patch -Np1 || { echo "Failed reiser4 patch '${file_reiser4%.gz}'"; return 1 ; }
82 # applying tuxonice patch
83 if [ "${enable_toi}" = "1" ]; then
84 echo "Applying ${file_toi%.bz2}"
85 bzip2 -dck ${srcdir}/${file_toi} \
86 | sed 's/printk(KERN_INFO "PM: Creating hibernation image:\\n/printk(KERN_INFO "PM: Creating hibernation image: \\n/' \
87 | patch -Np1 -F4 || { echo "Failed TOI"; return 1 ; }
90 if [ "${bfs_scheduler}" = "1" ]; then
91 # applying BFS scheduler patch
92 echo "Applying BFS scheduler patch"
93 patch -Np1 -i ${srcdir}/${file_bfs} || { echo "Failed BFS"; return 1 ; }
97 sed -i 's|^EXTRAVERSION = .*$|EXTRAVERSION =|g' Makefile
99 # load configuration for i686 or x86_64
100 if [ "$CARCH" = "x86_64" ]; then
101 cat ../config.x86_64 >./.config
103 cat ../config >./.config
106 # use custom config instead
107 if [ -n "${use_config}" ] ; then
108 echo "Using config: '${use_config}'"
109 cat "${use_config}" > ./.config
113 # use existing config.gz
114 if [ "$use_config_gz" = "1" ]; then
115 zcat /proc/config.gz > ./.config
118 if [ "${_kernelname}" != "" ]; then
119 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
122 # hack to prevent output kernel from being marked as dirty or git
123 chmod +x ${srcdir}/linux-${_basekernel}/scripts/setlocalversion
124 sed 's/head=`git rev-parse --verify --short HEAD 2>\/dev\/null`/0/' \
125 ${srcdir}/linux-${_basekernel}/scripts/setlocalversion \
126 > ${srcdir}/linux-${_basekernel}/scripts/setlocalversion.new
127 mv ${srcdir}/linux-${_basekernel}/scripts/setlocalversion.new \
128 ${srcdir}/linux-${_basekernel}/scripts/setlocalversion
132 # Configure the kernel. Replace the line below with one of your choice.
133 if [ "$gconfig" = "1" ]; then
136 if [ "$xconfig" = "1" ]; then
139 if [ "$menuconfig" = "1" ]; then
145 make prepare # Necessary in case config has been changed
147 make ${MAKEFLAGS} bzImage modules
150 package_kernel26-ice() {
153 cd ${srcdir}/linux-$_basekernel
154 if [ "$keep_source_code" = "1" ]; then
155 echo -n "Copying source code..."
156 # Keep the source code
158 mkdir -p $pkgdir/usr/src || return 1
159 cp -a ${srcdir}/linux-${_basekernel} $pkgdir/usr/src/linux-${_kernver} || return 1
161 #Add a link from the modules directory
162 mkdir -p $pkgdir/lib/modules/${_kernver} || return 1
163 cd $pkgdir/lib/modules/${_kernver} || return 1
165 ln -s ../../../usr/src/linux-${_kernver} source || return 1
170 _kernver="$(make kernelrelease)"
171 mkdir -p ${pkgdir}/{lib/modules,lib/firmware,boot}
172 make INSTALL_MOD_PATH=${pkgdir} modules_install
173 cp System.map ${pkgdir}/boot/System.map26${_kernelname}
174 cp arch/$KARCH/boot/bzImage ${pkgdir}/boot/vmlinuz26${_kernelname}
176 install -m644 -D vmlinux ${pkgdir}/usr/src/linux-${_kernver}/vmlinux
178 # install fallback mkinitcpio.conf file and preset file for kernel
179 install -m644 -D ${srcdir}/${pkgname}.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
180 # set correct depmod command for install
182 -e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
183 -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
184 -i $startdir/${pkgname}.install
186 -e "s|source .*|source /etc/mkinitcpio.d/kernel26${_kernelname}.kver|g" \
187 -e "s|default_image=.*|default_image=\"/boot/${pkgname}.img\"|g" \
188 -e "s|fallback_image=.*|fallback_image=\"/boot/${pkgname}-fallback.img\"|g" \
189 -i ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
191 echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${pkgdir}/etc/mkinitcpio.d/${pkgname}.kver
192 # remove build and source links
193 rm -f ${pkgdir}/lib/modules/${_kernver}/{source,build}
194 # remove the firmware
195 rm -rf ${pkgdir}/lib/firmware
196 # gzip -9 all modules to safe 100MB of space
197 find "$pkgdir" -name '*.ko' -exec gzip -9 {} \;
199 mkdir -p ${pkgdir}/lib/modules/${_kernver}
200 cd ${pkgdir}/lib/modules/${_kernver}
201 ln -sf ../../../usr/src/linux-${_kernver} build
202 cd ${srcdir}/linux-$_basekernel
203 install -D -m644 Makefile \
204 ${pkgdir}/usr/src/linux-${_kernver}/Makefile
205 install -D -m644 kernel/Makefile \
206 ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
207 install -D -m644 .config \
208 ${pkgdir}/usr/src/linux-${_kernver}/.config
209 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include
211 for i in acpi asm-generic config generated linux math-emu media net pcmcia scsi sound trace video xen; do
212 cp -a include/$i ${pkgdir}/usr/src/linux-${_kernver}/include/
215 # copy arch includes for external modules
216 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/x86
217 cp -a arch/x86/include ${pkgdir}/usr/src/linux-${_kernver}/arch/x86/
219 # copy files necessary for later builds, like nvidia and vmware
220 cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
221 cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}
222 # fix permissions on scripts dir
223 chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
224 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions
226 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel
228 cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
229 if [ "$CARCH" = "i686" ]; then
230 cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
232 cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/
234 # add headers for lirc package
235 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video
236 cp drivers/media/video/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/
237 for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
238 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
239 cp -a drivers/media/video/$i/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
241 # add docbook makefile
242 install -D -m644 Documentation/DocBook/Makefile \
243 ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
245 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
246 cp drivers/md/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
248 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/linux
249 cp include/linux/inotify.h ${pkgdir}/usr/src/linux-${_kernver}/include/linux/
250 # add wireless headers
251 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
252 cp net/mac80211/*.h ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
253 # add dvb headers for external modules
255 # http://bugs.archlinux.org/task/9912
256 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
257 cp drivers/media/dvb/dvb-core/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
258 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
260 # http://bugs.archlinux.org/task/13146
261 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
262 cp drivers/media/dvb/frontends/lgdt330x.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
263 cp drivers/media/video/msp3400-driver.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
266 # http://bugs.archlinux.org/task/20402
267 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb
268 cp drivers/media/dvb/dvb-usb/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/
269 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends
270 cp drivers/media/dvb/frontends/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
271 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners
272 cp drivers/media/common/tuners/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/
273 # add xfs and shmem for aufs building
274 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs
275 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/mm
276 cp fs/xfs/xfs_sb.h ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h
277 # add headers vor virtualbox
279 # http://bugs.archlinux.org/task/14568
280 cp -a include/drm $pkgdir/usr/src/linux-${_kernver}/include/
281 # add headers for broadcom wl
283 # http://bugs.archlinux.org/task/14568
284 cp -a include/trace $pkgdir/usr/src/linux-${_kernver}/include/
285 # add headers for crypto modules
287 # http://bugs.archlinux.org/task/22081
288 cp -a include/crypto $pkgdir/usr/src/linux-${_kernver}/include/
289 # copy in Kconfig files
290 for i in `find . -name "Kconfig*"`; do
291 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
292 cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
295 chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
296 find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
297 # strip scripts directory
298 find ${pkgdir}/usr/src/linux-${_kernver}/scripts -type f -perm -u+w 2>/dev/null | while read binary ; do
299 case "$(file -bi "$binary")" in
300 *application/x-sharedlib*) # Libraries (.so)
301 /usr/bin/strip $STRIP_SHARED "$binary";;
302 *application/x-archive*) # Libraries (.a)
303 /usr/bin/strip $STRIP_STATIC "$binary";;
304 *application/x-executable*) # Binaries
305 /usr/bin/strip $STRIP_BINARIES "$binary";;
308 # remove unneeded architectures
309 if [ "$keep_source_code" = "0" ]; then
310 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}