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