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