1 ###############################################################################
2 # IPFire.org - An Open Source Firewall Solution #
3 # Copyright (C) - IPFire Development Team <info@ipfire.org> #
4 ###############################################################################
9 thisapp = linux-%{version}
11 maintainer = Arne Fitzenreiter <arne.fitzenreiter@ipfire.org>
12 groups = System/Kernels
13 url = http://www.kernel.org/
15 summary = The Linux kernel.
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.
24 # Version helper variables.
25 localversion = %{release}.%{DISTRO_DISTTAG}.%{DISTRO_ARCH}
26 fullver = %{version}-%{localversion}
28 source_dl = http://www.kernel.org/pub/linux/kernel/v4.x/
29 sources = %{thisapp}.tar.xz
32 kernel_logo = /usr/share/pixmaps/kernel-logo.ppm
63 # A list of kernels to build.
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=
70 kernel_arch = %{DISTRO_PLATFORM}
71 kernel_target = bzImage
72 kernel_image = arch/%{kernel_arch}/boot/%{kernel_target}
74 if "%{DISTRO_ARCH}" == "x86_64"
75 build_kernel_default = 1
78 if "%{DISTRO_ARCH}" == "aarch64"
79 build_kernel_default = 1
82 kernel_target = Image.gz
85 if "%{DISTRO_ARCH}" == "armv7hl"
86 # Build the default unified kernel.
87 build_kernel_default = 1
89 kernel_target = zImage
92 # mkimage is a requirement to build uImage images.
93 if "%{kernel_target}" == "uImage"
94 requires += u-boot-tools
97 # Build default kernel.
98 if "%{build_kernel_default}" == "1"
102 perf_make = make %{MAKETUNING} -C tools/perf V=1 WERROR=0 \
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
107 # Disable the colorize plugin.
108 # It's generally very nice but it clutters our
110 sed -e "/^COLORIZE_PLUGIN_CFLAGS/d" \
113 sed -e "s/^HOSTCFLAGS.*=.*/& -fPIC/g" -i Makefile
115 cp -vf %{kernel_logo} \
116 drivers/video/logo/logo_linux_clut224.ppm
118 # Get rid of unwanted files resulting from patch fuzz.
119 find . \( -name "*.orig" -o -name "*~" \) -exec rm -f {} \; >/dev/null
121 # Remove unnecessary SCM files.
122 find . -name .gitignore -exec rm -f {} \; >/dev/null
124 # This prevents scripts/setlocalversion from mucking with our version numbers.
133 if [ "${flavour}" != "default" ]; then
137 scripts/configure --kernel-dir=%{DIR_APP} \
138 merge %{DISTRO_ARCH} ${flavour} %{DIR_APP}/configs/config.${flavour}
141 # Generate configuration files for all kernels we are going to
143 for kernel in %{kernels}; do
144 configure_kernel ${kernel}
148 # Prevent perf from installing any files in /usr/libexec
149 sed -i %{DIR_APP}/tools/perf/config/Makefile -e "s/libexec/lib/g"
156 local localversion="%{localversion}"
157 local fullversion="%{fullver}"
158 if [ "${flavour}" != "default" ]; then
160 localversion="${localversion}.${flavour}"
161 fullversion="${fullversion}.${flavour}"
166 -e "s/^EXTRAVERSION.*/EXTRAVERSION = -${localversion}/"
168 # Clean up the source tree.
171 # Install configuration file.
172 cp configs/config.${flavour} .config
176 make ARCH=%{kernel_arch} oldnoconfig >/dev/null
177 make ARCH=%{kernel_arch} CC="gcc -fno-PIE" %{kernel_target} modules \
178 %{kernel_build_flags} %{PARALLELISMFLAGS}
180 # Compile Flattened Device Tree database
181 case "${DISTRO_ARCH}" in
183 make ARCH=%{kernel_arch} dtbs
185 mkdir -pv %{BUILDROOT}/boot/dtb-${fullversion}
186 for file in arch/arm/boot/dts/*.dtb; do
187 [ -e "${file}" ] || continue
189 install -m 644 ${file} %{BUILDROOT}/boot/dtb-${fullversion} || exit 1
195 # Install the results.
196 mkdir -pv %{BUILDROOT}/boot %{BUILDROOT}/usr/lib/modules/${fullversion}
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}
201 # Create empty initramfs (20M).
202 dd if=/dev/zero of=%{BUILDROOT}/boot/initramfs-${fullversion}.img bs=1M count=20
205 make ARCH=%{kernel_arch} INSTALL_MOD_PATH=%{BUILDROOT}/usr mod-fw= V=1 \
206 KERNELRELEASE=${fullversion} modules_install
208 # Create an empty settings file for dracut
209 mkdir -p %{BUILDROOT}/etc/ld.so.conf.d
210 echo "# Placeholder file, no vDSO hwcap entries used in this kernel." \
211 > %{BUILDROOT}/etc/ld.so.conf.d/kernel-${fullversion}.conf
213 # And now the scary looking part.
215 # Recreate source and build links.
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
220 # Create dirs for extra modules.
221 mkdir -p %{BUILDROOT}/usr/lib/modules/${fullversion}/extra
223 cp --parents $(find -type f -name "Makefile*" -o -name "Kconfig*") \
224 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
225 cp Module.symvers System.map \
226 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
227 rm -rf %{BUILDROOT}/usr/lib/modules/${fullversion}/build/{Documentation,scripts,include}
229 cp .config %{BUILDROOT}/usr/lib/modules/${fullversion}/build
230 cp -a scripts %{BUILDROOT}/usr/lib/modules/${fullversion}/build
231 find %{BUILDROOT}/usr/lib/modules/${fullversion}/build/scripts -name "*.o" \
234 cp -a --parents arch/%{kernel_arch}/include \
235 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
236 cp -a include %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include
238 # Make sure we can build external modules.
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
243 cp %{BUILDROOT}/usr/lib/modules/${fullversion}/build/.config \
244 %{BUILDROOT}/usr/lib/modules/${fullversion}/build/include/config/auto.conf
246 find %{BUILDROOT}/usr/lib/modules/${fullversion} -name "*.ko" -type f | \
247 xargs --no-run-if-empty chmod u+x
249 # Move all development files to /usr/src.
250 mkdir -p %{BUILDROOT}/usr/src/kernels
251 mv %{BUILDROOT}/usr/lib/modules/${fullversion}/build \
252 %{BUILDROOT}/usr/src/kernels/${fullversion}
253 ln -sf ../../../src/kernels/${fullversion} \
254 %{BUILDROOT}/usr/lib/modules/${fullversion}/build
257 find %{BUILDROOT}/usr/src/kernels -name "modules.order" \
258 -exec chmod 644 {} \;
260 find %{BUILDROOT}/usr/src/kernels -name ".*.cmd" -exec rm -f {} \;
263 for kernel in %{kernels}; do
264 build_kernel ${kernel}
269 %{perf_make} DESTDIR=%{BUILDROOT} all
272 chmod +x tools/power/cpupower/utils/version-gen.sh
273 make -C tools/power/cpupower CPUFREQ_BENCH=false %{PARALLELISMFLAGS}
275 if [ "%{DISTRO_ARCH}" = "x86_64" ]; then
276 pushd tools/power/cpupower/debug/x86_64
277 make %{MAKETUNING} centrino-decode powernow-k8-decode
280 pushd tools/power/x86/x86_energy_perf_policy
284 pushd tools/power/x86/turbostat
289 pushd tools/thermal/tmon
295 # When no kernels are configured, we create a default config
296 # which enables us to install at least the header files.
297 [ -n "%{kernels}" ] || make ARCH=%{kernel_arch} defconfig
299 # Install the header files
300 make ARCH=%{kernel_arch} INSTALL_HDR_PATH=dest headers_install
301 mkdir -pv %{BUILDROOT}/usr/include
302 find dest/include \( -name .install -o -name ..install.cmd \) -delete
303 cp -rv dest/include/* %{BUILDROOT}/usr/include
305 # Glibc provides these headers
306 rm -rfv %{BUILDROOT}/usr/include/scsi \
307 %{BUILDROOT}/usr/include/asm*/atomic.h \
308 %{BUILDROOT}/usr/include/asm*/io.h \
309 %{BUILDROOT}/usr/include/asm*/irq.h
311 # Remove all firmware files which are distributed by linux-firmware
312 rm -rfv %{BUILDROOT}/lib/firmware
315 %{perf_make} DESTDIR=%{BUILDROOT} install-bin install-python_ext
318 make -C tools/power/cpupower DESTDIR=%{BUILDROOT} libdir=%{libdir} \
319 mandir=%{mandir} CPUFREQ_BENCH=false install
321 if [ "%{DISTRO_ARCH}" = "x86_64" ]; then
322 pushd tools/power/cpupower/debug/x86_64
323 install -m 755 centrino-decode \
324 %{BUILDROOT}/usr/bin/centrino-decode
325 install -m 755 powernow-k8-decode \
326 %{BUILDROOT}/usr/bin/powernow-k8-decode
330 chmod 0755 %{BUILDROOT}%{libdir}/libcpupower.so*
332 # This should be built for all x86 architectures
333 if [ "%{DISTRO_ARCH}" = "x86_64" ]; then
334 mkdir -pv %{BUILDROOT}%{mandir}/man8
336 pushd tools/power/x86/x86_energy_perf_policy
337 make DESTDIR=%{BUILDROOT} install
340 pushd tools/power/x86/turbostat
341 make DESTDIR=%{BUILDROOT} install
346 pushd tools/thermal/tmon
347 make INSTALL_ROOT=%{BUILDROOT} install
355 kernel_release = %{fullver}
357 summary = The Linux kernel %{kernel_release}.
364 kernel=%{kernel_release}
374 /boot/System.map-%{kernel_release}
375 /boot/dtb-%{kernel_release}
376 /boot/vmlinuz-%{kernel_release}
377 /boot/initramfs-%{kernel_release}.img
378 /etc/ld.so.conf.d/kernel-%{kernel_release}.conf
379 /usr/lib/modules/%{kernel_release}
383 /sbin/new-kernel-pkg --package %{kernel_name} --mkinitrd --dracut --depmod --update %{kernel_release}
384 /sbin/new-kernel-pkg --package %{kernel_name} --rpmposttrans %{kernel_release}
396 /sbin/new-kernel-pkg --package %{kernel_name} --install %{kernel_release}
400 /sbin/new-kernel-pkg --package %{kernel_name} --install %{kernel_release}
404 /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{kernel_release}
409 kernel_release = %{fullver}
411 summary = Development files of kernel-%{kernel_release}.
415 Install this package in order to compile modules for
416 kernel release %{kernel_release}.
420 kernel-devel = %{thisver}
428 /usr/lib/modules/%{kernel_release}/build
429 /usr/lib/modules/%{kernel_release}/source
430 /usr/src/kernels/%{kernel_release}
434 if "%{build_kernel_default}" == "1"
435 if "%{DISTRO_ARCH}" == "armv7hl"
440 kernel_release = %{fullver}
442 # Replace the Exynos kernel.
443 obsoletes += kernel-exynos < %{kernel_release}
444 conflicts += kernel-exynos < %{kernel_release}
446 # Replace the OMAP kernel.
447 obsoletes += kernel-omap < %{kernel_release}
448 conflicts += kernel-omap < %{kernel_release}
455 kernel_release = %{fullver}
457 # Replace the Exynos kernel.
458 obsoletes += kernel-exynos-devel < %{kernel_release}
459 conflicts += kernel-exynos-devel < %{kernel_release}
461 # Replace the OMAP kernel.
462 obsoletes += kernel-omap-devel < %{kernel_release}
463 conflicts += kernel-omap-devel < %{kernel_release}
471 kernel_release = %{fullver}
478 kernel_release = %{fullver}
483 package kernel-headers
484 summary = Header files of the kernel release %{fullver}.
485 desciption = %{summary}
493 summary = Assortment of tools for the Linux kernel.
494 description = %{summary}