]>
Commit | Line | Data |
---|---|---|
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 | 6 | name = kernel |
d27a5bdd | 7 | version = 4.12.4 |
fe1f3d4a | 8 | release = 1 |
15a11c5b | 9 | thisapp = linux-%{version} |
166a6c21 | 10 | |
81bb0557 | 11 | maintainer = Arne Fitzenreiter <arne.fitzenreiter@ipfire.org> |
802ea3af MT |
12 | groups = System/Kernels |
13 | url = http://www.kernel.org/ | |
14 | license = GPLv2 | |
15 | summary = The Linux kernel. | |
166a6c21 | 16 | |
802ea3af | 17 | description |
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 | 22 | end |
166a6c21 | 23 | |
802ea3af | 24 | # Version helper variables. |
bcf38aec MT |
25 | localversion = %{release}.%{DISTRO_DISTTAG}.%{DISTRO_ARCH} |
26 | fullver = %{version}-%{localversion} | |
802ea3af | 27 | |
94cce289 | 28 | source_dl = http://www.kernel.org/pub/linux/kernel/v4.x/ |
fe014038 | 29 | sources = %{thisapp}.tar.xz |
802ea3af MT |
30 | |
31 | build | |
6b6a8ff6 MT |
32 | kernel_logo = /usr/share/pixmaps/kernel-logo.ppm |
33 | ||
802ea3af | 34 | requires |
662414a4 | 35 | asciidoc |
81bb0557 | 36 | audit-devel |
7f6f4de5 | 37 | bc |
849a0073 | 38 | binutils >= 2.25 |
bcf38aec | 39 | binutils-devel |
c6e2a6c8 | 40 | bison |
bcf38aec | 41 | elfutils-devel |
c6e2a6c8 | 42 | flex |
461b7e77 | 43 | gcc >= 4.9 |
fe2de317 | 44 | gcc-plugin-devel |
6e9df6a3 | 45 | gettext |
849a0073 | 46 | hostname |
81bb0557 | 47 | libunwind-devel |
802ea3af | 48 | ncurses-devel |
ebeed08a | 49 | net-tools |
7c69f2c2 MT |
50 | newt-devel |
51 | pciutils-devel | |
802ea3af | 52 | perl |
bcf38aec | 53 | python-devel |
849a0073 | 54 | openssl-devel |
7c69f2c2 | 55 | slang-devel |
662414a4 | 56 | xmlto |
bf6ee3f7 | 57 | xz |
4c928ab7 MT |
58 | |
59 | /sbin/depmod | |
6b6a8ff6 | 60 | %{kernel_logo} |
bcf38aec MT |
61 | end |
62 | ||
63 | # A list of kernels to build. | |
45088e83 | 64 | kernels = |
bcf38aec | 65 | |
55586be2 MT |
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= | |
572b4308 | 69 | |
34520606 | 70 | kernel_arch = %{DISTRO_PLATFORM} |
45088e83 | 71 | kernel_target = bzImage |
967da24b MT |
72 | kernel_image = arch/%{kernel_arch}/boot/%{kernel_target} |
73 | ||
c112b2e3 MT |
74 | if "%{DISTRO_ARCH}" == "x86_64" |
75 | build_kernel_default = 1 | |
c112b2e3 MT |
76 | end |
77 | ||
d5383c43 | 78 | if "%{DISTRO_ARCH}" == "aarch64" |
55586be2 | 79 | build_kernel_default = 1 |
d5383c43 MT |
80 | |
81 | kernel_arch = arm64 | |
82 | kernel_target = Image.gz | |
83 | end | |
84 | ||
13c9d848 | 85 | if "%{DISTRO_ARCH}" == "armv7hl" |
7f6f4de5 MT |
86 | # Build the default unified kernel. |
87 | build_kernel_default = 1 | |
88 | ||
7f6f4de5 | 89 | kernel_target = zImage |
967da24b MT |
90 | end |
91 | ||
92 | # mkimage is a requirement to build uImage images. | |
93 | if "%{kernel_target}" == "uImage" | |
94 | requires += u-boot-tools | |
13c9d848 MT |
95 | end |
96 | ||
45088e83 MT |
97 | # Build default kernel. |
98 | if "%{build_kernel_default}" == "1" | |
99 | kernels += default | |
100 | end | |
101 | ||
ad855779 | 102 | perf_make = make %{PARALLELISMFLAGS} -C tools/perf V=1 WERROR=0 \ |
302e8df8 MT |
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 | ||
802ea3af | 106 | prepare_cmds |
5e856224 MT |
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 | ||
802ea3af MT |
113 | sed -e "s/^HOSTCFLAGS.*=.*/& -fPIC/g" -i Makefile |
114 | ||
6b6a8ff6 | 115 | cp -vf %{kernel_logo} \ |
802ea3af MT |
116 | drivers/video/logo/logo_linux_clut224.ppm |
117 | ||
bcf38aec MT |
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 | ||
ebeed08a MT |
124 | # This prevents scripts/setlocalversion from mucking with our version numbers. |
125 | touch .scmversion | |
126 | ||
bcf38aec | 127 | mkdir -pv configs |
4c928ab7 MT |
128 | |
129 | cd %{DIR_SOURCE} | |
bcf38aec MT |
130 | configure_kernel() { |
131 | local flavour=${1} | |
132 | local suffix | |
133 | if [ "${flavour}" != "default" ]; then | |
134 | suffix="-${flavour}" | |
135 | fi | |
136 | ||
4c928ab7 MT |
137 | scripts/configure --kernel-dir=%{DIR_APP} \ |
138 | merge %{DISTRO_ARCH} ${flavour} %{DIR_APP}/configs/config.${flavour} | |
bcf38aec MT |
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 | |
302e8df8 MT |
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" | |
802ea3af MT |
150 | end |
151 | ||
152 | build | |
bcf38aec MT |
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 | |
802ea3af | 163 | |
ebeed08a MT |
164 | # Label the build. |
165 | sed -i Makefile \ | |
166 | -e "s/^EXTRAVERSION.*/EXTRAVERSION = -${localversion}/" | |
167 | ||
bcf38aec MT |
168 | # Clean up the source tree. |
169 | make mrproper | |
802ea3af | 170 | |
bcf38aec MT |
171 | # Install configuration file. |
172 | cp configs/config.${flavour} .config | |
c6e2a6c8 | 173 | cat .config |
802ea3af | 174 | |
bcf38aec | 175 | # Run the build. |
ebeed08a | 176 | make ARCH=%{kernel_arch} oldnoconfig >/dev/null |
572b4308 MT |
177 | make ARCH=%{kernel_arch} CC="gcc -fno-PIE" %{kernel_target} modules \ |
178 | %{kernel_build_flags} %{PARALLELISMFLAGS} | |
bcf38aec | 179 | |
9d4be168 MT |
180 | # Compile Flattened Device Tree database |
181 | case "${DISTRO_ARCH}" in | |
d5383c43 | 182 | aarch64|arm*) |
9d4be168 MT |
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 | ||
bcf38aec | 195 | # Install the results. |
c4ef5c45 | 196 | mkdir -pv %{BUILDROOT}/boot %{BUILDROOT}/usr/lib/modules/${fullversion} |
bcf38aec MT |
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. | |
81bb0557 | 205 | make ARCH=%{kernel_arch} INSTALL_MOD_PATH=%{BUILDROOT}/usr mod-fw= V=1 \ |
bcf38aec | 206 | KERNELRELEASE=${fullversion} modules_install |
c8f122e5 | 207 | |
bcf38aec | 208 | # Create an empty settings file for dracut |
7c69f2c2 | 209 | mkdir -p %{BUILDROOT}/etc/ld.so.conf.d |
bcf38aec MT |
210 | echo "# Placeholder file, no vDSO hwcap entries used in this kernel." \ |
211 | > %{BUILDROOT}/etc/ld.so.conf.d/kernel-${fullversion}.conf | |
802ea3af | 212 | |
bcf38aec MT |
213 | # And now the scary looking part. |
214 | # | |
215 | # Recreate source and build links. | |
7c69f2c2 MT |
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 | |
802ea3af | 219 | |
bcf38aec | 220 | # Create dirs for extra modules. |
7c69f2c2 | 221 | mkdir -p %{BUILDROOT}/usr/lib/modules/${fullversion}/extra |
802ea3af | 222 | |
7c69f2c2 | 223 | cp --parents $(find -type f -name "Makefile*" -o -name "Kconfig*") \ |
c4ef5c45 | 224 | %{BUILDROOT}/usr/lib/modules/${fullversion}/build |
7c69f2c2 | 225 | cp Module.symvers System.map \ |
c4ef5c45 | 226 | %{BUILDROOT}/usr/lib/modules/${fullversion}/build |
7c69f2c2 | 227 | rm -rf %{BUILDROOT}/usr/lib/modules/${fullversion}/build/{Documentation,scripts,include} |
bcf38aec | 228 | |
7c69f2c2 MT |
229 | cp .config %{BUILDROOT}/usr/lib/modules/${fullversion}/build |
230 | cp -a scripts %{BUILDROOT}/usr/lib/modules/${fullversion}/build | |
c4ef5c45 | 231 | find %{BUILDROOT}/usr/lib/modules/${fullversion}/build/scripts -name "*.o" \ |
bcf38aec MT |
232 | -exec rm -vf {} \; |
233 | ||
7c69f2c2 | 234 | cp -a --parents arch/%{kernel_arch}/include \ |
c4ef5c45 | 235 | %{BUILDROOT}/usr/lib/modules/${fullversion}/build |
7c69f2c2 | 236 | cp -a include %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include |
bcf38aec MT |
237 | |
238 | # Make sure we can build external modules. | |
c4ef5c45 MT |
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 | |
7c69f2c2 | 243 | cp %{BUILDROOT}/usr/lib/modules/${fullversion}/build/.config \ |
c4ef5c45 MT |
244 | %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include/config/auto.conf |
245 | ||
246 | find %{BUILDROOT}/usr/lib/modules/${fullversion} -name "*.ko" -type f | \ | |
bf6ee3f7 | 247 | xargs --no-run-if-empty chmod u+x |
bcf38aec | 248 | |
bcf38aec | 249 | # Move all development files to /usr/src. |
7c69f2c2 MT |
250 | mkdir -p %{BUILDROOT}/usr/src/kernels |
251 | mv %{BUILDROOT}/usr/lib/modules/${fullversion}/build \ | |
bcf38aec | 252 | %{BUILDROOT}/usr/src/kernels/${fullversion} |
7c69f2c2 | 253 | ln -sf ../../../src/kernels/${fullversion} \ |
c4ef5c45 | 254 | %{BUILDROOT}/usr/lib/modules/${fullversion}/build |
bcf38aec | 255 | |
81bb0557 MT |
256 | # Fix permissions. |
257 | find %{BUILDROOT}/usr/src/kernels -name "modules.order" \ | |
258 | -exec chmod 644 {} \; | |
259 | ||
bcf38aec | 260 | find %{BUILDROOT}/usr/src/kernels -name ".*.cmd" -exec rm -f {} \; |
d27a5bdd AF |
261 | |
262 | # remove device tree compiler because there are dead links | |
263 | rm -rf %{BUILDROOT}/usr/src/kernels/*/scripts/dtc | |
bcf38aec MT |
264 | } |
265 | ||
266 | for kernel in %{kernels}; do | |
267 | build_kernel ${kernel} | |
268 | done | |
6e9df6a3 MT |
269 | |
270 | # Build tools. | |
302e8df8 | 271 | # perf |
ad855779 | 272 | #%{perf_make} DESTDIR=%{BUILDROOT} all |
302e8df8 | 273 | |
6e9df6a3 | 274 | # cpupower |
7c69f2c2 MT |
275 | chmod +x tools/power/cpupower/utils/version-gen.sh |
276 | make -C tools/power/cpupower CPUFREQ_BENCH=false %{PARALLELISMFLAGS} | |
277 | ||
302e8df8 MT |
278 | pushd tools/thermal/tmon |
279 | make | |
280 | popd | |
bcf38aec MT |
281 | end |
282 | ||
283 | install | |
4c928ab7 MT |
284 | # When no kernels are configured, we create a default config |
285 | # which enables us to install at least the header files. | |
286 | [ -n "%{kernels}" ] || make ARCH=%{kernel_arch} defconfig | |
287 | ||
802ea3af | 288 | # Install the header files |
c8f122e5 | 289 | make ARCH=%{kernel_arch} INSTALL_HDR_PATH=dest headers_install |
802ea3af MT |
290 | mkdir -pv %{BUILDROOT}/usr/include |
291 | find dest/include \( -name .install -o -name ..install.cmd \) -delete | |
292 | cp -rv dest/include/* %{BUILDROOT}/usr/include | |
293 | ||
294 | # Glibc provides these headers | |
295 | rm -rfv %{BUILDROOT}/usr/include/scsi \ | |
296 | %{BUILDROOT}/usr/include/asm*/atomic.h \ | |
297 | %{BUILDROOT}/usr/include/asm*/io.h \ | |
298 | %{BUILDROOT}/usr/include/asm*/irq.h | |
299 | ||
15a11c5b MT |
300 | # Remove all firmware files which are distributed by linux-firmware |
301 | rm -rfv %{BUILDROOT}/lib/firmware | |
bcf38aec MT |
302 | |
303 | # Install tools. | |
ad855779 | 304 | #%{perf_make} DESTDIR=%{BUILDROOT} install-bin install-python_ext |
6e9df6a3 MT |
305 | |
306 | # cpupower | |
7c69f2c2 MT |
307 | make -C tools/power/cpupower DESTDIR=%{BUILDROOT} libdir=%{libdir} \ |
308 | mandir=%{mandir} CPUFREQ_BENCH=false install | |
309 | ||
7c69f2c2 | 310 | chmod 0755 %{BUILDROOT}%{libdir}/libcpupower.so* |
302e8df8 | 311 | |
302e8df8 MT |
312 | # tmon |
313 | pushd tools/thermal/tmon | |
314 | make INSTALL_ROOT=%{BUILDROOT} install | |
315 | popd | |
802ea3af MT |
316 | end |
317 | end | |
318 | ||
319 | packages | |
bcf38aec | 320 | template KERNEL |
aa3ab846 | 321 | kernel_name = kernel |
bcf38aec MT |
322 | kernel_release = %{fullver} |
323 | ||
324 | summary = The Linux kernel %{kernel_release}. | |
325 | ||
1c9b6c79 | 326 | prerequires |
4c928ab7 | 327 | /sbin/depmod |
1c9b6c79 MT |
328 | end |
329 | ||
330 | provides | |
331 | kernel=%{kernel_release} | |
332 | end | |
333 | ||
802ea3af | 334 | requires |
4c928ab7 MT |
335 | dracut |
336 | grubby | |
802ea3af MT |
337 | linux-firmware |
338 | end | |
ad1ea534 | 339 | |
bcf38aec MT |
340 | files |
341 | /boot/System.map-%{kernel_release} | |
9d4be168 | 342 | /boot/dtb-%{kernel_release} |
bcf38aec MT |
343 | /boot/vmlinuz-%{kernel_release} |
344 | /boot/initramfs-%{kernel_release}.img | |
345 | /etc/ld.so.conf.d/kernel-%{kernel_release}.conf | |
c4ef5c45 | 346 | /usr/lib/modules/%{kernel_release} |
bcf38aec MT |
347 | end |
348 | ||
aa3ab846 | 349 | _posttrans |
c8f9fe35 MT |
350 | /sbin/new-kernel-pkg --package %{kernel_name} --mkinitrd --dracut --depmod --update %{kernel_release} |
351 | /sbin/new-kernel-pkg --package %{kernel_name} --rpmposttrans %{kernel_release} | |
aa3ab846 MT |
352 | end |
353 | ||
ad1ea534 | 354 | script posttransin |
aa3ab846 MT |
355 | %{_posttrans} |
356 | end | |
357 | ||
358 | script posttransup | |
359 | %{_posttrans} | |
360 | end | |
361 | ||
362 | script postin | |
c8f9fe35 | 363 | /sbin/new-kernel-pkg --package %{kernel_name} --install %{kernel_release} |
aa3ab846 MT |
364 | end |
365 | ||
366 | script postup | |
367 | /sbin/new-kernel-pkg --package %{kernel_name} --install %{kernel_release} | |
368 | end | |
369 | ||
370 | script preun | |
371 | /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{kernel_release} | |
bcf38aec MT |
372 | end |
373 | end | |
374 | ||
375 | template KERNELDEVEL | |
376 | kernel_release = %{fullver} | |
377 | ||
378 | summary = Development files of kernel-%{kernel_release}. | |
379 | description | |
380 | %{summary} | |
381 | ||
382 | Install this package in order to compile modules for | |
383 | kernel release %{kernel_release}. | |
384 | end | |
385 | ||
10756fd5 MT |
386 | provides |
387 | kernel-devel = %{thisver} | |
388 | end | |
389 | ||
bcf38aec MT |
390 | filter_requires |
391 | perl>=[0-9]\:.* | |
ad1ea534 MT |
392 | end |
393 | ||
bcf38aec | 394 | files |
c4ef5c45 MT |
395 | /usr/lib/modules/%{kernel_release}/build |
396 | /usr/lib/modules/%{kernel_release}/source | |
bcf38aec | 397 | /usr/src/kernels/%{kernel_release} |
ad1ea534 | 398 | end |
802ea3af | 399 | end |
bcf38aec | 400 | |
45088e83 | 401 | if "%{build_kernel_default}" == "1" |
7f6f4de5 MT |
402 | if "%{DISTRO_ARCH}" == "armv7hl" |
403 | package kernel | |
404 | template KERNEL | |
58dc2060 | 405 | |
7f6f4de5 MT |
406 | kernel_name = kernel |
407 | kernel_release = %{fullver} | |
bcf38aec | 408 | |
0db4b328 MT |
409 | # Replace the Exynos kernel. |
410 | obsoletes += kernel-exynos < %{kernel_release} | |
411 | conflicts += kernel-exynos < %{kernel_release} | |
412 | ||
7f6f4de5 MT |
413 | # Replace the OMAP kernel. |
414 | obsoletes += kernel-omap < %{kernel_release} | |
415 | conflicts += kernel-omap < %{kernel_release} | |
416 | end | |
417 | ||
418 | package kernel-devel | |
419 | template KERNELDEVEL | |
420 | ||
421 | kernel_name = kernel | |
422 | kernel_release = %{fullver} | |
423 | ||
0db4b328 MT |
424 | # Replace the Exynos kernel. |
425 | obsoletes += kernel-exynos-devel < %{kernel_release} | |
426 | conflicts += kernel-exynos-devel < %{kernel_release} | |
427 | ||
7f6f4de5 MT |
428 | # Replace the OMAP kernel. |
429 | obsoletes += kernel-omap-devel < %{kernel_release} | |
430 | conflicts += kernel-omap-devel < %{kernel_release} | |
431 | end | |
58dc2060 | 432 | |
7f6f4de5 MT |
433 | else |
434 | package kernel | |
435 | template KERNEL | |
436 | ||
437 | kernel_name = kernel | |
438 | kernel_release = %{fullver} | |
439 | end | |
440 | ||
441 | package kernel-devel | |
442 | template KERNELDEVEL | |
443 | ||
444 | kernel_name = kernel | |
445 | kernel_release = %{fullver} | |
446 | end | |
45088e83 | 447 | end |
bcf38aec | 448 | end |
81bb0557 | 449 | |
802ea3af | 450 | package kernel-headers |
802ea3af MT |
451 | summary = Header files of the kernel release %{fullver}. |
452 | desciption = %{summary} | |
c698e4be MT |
453 | |
454 | files | |
455 | /usr/include | |
456 | end | |
802ea3af | 457 | end |
bcf38aec | 458 | |
ebeed08a MT |
459 | package kernel-tools |
460 | summary = Assortment of tools for the Linux kernel. | |
461 | description = %{summary} | |
462 | ||
463 | filter_requires | |
464 | perl>=[0-9]\:.* | |
465 | end | |
466 | ||
467 | files | |
468 | / | |
469 | !/boot | |
ebeed08a | 470 | !/usr/include |
c4ef5c45 | 471 | !/usr/lib/modules |
ebeed08a | 472 | !/usr/src |
fe2de317 MT |
473 | !/usr/src/debug |
474 | !/usr/lib/debug | |
ebeed08a MT |
475 | end |
476 | end | |
802ea3af | 477 | end |