]> git.ipfire.org Git - people/pmueller/ipfire-3.x.git/blame - kernel/kernel.nm
kernel: Enable cgroup memory controller
[people/pmueller/ipfire-3.x.git] / kernel / kernel.nm
CommitLineData
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 6name = kernel
bbc2926a 7version = 6.5.3
6445c5f1 8release = 5
15a11c5b 9thisapp = linux-%{version}
166a6c21 10
81bb0557 11maintainer = Arne Fitzenreiter <arne.fitzenreiter@ipfire.org>
802ea3af 12groups = System/Kernels
ee731e2d 13url = https://www.kernel.org/
802ea3af
MT
14license = GPLv2
15summary = The Linux kernel.
166a6c21 16
802ea3af 17description
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 22end
166a6c21 23
802ea3af 24# Version helper variables.
bcf38aec
MT
25localversion = %{release}.%{DISTRO_DISTTAG}.%{DISTRO_ARCH}
26fullver = %{version}-%{localversion}
802ea3af 27
d8d7d102 28source_dl = https://www.kernel.org/pub/linux/kernel/v6.x/
fe014038 29sources = %{thisapp}.tar.xz
802ea3af
MT
30
31build
32 requires
662414a4 33 asciidoc
7f6f4de5 34 bc
849a0073 35 binutils >= 2.25
bcf38aec 36 binutils-devel
c6e2a6c8 37 bison
bcf38aec 38 elfutils-devel
c6e2a6c8 39 flex
0f52a9b7 40 gcc >= 8
fe2de317 41 gcc-plugin-devel
6e9df6a3 42 gettext
849a0073 43 hostname
81bb0557 44 libunwind-devel
802ea3af 45 ncurses-devel
7c69f2c2 46 newt-devel
04859b28 47 openssl
6dce0e4c 48 /usr/bin/openssl
7c69f2c2 49 pciutils-devel
802ea3af 50 perl
d69f4f23 51 python3-devel
1b1a9c16 52 rsync
849a0073 53 openssl-devel
7c69f2c2 54 slang-devel
662414a4 55 xmlto
bf6ee3f7 56 xz
a3776d8a 57 zstd
4c928ab7
MT
58
59 /sbin/depmod
bcf38aec
MT
60 end
61
34520606 62 kernel_arch = %{DISTRO_PLATFORM}
45088e83 63 kernel_target = bzImage
967da24b
MT
64 kernel_image = arch/%{kernel_arch}/boot/%{kernel_target}
65
d5383c43 66 if "%{DISTRO_ARCH}" == "aarch64"
d5383c43
MT
67 kernel_arch = arm64
68 kernel_target = Image.gz
69 end
70
802ea3af 71 prepare_cmds
5e856224
MT
72 # Disable the colorize plugin.
73 # It's generally very nice but it clutters our
74 # logfiles.
75 sed -e "/^COLORIZE_PLUGIN_CFLAGS/d" \
76 -i Makefile
77
93e1e527
SS
78 # Use our linker flags while building the compiler plugins.
79 sed -i '/^plugin_ldflags\s\+=/ s/$/ %{LDFLAGS}/' \
80 scripts/gcc-plugins/Makefile
802ea3af 81
689ec88b
MT
82 # Remove Python 2 interpreter from a few scripts
83 sed -e "s@^#!.*python@#!%{python3}@" \
84 -i scripts/show_delta \
85 -i scripts/tracing/draw_functrace.py
86
bcf38aec
MT
87 # Get rid of unwanted files resulting from patch fuzz.
88 find . \( -name "*.orig" -o -name "*~" \) -exec rm -f {} \; >/dev/null
89
90 # Remove unnecessary SCM files.
91 find . -name .gitignore -exec rm -f {} \; >/dev/null
92
ebeed08a
MT
93 # This prevents scripts/setlocalversion from mucking with our version numbers.
94 touch .scmversion
95
bcf38aec 96 mkdir -pv configs
4c928ab7
MT
97
98 cd %{DIR_SOURCE}
bcf38aec
MT
99 configure_kernel() {
100 local flavour=${1}
101 local suffix
f05d9a85 102 if [ "${flavour}" != "generic" ]; then
bcf38aec
MT
103 suffix="-${flavour}"
104 fi
105
d8d7d102 106 bash scripts/configure --kernel-dir=%{DIR_APP} \
4c928ab7 107 merge %{DISTRO_ARCH} ${flavour} %{DIR_APP}/configs/config.${flavour}
bcf38aec
MT
108 }
109
110 # Generate configuration files for all kernels we are going to
111 # build.
f05d9a85 112 configure_kernel "generic"
802ea3af
MT
113 end
114
115 build
bcf38aec
MT
116 build_kernel() {
117 local flavour=${1}
118 local suffix
119 local localversion="%{localversion}"
120 local fullversion="%{fullver}"
f05d9a85 121 if [ "${flavour}" != "generic" ]; then
bcf38aec
MT
122 suffix="-${flavour}"
123 localversion="${localversion}.${flavour}"
124 fullversion="${fullversion}.${flavour}"
125 fi
802ea3af 126
ebeed08a
MT
127 # Label the build.
128 sed -i Makefile \
129 -e "s/^EXTRAVERSION.*/EXTRAVERSION = -${localversion}/"
130
bcf38aec
MT
131 # Clean up the source tree.
132 make mrproper
802ea3af 133
bcf38aec
MT
134 # Install configuration file.
135 cp configs/config.${flavour} .config
c6e2a6c8 136 cat .config
802ea3af 137
bcf38aec 138 # Run the build.
636e102c
SS
139 make ARCH=%{kernel_arch} HOSTCFLAGS="%{CFLAGS}" \
140 HOSTLDFLAGS="%{LDFLAGS}" olddefconfig >/dev/null
141
65c2deba 142 make ARCH=%{kernel_arch} %{kernel_target} modules \
636e102c
SS
143 KERNELRELEASE=${fullversion} HOSTCFLAGS="%{CFLAGS}" \
144 HOSTLDFLAGS="%{LDFLAGS}" %{PARALLELISMFLAGS}
bcf38aec 145
9d4be168
MT
146 # Compile Flattened Device Tree database
147 case "${DISTRO_ARCH}" in
d8d7d102 148 aarch64)
9d4be168
MT
149 make ARCH=%{kernel_arch} dtbs
150
151 mkdir -pv %{BUILDROOT}/boot/dtb-${fullversion}
152 for file in arch/arm/boot/dts/*.dtb; do
153 [ -e "${file}" ] || continue
154
155 install -m 644 ${file} %{BUILDROOT}/boot/dtb-${fullversion} || exit 1
156 rm -f ${file}
157 done
158 ;;
159 esac
160
bcf38aec 161 # Install the results.
c4ef5c45 162 mkdir -pv %{BUILDROOT}/boot %{BUILDROOT}/usr/lib/modules/${fullversion}
bcf38aec
MT
163 install -m 755 %{kernel_image} %{BUILDROOT}/boot/vmlinuz-${fullversion}
164 install -m 644 .config %{BUILDROOT}/boot/config-${fullversion}
165 install -m 644 System.map %{BUILDROOT}/boot/System.map-${fullversion}
166
bbc2926a
AF
167 # Create empty initramfs (70M).
168 dd if=/dev/zero of=%{BUILDROOT}/boot/initramfs-${fullversion}.img bs=1M count=70
bcf38aec
MT
169
170 # Install modules.
81bb0557 171 make ARCH=%{kernel_arch} INSTALL_MOD_PATH=%{BUILDROOT}/usr mod-fw= V=1 \
bcf38aec 172 KERNELRELEASE=${fullversion} modules_install
c8f122e5 173
bcf38aec
MT
174 # And now the scary looking part.
175 #
176 # Recreate source and build links.
7c69f2c2
MT
177 rm -f %{BUILDROOT}/usr/lib/modules/${fullversion}/{build,source}
178 mkdir -p %{BUILDROOT}/usr/lib/modules/${fullversion}/build
179 ln -sf build %{BUILDROOT}/usr/lib/modules/${fullversion}/source
802ea3af 180
bcf38aec 181 # Create dirs for extra modules.
7c69f2c2 182 mkdir -p %{BUILDROOT}/usr/lib/modules/${fullversion}/extra
802ea3af 183
7c69f2c2 184 cp --parents $(find -type f -name "Makefile*" -o -name "Kconfig*") \
c4ef5c45 185 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
7c69f2c2 186 cp Module.symvers System.map \
c4ef5c45 187 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
7c69f2c2 188 rm -rf %{BUILDROOT}/usr/lib/modules/${fullversion}/build/{Documentation,scripts,include}
bcf38aec 189
7c69f2c2
MT
190 cp .config %{BUILDROOT}/usr/lib/modules/${fullversion}/build
191 cp -a scripts %{BUILDROOT}/usr/lib/modules/${fullversion}/build
c4ef5c45 192 find %{BUILDROOT}/usr/lib/modules/${fullversion}/build/scripts -name "*.o" \
bcf38aec
MT
193 -exec rm -vf {} \;
194
7c69f2c2 195 cp -a --parents arch/%{kernel_arch}/include \
c4ef5c45 196 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
7c69f2c2 197 cp -a include %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include
bcf38aec
MT
198
199 # Make sure we can build external modules.
c4ef5c45
MT
200 touch -r %{BUILDROOT}/usr/lib/modules/${fullversion}/build/Makefile \
201 %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include/linux/version.h
202 touch -r %{BUILDROOT}/usr/lib/modules/${fullversion}/build/.config \
203 %{BUILDROOT}/usr/lib/modules/${fullversion}/build/autoconf.h
7c69f2c2 204 cp %{BUILDROOT}/usr/lib/modules/${fullversion}/build/.config \
c4ef5c45
MT
205 %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include/config/auto.conf
206
207 find %{BUILDROOT}/usr/lib/modules/${fullversion} -name "*.ko" -type f | \
bf6ee3f7 208 xargs --no-run-if-empty chmod u+x
bcf38aec 209
bcf38aec 210 # Move all development files to /usr/src.
7c69f2c2
MT
211 mkdir -p %{BUILDROOT}/usr/src/kernels
212 mv %{BUILDROOT}/usr/lib/modules/${fullversion}/build \
bcf38aec 213 %{BUILDROOT}/usr/src/kernels/${fullversion}
7c69f2c2 214 ln -sf ../../../src/kernels/${fullversion} \
c4ef5c45 215 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
bcf38aec 216
81bb0557
MT
217 # Fix permissions.
218 find %{BUILDROOT}/usr/src/kernels -name "modules.order" \
219 -exec chmod 644 {} \;
220
bcf38aec 221 find %{BUILDROOT}/usr/src/kernels -name ".*.cmd" -exec rm -f {} \;
d27a5bdd
AF
222
223 # remove device tree compiler because there are dead links
224 rm -rf %{BUILDROOT}/usr/src/kernels/*/scripts/dtc
bcf38aec
MT
225 }
226
d8d7d102 227 # Build the kernel
f05d9a85 228 build_kernel "generic"
6e9df6a3 229
6e9df6a3 230 # cpupower
7c69f2c2
MT
231 chmod +x tools/power/cpupower/utils/version-gen.sh
232 make -C tools/power/cpupower CPUFREQ_BENCH=false %{PARALLELISMFLAGS}
233
302e8df8
MT
234 pushd tools/thermal/tmon
235 make
236 popd
bcf38aec
MT
237 end
238
239 install
4c928ab7
MT
240 # When no kernels are configured, we create a default config
241 # which enables us to install at least the header files.
242 [ -n "%{kernels}" ] || make ARCH=%{kernel_arch} defconfig
243
802ea3af 244 # Install the header files
c8f122e5 245 make ARCH=%{kernel_arch} INSTALL_HDR_PATH=dest headers_install
802ea3af
MT
246 mkdir -pv %{BUILDROOT}/usr/include
247 find dest/include \( -name .install -o -name ..install.cmd \) -delete
248 cp -rv dest/include/* %{BUILDROOT}/usr/include
249
250 # Glibc provides these headers
251 rm -rfv %{BUILDROOT}/usr/include/scsi \
252 %{BUILDROOT}/usr/include/asm*/atomic.h \
253 %{BUILDROOT}/usr/include/asm*/io.h \
254 %{BUILDROOT}/usr/include/asm*/irq.h
255
15a11c5b
MT
256 # Remove all firmware files which are distributed by linux-firmware
257 rm -rfv %{BUILDROOT}/lib/firmware
bcf38aec
MT
258
259 # Install tools.
6e9df6a3 260 # cpupower
7c69f2c2
MT
261 make -C tools/power/cpupower DESTDIR=%{BUILDROOT} libdir=%{libdir} \
262 mandir=%{mandir} CPUFREQ_BENCH=false install
263
7c69f2c2 264 chmod 0755 %{BUILDROOT}%{libdir}/libcpupower.so*
302e8df8 265
302e8df8
MT
266 # tmon
267 pushd tools/thermal/tmon
268 make INSTALL_ROOT=%{BUILDROOT} install
269 popd
802ea3af
MT
270 end
271end
272
273packages
d8d7d102
MT
274 package kernel-tools
275 summary = Assortment of tools for the Linux kernel.
276 description = %{summary}
bcf38aec 277
d8d7d102
MT
278 filter_requires
279 perl>=[0-9]\:.*
280 end
281 end
282
6dce0e4c
MT
283 package kernel-tools-debuginfo
284 template DEBUGINFO
285 end
286
d8d7d102
MT
287 package kernel
288 summary = The Linux kernel %{fullver}
bcf38aec 289
1c9b6c79 290 prerequires
4c928ab7 291 /sbin/depmod
1c9b6c79
MT
292 end
293
294 provides
d8d7d102 295 kernel = %{fullver}
98a495db
MT
296
297 # Used to lock the running kernel from being uninstalled
298 kernel(%{fullver})
1c9b6c79
MT
299 end
300
802ea3af 301 requires
4c928ab7 302 dracut
868edea1 303 kernel-updater
802ea3af 304 linux-firmware
c5123727 305 wireless-regdb
57fb3e8c
MT
306
307 # Install intel-microcode only on x86_64
308 (intel-microcode if arch(x86_64))
802ea3af 309 end
ad1ea534 310
bcf38aec 311 files
d8d7d102
MT
312 /boot/System.map-%{fullver}
313 /boot/dtb-%{fullver}
314 /boot/vmlinuz-%{fullver}
315 /boot/initramfs-%{fullver}.img
316 /usr/lib/modules/%{fullver}
bcf38aec
MT
317 end
318
aa3ab846 319 _posttrans
d8d7d102 320 kernel-updater install %{fullver}
aa3ab846
MT
321 end
322
ad1ea534 323 script posttransin
aa3ab846
MT
324 %{_posttrans}
325 end
326
327 script posttransup
328 %{_posttrans}
329 end
330
868edea1 331 script postun
d8d7d102 332 kernel-updater uninstall %{fullver}
bcf38aec
MT
333 end
334 end
335
d8d7d102
MT
336 package kernel-devel
337 summary = Development files of kernel-%{fullver}
bcf38aec
MT
338 description
339 %{summary}
340
341 Install this package in order to compile modules for
d8d7d102 342 kernel release %{fullver}.
bcf38aec
MT
343 end
344
10756fd5
MT
345 provides
346 kernel-devel = %{thisver}
347 end
348
98a495db
MT
349 requires
350 kernel = %{thisver}
351 end
352
bcf38aec
MT
353 filter_requires
354 perl>=[0-9]\:.*
ad1ea534
MT
355 end
356
bcf38aec 357 files
d8d7d102
MT
358 /usr/lib/modules/%{fullver}/build
359 /usr/lib/modules/%{fullver}/source
360 /usr/src/kernels/%{fullver}
45088e83 361 end
bcf38aec 362 end
81bb0557 363
802ea3af 364 package kernel-headers
d8d7d102 365 summary = Header files of the kernel release %{fullver}
802ea3af 366 desciption = %{summary}
c698e4be
MT
367
368 files
369 /usr/include
370 end
802ea3af 371 end
802ea3af 372end