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