]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blame - kernel/kernel.nm
kernel: Update to 3.5.3.
[people/ms/ipfire-3.x.git] / kernel / kernel.nm
CommitLineData
166a6c21 1###############################################################################
802ea3af
MT
2# IPFire.org - An Open Source Firewall Solution #
3# Copyright (C) - IPFire Development Team <info@ipfire.org> #
166a6c21
MT
4###############################################################################
5
15a11c5b 6name = kernel
235a7714
MT
7version = 3.5.3
8release = 0.1
15a11c5b 9thisapp = linux-%{version}
166a6c21 10
802ea3af
MT
11maintainer = Michael Tremer <michael.tremer@ipfire.org>
12groups = System/Kernels
13url = http://www.kernel.org/
14license = GPLv2
15summary = The Linux kernel.
166a6c21 16
802ea3af 17description
4c928ab7
MT
18 The kernel package contains the Linux kernel (vmlinuz), the core of any
19 Linux operating system. The kernel handles the basic functions
20 of the operating system: memory allocation, process allocation, device
166a6c21 21 input and output, etc.
802ea3af 22end
166a6c21 23
802ea3af 24# Version helper variables.
bcf38aec
MT
25localversion = %{release}.%{DISTRO_DISTTAG}.%{DISTRO_ARCH}
26fullver = %{version}-%{localversion}
802ea3af 27
fe014038
MT
28source_dl = http://www.kernel.org/pub/linux/kernel/v3.x/
29sources = %{thisapp}.tar.xz
802ea3af
MT
30
31build
ebeed08a
MT
32 # icecream cannot be used to compile the kernel.
33 # Because the PaX patch does use GCC plugins to harden the kernel which
34 # are not available on the remote compilers, we need to disable it here.
35 export ICECC=no
36
802ea3af 37 requires
662414a4 38 asciidoc
c6e2a6c8 39 binutils >= 2.22.52.0.3-2
bcf38aec 40 binutils-devel
c6e2a6c8 41 bison
bcf38aec 42 elfutils-devel
c6e2a6c8 43 flex
fe2de317 44 gcc-plugin-devel
6e9df6a3 45 gettext
802ea3af 46 ncurses-devel
ebeed08a 47 net-tools
802ea3af 48 perl
bcf38aec 49 python-devel
662414a4 50 xmlto
4c928ab7
MT
51
52 /sbin/depmod
bcf38aec
MT
53 end
54
13c9d848
MT
55 tools_cpupower_requires
56 newt-devel
fe2de317 57 pciutils-devel
13c9d848
MT
58 slang-devel
59 end
60
bcf38aec 61 # A list of kernels to build.
45088e83 62 kernels =
bcf38aec 63
45088e83
MT
64 # Should we build cpupower?
65 build_cpupower = 1
66
572b4308
MT
67 # Arguments that are passed to the kernel build command.
68 kernel_build_flags =
69
45088e83 70 kernel_target = bzImage
bcf38aec 71 if "%{DISTRO_ARCH}" == "i686"
1c9b6c79 72 # Build a default and legacy kernel for the
45088e83
MT
73 # i686 architecture.
74 build_kernel_default = 1
1c9b6c79 75 build_kernel_legacy = 1
bcf38aec
MT
76
77 kernel_arch = x86
78 kernel_image = arch/%{kernel_arch}/boot/bzImage
45088e83
MT
79
80 end
81
c112b2e3
MT
82 if "%{DISTRO_ARCH}" == "x86_64"
83 build_kernel_default = 1
84
85 kernel_arch = x86
86 kernel_image = arch/%{kernel_arch}/boot/bzImage
87 end
88
45088e83 89 if "%{DISTRO_ARCH}" == "armv5tel"
4c928ab7
MT
90 # ERROR Currently all kernel images are disabled, because they
91 # won't build with the grsecurity patch.
92
4c928ab7 93 # Build a kernel for Marvell Kirkwood-based devices.
c6e2a6c8 94 build_kernel_kirkwood = 1
45088e83
MT
95
96 kernel_arch = arm
97 kernel_image = arch/%{kernel_arch}/boot/zImage
98
99 # ARM does not support cpupower.
100 build_cpupower = 0
572b4308
MT
101
102 # http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/091404.html
103 kernel_build_flags = KALLSYMS_EXTRA_PASS=1
45088e83
MT
104 end
105
13c9d848 106 if "%{DISTRO_ARCH}" == "armv7hl"
4c928ab7
MT
107 # Build a kernel for TI OMAP SoCs.
108 build_kernel_omap = 1
13c9d848
MT
109
110 kernel_arch = arm
4c928ab7 111 kernel_image = arch/%{kernel_arch}/boot/zImage
13c9d848
MT
112
113 # ARM does not support cpupower.
114 build_cpupower = 0
115 end
116
45088e83
MT
117 # Build default kernel.
118 if "%{build_kernel_default}" == "1"
119 kernels += default
120 end
121
1c9b6c79
MT
122 # Build legacy kernel.
123 if "%{build_kernel_legacy}" == "1"
124 kernels += legacy
45088e83
MT
125 end
126
4c928ab7
MT
127 # Build ARM kirkwood kernel.
128 if "%{build_kernel_kirkwood}" == "1"
129 kernels += kirkwood
130 end
131
132 # Build ARM omap kernel.
133 if "%{build_kernel_omap}" == "1"
134 kernels += omap
135 end
136
13c9d848
MT
137 # Add tools' build requirements if build is requested.
138 if "%{build_cpupower}" == "1"
139 requires += %{tools_cpupower_requires}
140 end
141
802ea3af 142 prepare_cmds
802ea3af
MT
143 rm -f %{DIR_APP}/localversion-grsec
144
5e856224
MT
145 # Remove -Werror flag to fix ARMv5 build.
146 sed -e "s/-Werror//g" -i grsecurity/Makefile
147
148 # Disable the colorize plugin.
149 # It's generally very nice but it clutters our
150 # logfiles.
151 sed -e "/^COLORIZE_PLUGIN_CFLAGS/d" \
152 -i Makefile
153
802ea3af
MT
154 sed -e "s/^HOSTCFLAGS.*=.*/& -fPIC/g" -i Makefile
155
156 cp -vf %{DIR_SOURCE}/%{DISTRO_SNAME}_logo.ppm \
157 drivers/video/logo/logo_linux_clut224.ppm
158
bcf38aec
MT
159 # Get rid of unwanted files resulting from patch fuzz.
160 find . \( -name "*.orig" -o -name "*~" \) -exec rm -f {} \; >/dev/null
161
162 # Remove unnecessary SCM files.
163 find . -name .gitignore -exec rm -f {} \; >/dev/null
164
ebeed08a
MT
165 # This prevents scripts/setlocalversion from mucking with our version numbers.
166 touch .scmversion
167
bcf38aec 168 mkdir -pv configs
4c928ab7
MT
169
170 cd %{DIR_SOURCE}
bcf38aec
MT
171 configure_kernel() {
172 local flavour=${1}
173 local suffix
174 if [ "${flavour}" != "default" ]; then
175 suffix="-${flavour}"
176 fi
177
4c928ab7
MT
178 scripts/configure --kernel-dir=%{DIR_APP} \
179 merge %{DISTRO_ARCH} ${flavour} %{DIR_APP}/configs/config.${flavour}
bcf38aec
MT
180 }
181
182 # Generate configuration files for all kernels we are going to
183 # build.
184 for kernel in %{kernels}; do
185 configure_kernel ${kernel}
186 done
802ea3af
MT
187 end
188
189 build
bcf38aec
MT
190 build_kernel() {
191 local flavour=${1}
192 local suffix
193 local localversion="%{localversion}"
194 local fullversion="%{fullver}"
195 if [ "${flavour}" != "default" ]; then
196 suffix="-${flavour}"
197 localversion="${localversion}.${flavour}"
198 fullversion="${fullversion}.${flavour}"
199 fi
802ea3af 200
ebeed08a
MT
201 # Label the build.
202 sed -i Makefile \
203 -e "s/^EXTRAVERSION.*/EXTRAVERSION = -${localversion}/"
204
bcf38aec
MT
205 # Clean up the source tree.
206 make mrproper
802ea3af 207
bcf38aec
MT
208 # Install configuration file.
209 cp configs/config.${flavour} .config
c6e2a6c8 210 cat .config
802ea3af 211
bcf38aec 212 # Run the build.
ebeed08a 213 make ARCH=%{kernel_arch} oldnoconfig >/dev/null
572b4308
MT
214 make ARCH=%{kernel_arch} CC="gcc -fno-PIE" %{kernel_target} modules \
215 %{kernel_build_flags} %{PARALLELISMFLAGS}
bcf38aec
MT
216
217 # Install the results.
c4ef5c45 218 mkdir -pv %{BUILDROOT}/boot %{BUILDROOT}/usr/lib/modules/${fullversion}
bcf38aec
MT
219 install -m 755 %{kernel_image} %{BUILDROOT}/boot/vmlinuz-${fullversion}
220 install -m 644 .config %{BUILDROOT}/boot/config-${fullversion}
221 install -m 644 System.map %{BUILDROOT}/boot/System.map-${fullversion}
222
223 # Create empty initramfs (20M).
224 dd if=/dev/zero of=%{BUILDROOT}/boot/initramfs-${fullversion}.img bs=1M count=20
225
226 # Install modules.
c4ef5c45 227 make ARCH=%{kernel_arch} INSTALL_MOD_PATH=%{BUILDROOT}/usr mod-fw= \
bcf38aec 228 KERNELRELEASE=${fullversion} modules_install
c8f122e5
MT
229
230 # Install vdso.
231 case "%{DISTRO_ARCH}" in
232 i686)
233 make ARCH=%{kernel_arch} INSTALL_MOD_PATH=%{BUILDROOT} \
234 KERNELRELEASE=${fullversion} vdso_install
235 ;;
236 esac
802ea3af 237
bcf38aec
MT
238 # Create an empty settings file for dracut
239 mkdir -pv %{BUILDROOT}/etc/ld.so.conf.d
240 echo "# Placeholder file, no vDSO hwcap entries used in this kernel." \
241 > %{BUILDROOT}/etc/ld.so.conf.d/kernel-${fullversion}.conf
802ea3af 242
bcf38aec
MT
243 # And now the scary looking part.
244 #
245 # Recreate source and build links.
c4ef5c45
MT
246 rm -vf %{BUILDROOT}/usr/lib/modules/${fullversion}/{build,source}
247 mkdir -pv %{BUILDROOT}/usr/lib/modules/${fullversion}/build
248 ln -svf build %{BUILDROOT}/usr/lib/modules/${fullversion}/source
802ea3af 249
bcf38aec 250 # Create dirs for extra modules.
c4ef5c45 251 mkdir -pv %{BUILDROOT}/usr/lib/modules/${fullversion}/extra
802ea3af 252
bcf38aec 253 cp -v --parents $(find -type f -name "Makefile*" -o -name "Kconfig*") \
c4ef5c45 254 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
bcf38aec 255 cp -v Module.symvers System.map \
c4ef5c45
MT
256 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
257 rm -vrf %{BUILDROOT}/usr/lib/modules/${fullversion}/build/{Documentation,scripts,include}
bcf38aec 258
c4ef5c45
MT
259 cp -v .config %{BUILDROOT}/usr/lib/modules/${fullversion}/build
260 cp -va scripts %{BUILDROOT}/usr/lib/modules/${fullversion}/build
261 find %{BUILDROOT}/usr/lib/modules/${fullversion}/build/scripts -name "*.o" \
bcf38aec
MT
262 -exec rm -vf {} \;
263
264 cp -va --parents arch/%{kernel_arch}/include \
c4ef5c45
MT
265 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
266 cp -va include %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include
bcf38aec
MT
267
268 # Make sure we can build external modules.
c4ef5c45
MT
269 touch -r %{BUILDROOT}/usr/lib/modules/${fullversion}/build/Makefile \
270 %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include/linux/version.h
271 touch -r %{BUILDROOT}/usr/lib/modules/${fullversion}/build/.config \
272 %{BUILDROOT}/usr/lib/modules/${fullversion}/build/autoconf.h
273 cp -v %{BUILDROOT}/usr/lib/modules/${fullversion}/build/.config \
274 %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include/config/auto.conf
275
276 find %{BUILDROOT}/usr/lib/modules/${fullversion} -name "*.ko" -type f | \
bcf38aec
MT
277 xargs chmod u+x
278
bcf38aec
MT
279 # Move all development files to /usr/src.
280 mkdir -pv %{BUILDROOT}/usr/src/kernels
c4ef5c45 281 mv -v %{BUILDROOT}/usr/lib/modules/${fullversion}/build \
bcf38aec 282 %{BUILDROOT}/usr/src/kernels/${fullversion}
c4ef5c45
MT
283 ln -svf ../../../src/kernels/${fullversion} \
284 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
bcf38aec
MT
285
286 find %{BUILDROOT}/usr/src/kernels -name ".*.cmd" -exec rm -f {} \;
287 }
288
289 for kernel in %{kernels}; do
290 build_kernel ${kernel}
291 done
6e9df6a3
MT
292
293 # Build tools.
294 # cpupower
45088e83
MT
295 if [ "%{build_cpupower}" = "1" ]; then
296 chmod +x tools/power/cpupower/utils/version-gen.sh
297 make -C tools/power/cpupower CPUFREQ_BENCH=false %{PARALLELISMFLAGS}
298
299 cd tools/power/cpupower/debug/i386
300 make %{PARALLELISMFLAGS} centrino-decode powernow-k8-decode
301 cd -
302 fi
bcf38aec
MT
303 end
304
305 install
4c928ab7
MT
306 # When no kernels are configured, we create a default config
307 # which enables us to install at least the header files.
308 [ -n "%{kernels}" ] || make ARCH=%{kernel_arch} defconfig
309
802ea3af 310 # Install the header files
c8f122e5 311 make ARCH=%{kernel_arch} INSTALL_HDR_PATH=dest headers_install
802ea3af
MT
312 mkdir -pv %{BUILDROOT}/usr/include
313 find dest/include \( -name .install -o -name ..install.cmd \) -delete
314 cp -rv dest/include/* %{BUILDROOT}/usr/include
315
316 # Glibc provides these headers
317 rm -rfv %{BUILDROOT}/usr/include/scsi \
318 %{BUILDROOT}/usr/include/asm*/atomic.h \
319 %{BUILDROOT}/usr/include/asm*/io.h \
320 %{BUILDROOT}/usr/include/asm*/irq.h
321
15a11c5b
MT
322 # Remove all firmware files which are distributed by linux-firmware
323 rm -rfv %{BUILDROOT}/lib/firmware
bcf38aec
MT
324
325 # Install tools.
028e459b 326 make -C tools/perf DESTDIR=%{BUILDROOT} WERROR=0 \
ebeed08a 327 HAVE_CPLUS_DEMANGLE=1 prefix=/usr perfexecdir=lib/perf-core \
662414a4 328 install install-man
6e9df6a3
MT
329
330 # cpupower
45088e83 331 if [ "%{build_cpupower}" = "1" ]; then
c2c61882
MT
332 make -C tools/power/cpupower DESTDIR=%{BUILDROOT} libdir=%{libdir} \
333 mandir=%{mandir} CPUFREQ_BENCH=false install
45088e83
MT
334 cd tools/power/cpupower/debug/i386
335 install -m 755 centrino-decode %{BUILDROOT}/usr/bin/centrino-decode
336 install -m 755 powernow-k8-decode %{BUILDROOT}/usr/bin/powernow-k8-decode
337 cd -
c2c61882 338 chmod 0755 %{BUILDROOT}%{libdir}/libcpupower.so*
45088e83 339 fi
802ea3af
MT
340 end
341end
342
343packages
bcf38aec 344 template KERNEL
aa3ab846 345 kernel_name = kernel
bcf38aec
MT
346 kernel_release = %{fullver}
347
348 summary = The Linux kernel %{kernel_release}.
349
1c9b6c79 350 prerequires
4c928ab7 351 /sbin/depmod
1c9b6c79
MT
352 end
353
354 provides
355 kernel=%{kernel_release}
356 end
357
802ea3af 358 requires
4c928ab7
MT
359 dracut
360 grubby
802ea3af
MT
361 linux-firmware
362 end
ad1ea534 363
bcf38aec
MT
364 files
365 /boot/System.map-%{kernel_release}
366 /boot/vmlinuz-%{kernel_release}
367 /boot/initramfs-%{kernel_release}.img
368 /etc/ld.so.conf.d/kernel-%{kernel_release}.conf
c4ef5c45 369 /usr/lib/modules/%{kernel_release}
bcf38aec
MT
370 end
371
aa3ab846 372 _posttrans
c8f9fe35
MT
373 /sbin/new-kernel-pkg --package %{kernel_name} --mkinitrd --dracut --depmod --update %{kernel_release}
374 /sbin/new-kernel-pkg --package %{kernel_name} --rpmposttrans %{kernel_release}
aa3ab846
MT
375 end
376
ad1ea534 377 script posttransin
aa3ab846
MT
378 %{_posttrans}
379 end
380
381 script posttransup
382 %{_posttrans}
383 end
384
385 script postin
c8f9fe35 386 /sbin/new-kernel-pkg --package %{kernel_name} --install %{kernel_release}
aa3ab846
MT
387 end
388
389 script postup
390 /sbin/new-kernel-pkg --package %{kernel_name} --install %{kernel_release}
391 end
392
393 script preun
394 /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{kernel_release}
bcf38aec
MT
395 end
396 end
397
398 template KERNELDEVEL
399 kernel_release = %{fullver}
400
401 summary = Development files of kernel-%{kernel_release}.
402 description
403 %{summary}
404
405 Install this package in order to compile modules for
406 kernel release %{kernel_release}.
407 end
408
409 filter_requires
410 perl>=[0-9]\:.*
ad1ea534
MT
411 end
412
bcf38aec 413 files
c4ef5c45
MT
414 /usr/lib/modules/%{kernel_release}/build
415 /usr/lib/modules/%{kernel_release}/source
bcf38aec 416 /usr/src/kernels/%{kernel_release}
ad1ea534 417 end
802ea3af 418 end
bcf38aec 419
45088e83
MT
420 if "%{build_kernel_default}" == "1"
421 package kernel
422 template KERNEL
58dc2060 423
45088e83
MT
424 kernel_name = kernel
425 kernel_release = %{fullver}
426 end
bcf38aec 427
45088e83
MT
428 package kernel-devel
429 template KERNELDEVEL
58dc2060 430
45088e83
MT
431 kernel_name = kernel
432 kernel_release = %{fullver}
433 end
bcf38aec
MT
434 end
435
1c9b6c79
MT
436 if "%{build_kernel_legacy}" == "1"
437 package kernel-legacy
45088e83 438 template KERNEL
bcf38aec 439
1c9b6c79
MT
440 kernel_name = kernel-legacy
441 kernel_release = %{fullver}.legacy
45088e83
MT
442 end
443
1c9b6c79 444 package kernel-legacy-devel
45088e83
MT
445 template KERNELDEVEL
446
1c9b6c79
MT
447 kernel_name = kernel-legacy
448 kernel_release = %{fullver}.legacy
45088e83 449 end
bcf38aec
MT
450 end
451
4c928ab7
MT
452 if "%{build_kernel_kirkwood}" == "1"
453 package kernel-kirkwood
454 template KERNEL
455
456 kernel_name = kernel-kirkwood
457 kernel_release = %{fullver}.kirkwood
458 end
459
460 package kernel-kirkwood-devel
461 template KERNELDEVEL
462
463 kernel_name = kernel-kirkwood
464 kernel_release = %{fullver}.kirkwood
465 end
466 end
467
468 if "%{build_kernel_omap}" == "1"
469 package kernel-omap
470 template KERNEL
471
472 kernel_name = kernel-omap
473 kernel_release = %{fullver}.omap
474 end
475
476 package kernel-omap-devel
477 template KERNELDEVEL
478
479 kernel_name = kernel-omap
480 kernel_release = %{fullver}.omap
481 end
482 end
483
802ea3af 484 package kernel-headers
802ea3af
MT
485 summary = Header files of the kernel release %{fullver}.
486 desciption = %{summary}
c698e4be
MT
487
488 files
489 /usr/include
490 end
802ea3af 491 end
bcf38aec 492
ebeed08a
MT
493 package kernel-tools
494 summary = Assortment of tools for the Linux kernel.
495 description = %{summary}
496
497 filter_requires
498 perl>=[0-9]\:.*
499 end
500
501 files
502 /
503 !/boot
ebeed08a 504 !/usr/include
c4ef5c45 505 !/usr/lib/modules
ebeed08a 506 !/usr/src
fe2de317
MT
507 !/usr/src/debug
508 !/usr/lib/debug
ebeed08a
MT
509 end
510 end
802ea3af 511end