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