代码拉取完成,页面将自动刷新
同步操作将从 OpenCloudOS Stream/kernel 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# A simplified kernel spec initially based on Tencent Linux Kernels and Fedora/CentOS
#
# By changing a few rpm macros, it's very convenient to build for different archs or
# kernel config styles, and build different components.
### Kenrel version relation macros
# Following variables filled by automation scripts:
# %%{kernel_majver}: Kernel RPM package version, eg. 5.15.0, 5.15.3, 5.16.0
# %%{kernel_relver}: Kernel RPM package release, eg. 2207.1, 0.20211115git1135ec008ef3.rc0.2207, 0009.11
# %%{kernel_variant}: Kernel RPM package release, eg. 2207.1, 0.20211115git1135ec008ef3.rc0.2207, 0009.11
# %%{kernel_unamer_base}: base part of `uname -r` output, used to generate %%kernel_unamer, needed by scriptlets so prepare it early. eg. 5.18.19-2207.2.1.tks, 5.18.19-2207.2.1.tks+debug, 5.4.119-1-0009.1
# %%{kernel_unamer_force}: force use a unamer, usually for historical reason.
# %%{rpm_name}: Kernel RPM package name, eg. kernel, kernel-tlinux4, kernel-stream kernel-stream-debug
# %%{rpm_vendor}: RPM package vendor
# %%{rpm_url}: RPM url
# TODO: kernel_unamer don't have distro mark
%define kernel_majver 6.6.6
%define kernel_relver 2401.0.1
%define kernel_variant %{nil}
%define kernel_unamer_base 6.6.6-2401.0.1.3
%define kernel_unamer_force %{nil}
%define rpm_name kernel
%define rpm_vendor OpenCloudOS
%define rpm_url https://github.com/OpenCloudOS/OpenCloudOS-Kernel-Stream
%if "%{kernel_unamer_force}" == ""
%define kernel_unamer %{kernel_unamer_base}%{?dist}.%{_target_cpu}%{kernel_variant}
%else
%define kernel_unamer %{kernel_unamer_force}
%endif
# TODO: We have a fixed tar name, might be better to include KDIST in tarname
%define kernel_tarname kernel-%{kernel_majver}-%{kernel_relver}
# This section defines following value:
# %%{kernel_arch}
# Since kernel arch name differs from many other definations, this will insert a script snip
# to handle the convertion, and error out on unsupported arch.
ExclusiveArch: x86_64 aarch64 riscv64
%ifarch x86_64
%define kernel_arch x86_64
%endif
%ifarch aarch64
%define kernel_arch arm64
%endif
%ifarch riscv64
%define kernel_arch riscv
%endif
# TODO: This is a workaround for kernel userspace tools (eg. perf), which doesn't
# support LTO, and causes FTBFS, need to remove this after LTO is available in
# upstream
%global _lto_cflags %{nil}
###### Kernel packaging options #################################################
# Since we need to generate kernel, kernel-subpackages, perf, bpftools, from
# this one single code tree, following build switches are very helpful.
#
# The following build options can be enabled or disabled with --with/--without
# in the rpmbuild command. But may by disabled by later checks#
#
# This section defines following options:
# with_core: kernel core pkg
# with_doc: kernel doc pkg
# with_headers: kernel headers pkg
# with_perf: perf tools pkg
# with_tools: kernel tools pkg
# with_bpftool: bpftool pkg
# with_debuginfo: debuginfo for all packages
# with_modsign: if mod should be signed
# with_kabichk: if kabi check is needed at the end of build
# with_keypkg: package the signing key for user, CAUTION: this package allows
# users to be able to sign their modules using kernel trusted key.
# === Package options ===
# Eanbled by default: core doc headers perf tools bpftool debuginfo modsign traceevent_dyn
# Disabled by default: kabichk keypkg
%define with_core %{?_without_core:0}%{?!_without_core:1}
%define with_doc %{?_without_doc:0}%{?!_without_doc:1}
%define with_headers %{?_without_headers:0}%{?!_without_headers:1}
%define with_perf %{?_without_perf:0}%{?!_without_perf:1}
%define with_tools %{?_without_tools:0}%{?!_without_tools:1}
%define with_bpftool %{?_without_bpftool:0}%{?!_without_bpftool:1}
%define with_debuginfo %{?_without_debuginfo:0}%{?!_without_debuginfo:1}
%define with_modsign %{?_without_modsign:0}%{?!_without_modsign:1}
%define with_kabichk %{?_with_kabichk:1}%{?!_with_kabichk:0}
%define with_keypkg %{?_with_keypkg:1}%{?!_with_keypkg:0}
# Only use with cross build, don't touch it unless you know what you are doing
%define with_crossbuild %{?_with_crossbuild: 1} %{?!_with_crossbuild: 0}
###### Kernel signing params #################################################
### TODO: Currently only module signing, no secureboot
# module-keygen
# Should be an executable accepting two params:
# module-keygen <kernel ver> <kernel objdir>
# <kernel ver>: Kernel's version-release, `uname -r` output of that kernel
# <kernel objdir>: Kernel build dir, where built kernel objs, certs, and vmlinux is stored
#
# This executable should provide required keys for signing, or at least disable builtin keygen
%define use_builtin_module_keygen %{?_module_keygen: 0} %{?!_module_keygen: 1}
# module-signer
# Should be an executable accepting three params:
# module-signer <buildroot> <kernel ver> <kernel objdir>
# <kernel ver>: Kernel's version-release, `uname -r` output of that kernel
# <kernel objdir>: Kernel build dir, where built kernel objs, certs, and vmlinux is stored
# <buildroot>: RPM's buildroot, where kernel modules are installed into
#
# This executable should sign all kernel modules in <builddir>/lib/modules/<kernel ver>
# based on the info gatherable from <kernel objdir>.
%define use_builtin_module_signer %{?_module_signer: 0} %{?!_module_signer: 1}
###### Required RPM macros #####################################################
### Debuginfo handling
# Following macros controls RPM's builtin debuginfo extracting behaviour,
# tune it into a kernel friendly style.
#
# Kernel package needs its own method to pack the debuginfo files.
# This disables RPM's built-in debuginfo files packaging, we package
# debuginfo files manually use find-debuginfo.sh.
%undefine _debuginfo_subpackages
# This disables RH vendor macro's debuginfo package template generation.
# It only generates debuginfo for the main package, but we only want debuginfo
# for subpackages so disable it and do things manually.
%undefine _enable_debug_packages
# This disable find-debuginfo.sh from appending minimal debuginfo
# to every binary.
%undefine _include_minidebuginfo
# This disables debugsource package which collect source files for debug info,
# we pack the kernel source code manually.
%undefine _debugsource_packages
# TODO: This prevents find-debuginfo.sh from adding unique suffix to .ko.debug files
# that will make .ko.debug file names unrecognizable by `crash`
# We may patch `crash` to fix that or find a better way, since this stops the unique
# debug file renaming for userspace packages too.
%undefine _unique_debug_names
# Pass --reloc-debug-sections to eu-strip, .ko files are ET_REL files. So they have relocation
# sections for debug sections. Those sections will not be relinked. This help create .debug files
# that has cross debug section relocations resolved.
%global _find_debuginfo_opts -r
%global debuginfo_dir /usr/lib/debug
###### Build time config #######################################################
# Disable kernel building for non-supported arch, allow building userspace package
%ifarch %nobuildarches noarch
%global with_core 0
%endif
# Require cross compiler if cross compiling
%if %{with_crossbuild}
BuildRequires: binutils-%{_build_arch}-linux-gnu, gcc-%{_build_arch}-linux-gnu
%global with_perf 0
%global with_tools 0
%global with_bpftool 0
%global _cross_compile %{!?_cross_compile:%{_build_arch}-linux-gnu-}%{?_cross_compile:%{_cross_compile}}
%endif
# List the packages used during the kernel build
BuildRequires: kmod, patch, bash, coreutils, tar, git-core, which, gawk
BuildRequires: make, gcc, binutils, system-rpm-config, hmaccalc, bison, flex, gcc-c++
BuildRequires: bzip2, xz, findutils, gzip, perl-interpreter, perl-Carp, perl-devel
BuildRequires: net-tools, hostname, bc
BuildRequires: dwarves
BuildRequires: openssl-devel, elfutils-devel
# Required by multiple kernel tools
BuildRequires: python3-devel, python3-setuptools
BuildRequires: openssl
BuildRequires: gcc-plugin-devel
# glibc-static is required for a consistent build environment (specifically
# CONFIG_CC_CAN_LINK_STATIC=y).
BuildRequires: glibc-static
%if %{with_perf}
BuildRequires: zlib-devel binutils-devel newt-devel perl(ExtUtils::Embed) bison flex xz-devel
BuildRequires: audit-libs-devel
BuildRequires: java-devel
BuildRequires: libbabeltrace-devel
BuildRequires: libtraceevent-devel
%ifnarch aarch64
BuildRequires: numactl-devel
%endif
%endif
%if %{with_tools}
BuildRequires: gettext ncurses-devel
BuildRequires: pciutils-devel libcap-devel libnl3-devel
%endif
%if %{with_doc}
BuildRequires: xmlto, asciidoc
%endif
%if %{with_bpftool}
BuildRequires: llvm
# We don't care about this utils's python version, since we only want rst2* commands during build time
BuildRequires: /usr/bin/rst2man
BuildRequires: zlib-devel binutils-devel
%endif
%if %{with_headers}
BuildRequires: rsync
%endif
###### Kernel packages sources #################################################
### Kernel tarball
Source0: %{kernel_tarname}.tar.gz
### Build time scripts
# Script used to assist kernel building
Source10: filter-modules.sh
Source20: module-signer.sh
Source21: module-keygen.sh
Source30: check-kabi
### Arch speficied kernel configs and kABI
# Start from Source1000 to Source1199, for kernel config
# Start from Source1200 to Source1399, for kabi
Source1000: generic-release.x86_64.config
Source1001: generic-release.aarch64.config
Source1002: generic-release.riscv64.config
Source1200: Module.kabi_x86_64
Source1201: Module.kabi_aarch64
Source1202: Module.kabi_riscv64
### Userspace tools
# Start from Source2000 to Source2999, for userspace tools
Source2000: cpupower.service
Source2001: cpupower.config
###### Kernel package definations ##############################################
### Main meta package
Summary: %{rpm_vendor} Linux kernel meta package
Name: %{rpm_name}
Version: %{kernel_majver}
Release: %{kernel_relver}.3%{?dist}
License: GPLv2
URL: %{rpm_url}
# We can't let RPM do the dependencies automatic because it'll then pick up
# a correct but undesirable perl dependency from the module headers which
# isn't required for the kernel proper to function
AutoReq: no
AutoProv: yes
# Kernel requirements
# installonlypkg(kernel) is a hint for RPM that this package shouldn't be auto-cleaned.
Provides: installonlypkg(kernel)
Provides: kernel = %{version}-%{release}
Provides: %{rpm_name} = %{version}-%{release}
Requires: %{rpm_name}-core = %{version}-%{release}
Requires: %{rpm_name}-modules = %{version}-%{release}
Requires: linux-firmware
%description
This is the meta package of %{?rpm_vendor:%{rpm_vendor} }Linux kernel, the core of operating system.
%if %{with_core}
### Kernel core package
%package core
Summary: %{rpm_vendor} Linux Kernel
Provides: installonlypkg(kernel)
Provides: kernel-core = %{version}-%{release}
Provides: kernel-core-uname-r = %{kernel_unamer}
Provides: kernel-uname-r = %{kernel_unamer}
Requires(pre): coreutils
Requires(post): coreutils kmod dracut
Requires(preun): coreutils kmod
Requires(post): %{_bindir}/kernel-install
Requires(preun): %{_bindir}/kernel-install
# Kernel install hooks & initramfs
%if 0%{?rhel} == 7 || "%{?dist}" == ".tl2"
Requires(post): systemd
Requires(preun): systemd
%else
Requires(post): systemd-udev
Requires(preun): systemd-udev
%endif
%description core
The kernel package contains the %{?rpm_vendor:%{rpm_vendor} } Linux kernel (vmlinuz), the core of
operating system. The kernel handles the basic functions
of the operating system: memory allocation, process allocation, device
input and output, etc.
### Kernel module package
%package modules
Summary: %{rpm_vendor} Kernel modules to match the %{rpm_name}-core kernel
Provides: installonlypkg(kernel-module)
Provides: kernel-modules = %{version}-%{release}
Provides: kernel-modules-extra = %{version}-%{release}
Requires: %{rpm_name}-core = %{version}-%{release}
AutoReq: no
AutoProv: yes
Requires(pre): kmod
Requires(postun): kmod
%description modules
This package provides commonly used kernel modules for the %{?2:%{2}-}core kernel package.
### Kernel devel package
%package devel
Summary: Development package for building kernel modules to match the %{version}-%{release} kernel
Release: %{release}
Provides: installonlypkg(kernel)
Provides: kernel-devel = %{version}-%{release}
Provides: kernel-devel-%{_target_cpu} = %{version}-%{release}
Provides: kernel-devel-uname-r = %{kernel_unamer}
AutoReqprov: no
%description devel
This package provides kernel headers and makefiles sufficient to build modules
against the %{version}-%{release} kernel package.
### Kernel module package
%if %{with_keypkg}
%package signing-keys
Summary: %{rpm_vendor} Kernel signing key
Provides: installonlypkg(kernel)
Requires: %{rpm_name}-core = %{version}-%{release}
AutoReq: no
AutoProv: yes
%description signing-keys
This package provides kernel signing key for the %{?2:%{2}-}core kernel package.
%endif
%if %{with_debuginfo}
### Kernel debuginfo package
%package debuginfo
Summary: Debug information for package %{rpm_name}
Requires: %{rpm_name}-debuginfo-common
Provides: installonlypkg(kernel)
Provides: kernel-debuginfo = %{version}-%{release}
AutoReqProv: no
%description debuginfo
This package provides debug information including
vmlinux, System.map for package %{rpm_name}.
This is required to use SystemTap with %{rpm_name}.
# debuginfo search rule
# If BTF presents, keep it so kernel can use it.
%if 0%{?rhel} != 7
# Old version of find-debuginfo.sh doesn't support this, so only do it for newer version. Old version of eu-strip seems doesn't strip BTF either, so should be fine.
%global _find_debuginfo_opts %{_find_debuginfo_opts} --keep-section '.BTF'
%endif
# Debuginfo file list for main kernel package
# The (\+.*)? is used to match all variant kernel
%global _find_debuginfo_opts %{_find_debuginfo_opts} -p '.*\/usr\/src\/kernels/.*|XXX' -o ignored-debuginfo.list -p $(echo '.*/%{kernel_unamer}/.*|.*/%{kernel_unamer}(\.debug)?' | sed 's/+/[+]/g') -o debuginfo.list
# with_debuginfo
%endif
# with_core
%endif
%if %{with_debuginfo}
### Common debuginfo package
%package debuginfo-common
Summary: Kernel source files used by %{rpm_name}-debuginfo packages
Provides: installonlypkg(kernel)
Provides: kernel-debuginfo-common = %{version}-%{release}
%description debuginfo-common
This package is required by %{rpm_name}-debuginfo subpackages.
It provides the kernel source files common to all builds.
# No need to define extra debuginfo search rule here, use debugfiles.list
# with_debuginfo
%endif
%if %{with_headers}
%package headers
Summary: Header files for the Linux kernel for use by glibc
Obsoletes: glibc-kernheaders < 3.0-46
Provides: glibc-kernheaders = 3.0-46
Provides: kernel-headers = %{version}-%{release}
%description headers
Kernel-headers includes the C header files that specify the interface
between the Linux kernel and userspace libraries and programs. The
header files define structures and constants that are needed for
building most standard programs and are also needed for rebuilding the
glibc package.
# with_headers
%endif
%if %{with_perf}
%package -n perf
Summary: Performance monitoring for the Linux kernel
Requires: bzip2
License: GPLv2
%description -n perf
This package contains the perf tool, which enables performance monitoring
of the Linux kernel.
%package -n perf-debuginfo
Summary: Debug information for package perf
Requires: %{rpm_name}-debuginfo-common = %{version}-%{release}
AutoReqProv: no
%description -n perf-debuginfo
This package provides debug information for the perf package.
# debuginfo search rule
# Note that this pattern only works right to match the .build-id
# symlinks because of the trailing nonmatching alternation and
# the leading .*, because of find-debuginfo.sh's buggy handling
# of matching the pattern against the symlinks file.
%global _find_debuginfo_opts %{_find_debuginfo_opts} -p '.*%{_bindir}/perf(.*\.debug)?|.*%{_libexecdir}/perf-core/.*|.*%{_libdir}/libperf-jvmti.so(.*\.debug)?|.*%{_libdir}/traceevent/(.*\.debug)?|XXX' -o perf-debuginfo.list
%package -n python3-perf
Summary: Python bindings for apps which will manipulate perf events
%description -n python3-perf
The python3-perf package contains a module that permits applications
written in the Python programming language to use the interface
to manipulate perf events.
%package -n python3-perf-debuginfo
Summary: Debug information for package perf python bindings
Requires: %{rpm_name}-debuginfo-common = %{version}-%{release}
AutoReqProv: no
%description -n python3-perf-debuginfo
This package provides debug information for the perf python bindings.
# debuginfo search rule
# the python_sitearch macro should already be defined from above
%global _find_debuginfo_opts %{_find_debuginfo_opts} -p '.*%{python3_sitearch}/perf.*\.so(.*\.debug)?|XXX' -o python3-perf-debuginfo.list
# with_perf
%endif
%if %{with_tools}
%package -n kernel-tools
Summary: Assortment of tools for the Linux kernel
License: GPLv2
%ifarch %{cpupowerarchs}
Provides: cpupowerutils = 1:009-0.6.p1
Obsoletes: cpupowerutils < 1:009-0.6.p1
Provides: cpufreq-utils = 1:009-0.6.p1
Provides: cpufrequtils = 1:009-0.6.p1
Obsoletes: cpufreq-utils < 1:009-0.6.p1
Obsoletes: cpufrequtils < 1:009-0.6.p1
Obsoletes: cpuspeed < 1:1.5-16
Requires: kernel-tools-libs = %{version}-%{release}
%endif
%description -n kernel-tools
This package contains the tools/ directory from the kernel source
and the supporting documentation.
%package -n kernel-tools-libs
Summary: Libraries for the kernels-tools
License: GPLv2
%description -n kernel-tools-libs
This package contains the libraries built from the tools/ directory
from the kernel source.
%package -n kernel-tools-libs-devel
Summary: Assortment of tools for the Linux kernel
License: GPLv2
Requires: kernel-tools = %{version}-%{release}
%ifarch %{cpupowerarchs}
Provides: cpupowerutils-devel = 1:009-0.6.p1
Obsoletes: cpupowerutils-devel < 1:009-0.6.p1
%endif
Requires: kernel-tools-libs = %{version}-%{release}
Provides: kernel-tools-devel
%description -n kernel-tools-libs-devel
This package contains the development files for the tools/ directory from
the kernel source.
%package -n kernel-tools-debuginfo
Summary: Debug information for package kernel-tools
Requires: %{rpm_name}-debuginfo-common = %{version}-%{release}
AutoReqProv: no
%description -n kernel-tools-debuginfo
This package provides debug information for package kernel-tools.
# debuginfo search rule
# Note that this pattern only works right to match the .build-id
# symlinks because of the trailing nonmatching alternation and
# the leading .*, because of find-debuginfo.sh's buggy handling
# of matching the pattern against the symlinks file.
%global _find_debuginfo_opts %{_find_debuginfo_opts} -p '.*%{_bindir}/(cpupower|tmon|gpio-.*|iio_.*|ls.*|centrino-decode|powernow-k8-decode|turbostat|x86_energy_perf_policy|intel-speed-select|page_owner_sort|slabinfo)(.*\.debug)?|.*%{_libdir}/libcpupower.*|XXX' -o kernel-tools-debuginfo.list
# with_tools
%endif
%if %{with_bpftool}
%package -n bpftool
Summary: Inspection and simple manipulation of eBPF programs and maps
License: GPLv2
%description -n bpftool
This package contains the bpftool, which allows inspection and simple
manipulation of eBPF programs and maps.
%package -n bpftool-debuginfo
Summary: Debug information for package bpftool
Requires: %{rpm_name}-debuginfo-common = %{version}-%{release}
AutoReqProv: no
%description -n bpftool-debuginfo
This package provides debug information for the bpftool package.
# debuginfo search rule
%global _find_debuginfo_opts %{_find_debuginfo_opts} -p '.*%{_sbindir}/bpftool(.*\.debug)?|XXX' -o bpftool-debuginfo.list
# with_bpftool
%endif
###### common macros for build and install #####################################
### Signing scripts
# If externel module signer and keygen provided, ignore built-in keygen and
# signer, else use builtin keygen and signer.
%if %{use_builtin_module_signer}
# SOURCE20 is just a wrapper for $BUILD_DIR/scripts/sign-file
%define _module_signer %{SOURCE20}
%endif
%if %{use_builtin_module_keygen}
# SOURCE21 is a dummy file, only perform some checks, we depend on Kbuild for builtin keygen
%define _module_keygen %{SOURCE21}
%endif
### Prepare common build vars to share by %%prep, %%build and %%install section
# _KernSrc: Path to kernel source, located in _buildir
# _KernBuild: Path to the built kernel objects, could be same as $_KernSrc (just like source points to build under /lib/modules/<kver>)
# _KernVmlinuxH: path to vmlinux.h for BTF, located in _buildir
# KernUnameR: Get `uname -r` output of the built kernel
# KernModule: Kernel modules install path, located in %%{buildroot}
# KernDevel: Kernel headers and sources install path, located in %%{buildroot}
%global prepare_buildvar \
cd %{kernel_tarname} \
_KernSrc=%{_builddir}/%{rpm_name}-%{kernel_unamer}/%{kernel_tarname} \
_KernBuild=%{_builddir}/%{rpm_name}-%{kernel_unamer}/%{kernel_unamer}-obj \
_KernVmlinuxH=%{_builddir}/%{rpm_name}-%{kernel_unamer}/vmlinux.h \
KernUnameR=%{kernel_unamer} \
KernModule=%{buildroot}/lib/modules/%{kernel_unamer} \
KernDevel=%{buildroot}/usr/src/kernels/%{kernel_unamer} \
###### Rpmbuild Prep Stage #####################################################
%prep
%setup -q -c -n %{rpm_name}-%{kernel_unamer}
%{prepare_buildvar}
# TODO: Apply test patch here
:
# Mangle /usr/bin/python shebangs to /usr/bin/python3
# Mangle all Python shebangs to be Python 3 explicitly
# -p preserves timestamps
# -n prevents creating ~backup files
# -i specifies the interpreter for the shebang
# This fixes errors such as
# *** ERROR: ambiguous python shebang in /usr/bin/kvm_stat: #!/usr/bin/python. Change it to python3 (or python2) explicitly.
# We patch all sources below for which we got a report/error.
find scripts/ tools/ Documentation/ \
-type f -and \( \
-name "*.py" -or \( -not -name "*.*" -exec grep -Iq '^#!.*python' {} \; \) \
\) \
-exec pathfix.py -i "%{__python3} %{py3_shbang_opts}" -p -n {} \+;
# Make a copy and add suffix for kernel licence to prevent conflict of multi kernel package installation
cp $_KernSrc/COPYING $_KernSrc/COPYING.%{kernel_unamer}
# Update kernel version and suffix info to make uname consistent with RPM version
# PATCHLEVEL inconsistent only happen on first merge window, but patch them all just in case
sed -i "/^VESION/cVERSION = $(echo %{kernel_majver} | cut -d '.' -f 1)" $_KernSrc/Makefile
sed -i "/^PATCHLEVEL/cPATCHLEVEL = $(echo %{kernel_majver} | cut -d '.' -f 2)" $_KernSrc/Makefile
sed -i "/^SUBLEVEL/cSUBLEVEL = $(echo %{kernel_majver} | cut -d '.' -f 3)" $_KernSrc/Makefile
# Patch the kernel to apply uname, the reason we use EXTRAVERSION to control uname
# instead of complete use LOCALVERSION is that, we don't want out scm/rpm version info
# get inherited by random kernels built reusing the config file under /boot, which
# will be confusing.
_KVERSION=$(sed -nE "/^VERSION\s*:?=\s*(.*)/{s/^\s*^VERSION\s*:?=\s*//;h};\${x;p}" $_KernSrc/Makefile)
_KPATCHLEVEL=$(sed -nE "/^PATCHLEVEL\s*:?=\s*(.*)/{s/^\s*^PATCHLEVEL\s*:?=\s*//;h};\${x;p}" $_KernSrc/Makefile)
_KSUBLEVEL=$(sed -nE "/^SUBLEVEL\s*:?=\s*(.*)/{s/^\s*^SUBLEVEL\s*:?=\s*//;h};\${x;p}" $_KernSrc/Makefile)
_KUNAMER_PREFIX=${_KVERSION}.${_KPATCHLEVEL}.${_KSUBLEVEL}
_KEXTRAVERSION=""
_KLOCALVERSION=""
case $KernUnameR in
$_KUNAMER_PREFIX* )
_KEXTRAVERSION=$(echo "$KernUnameR" | sed -e "s/^$_KUNAMER_PREFIX//")
# Anything after "+" belongs to LOCALVERSION, eg, +debug/+minimal marker.
_KLOCALVERSION=$(echo "$_KEXTRAVERSION" | sed -ne 's/.*\([+].*\)$/\1/p')
_KEXTRAVERSION=$(echo "$_KEXTRAVERSION" | sed -e 's/[+].*$//')
# Update Makefile to embed uname
sed -i "/^EXTRAVERSION/cEXTRAVERSION = $_KEXTRAVERSION" $_KernSrc/Makefile
# Save LOCALVERSION in .dist.localversion, it will be set to .config after
# .config is ready in BuildConfig.
echo "$_KLOCALVERSION" > $_KernSrc/.dist.localversion
;;
* )
echo "FATAL: error: kernel version doesn't match with kernel spec." >&2 && exit 1
;;
esac
###### Rpmbuild Build Stage ####################################################
%build
### Make flags
#
# Those defination have to be defined after %%build macro, %%build macro may change
# some build flags, and we have to inherit these changes.
#
# NOTE: kernel's tools build system doesn't playwell with command line variables, some
# `override` statement will stop working after recursive Makefile `include` call.
# So keep these variables as environment variables so they are available globally,
# `make` will transformed env vars into makefile variable in every iteration.
## Common flags
%global make %{__make} %{_smp_mflags}
%global kernel_make_opts INSTALL_HDR_PATH=%{buildroot}/usr INSTALL_MOD_PATH=%{buildroot} KERNELRELEASE=$KernUnameR
%global tools_make_opts DESTDIR="%{buildroot}" prefix=%{_prefix} lib=%{_lib} PYTHON=%{__python3} INSTALL_ROOT="%{buildroot}"
## Cross compile flags
%if %{with_crossbuild}
%global kernel_make_opts %{kernel_make_opts} CROSS_COMPILE=%{_cross_compile} ARCH=%{kernel_arch}
# make for host tool, reset arch and flags for native host bulid, also limit to 1 job for better stability
%global host_make CFLAGS= LDFLAGS= ARCH= %{make} -j1
%global __strip %{_build_arch}-linux-gnu-strip
%else
%global host_make CFLAGS= LDFLAGS= %{make} -j1
%endif
# Drop host cflags for crossbuild, arch options from build target will break host compiler
%if !%{with_crossbuild}
%global kernel_make_opts %{kernel_make_opts} HOSTCFLAGS="%{?build_cflags}" HOSTLDFLAGS="%{?build_ldflags}"
%endif
## make for kernel
%global kernel_make %{make} %{kernel_make_opts}
## make for tools
%global tools_make CFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags}" %{make} %{tools_make_opts}
%global perf_make EXTRA_CFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags}" WERROR=0 NO_LIBUNWIND=1 HAVE_CPLUS_DEMANGLE=1 NO_GTK2=1 NO_STRLCPY=1 NO_BIONIC=1 LIBTRACEEVENT_DYNAMIC=1 %{make} %{tools_make_opts}
%global bpftool_make EXTRA_CFLAGS="${RPM_OPT_FLAGS}" EXTRA_LDFLAGS="%{__global_ldflags}" %{make} %{tools_make_opts} $([ -e "$_KernVmlinuxH" ] && echo VMLINUX_H="$_KernVmlinuxH")
### Real make
%{prepare_buildvar}
# Prepare Kernel config
BuildConfig() {
mkdir -p $_KernBuild
pushd $_KernBuild
cp $1 .config
[ "$_KernBuild" != "$_KernSrc" ] && echo "include $_KernSrc/Makefile" > Makefile
[ "$_KernBuild" != "$_KernSrc" ] && cp $_KernSrc/.dist.localversion ./
# Respect scripts/setlocalversion, avoid it from potentially mucking with our version numbers.
# Also update LOCALVERSION in .config
cp .dist.localversion .scmversion
"$_KernSrc"/scripts/config --file .config --set-str LOCALVERSION "$(cat .dist.localversion)"
# Ensures build-ids are unique to allow parallel debuginfo
sed -i -e "s/^CONFIG_BUILD_SALT.*/CONFIG_BUILD_SALT=\"$KernUnameR\"/" .config
# Call olddefconfig before make all, set all unset config to default value.
# The packager uses CROSS_COMPILE=scripts/dummy-tools for generating .config
# so compiler related config are always unset, let's just use defconfig for them for now
%{kernel_make} olddefconfig
%if %{with_modsign}
# Don't use Kbuild's signing, use %%{_module_signer} instead, be compatible with debuginfo and compression
sed -i -e "s/^CONFIG_MODULE_SIG_ALL=.*/# CONFIG_MODULE_SIG_ALL is not set/" .config
%else
# Not signing, unset all signing related configs
sed -i -e "s/^CONFIG_MODULE_SIG_ALL=.*/# CONFIG_MODULE_SIG_ALL is not set/" .config
sed -i -e "s/^CONFIG_MODULE_SIG_FORCE=.*/# CONFIG_MODULE_SIG_FORCE is not set/" .config
sed -i -e "s/^CONFIG_MODULE_SIG=.*/# CONFIG_MODULE_SIG is not set/" .config
# Lockdown can't work without module sign
sed -i -e "s/^CONFIG_SECURITY_LOCKDOWN_LSM=.*/# CONFIG_SECURITY_LOCKDOWN_LSM is not set/" .config
sed -i -e "s/^CONFIG_SECURITY_LOCKDOWN_LSM_EARLY=.*/# CONFIG_SECURITY_LOCKDOWN_LSM_EARLY is not set/" .config
%endif
# Don't use kernel's builtin module compression, imcompatible with debuginfo packaging and signing
sed -i -e "s/^\(CONFIG_DECOMPRESS_.*\)=y/# \1 is not set/" .config
popd
}
## $1: .config file
BuildKernel() {
echo "*** Start building kernel $KernUnameR"
mkdir -p $_KernBuild
pushd $_KernBuild
%if %{with_modsign}
# Call keygen here, if it generate the module keys, it should come before kbuild,
# so kbuild may avoid regenerate cert keys.
%{_module_keygen} "$KernUnameR" "$_KernBuild"
%endif
# Build vmlinux
%{kernel_make} all
# Build modules
grep -q "CONFIG_MODULES=y" ".config" && %{kernel_make} modules
# CONFIG_KERNEL_HEADER_TEST generates some extra files in the process of
# testing so just delete
find . -name *.h.s -delete
popd
}
BuildPerf() {
%{perf_make} -C tools/perf all
%{perf_make} -C tools/perf man
}
BuildTools() {
%{tools_make} -C tools/power/cpupower CPUFREQ_BENCH=false DEBUG=false
%ifarch x86_64
%{tools_make} -C tools/power/cpupower/debug/x86_64 centrino-decode powernow-k8-decode
%{tools_make} -C tools/power/x86/x86_energy_perf_policy
%{tools_make} -C tools/power/x86/turbostat
%{tools_make} -C tools/power/x86/intel-speed-select
%endif
%{tools_make} -C tools/thermal/tmon/
%{tools_make} -C tools/iio/
%{tools_make} -C tools/gpio/
%{tools_make} -C tools/mm/ slabinfo page_owner_sort
}
BuildBpfTool() {
echo "*** Building bootstrap bpftool and extrace vmlinux.h"
if ! [ -s $_KernVmlinuxH ]; then
# Precompile a minimized bpftool without vmlinux.h, use it to extract vmlinux.h
# for bootstraping the full feature bpftool
%{host_make} -C tools/bpf/bpftool/ VMLINUX_BTF= VMLINUX_H=
# Prefer to extract the vmlinux.h from the vmlinux that were just compiled
# fallback to use host's vmlinux
# Skip this if bpftools is too old and doesn't support BTF dump
if tools/bpf/bpftool/bpftool btf help 2>&1 | grep -q "\bdump\b"; then
if grep -q "CONFIG_DEBUG_INFO_BTF=y" "$_KernBuild/.config" && [ -s "$_KernBuild/vmlinux" ]; then
tools/bpf/bpftool/bpftool btf dump file "$_KernBuild/vmlinux" format c > $_KernVmlinuxH
else
tools/bpf/bpftool/bpftool btf dump file /sys/kernel/btf/vmlinux format c > $_KernVmlinuxH
fi
fi
%{host_make} -C tools/bpf/bpftool/ clean
fi
echo "*** Building bpftool"
%{bpftool_make} -C tools/bpf/bpftool
}
%if %{with_core}
%ifnarch x86_64 aarch64 riscv64
{error:unsupported arch}
%endif
%ifarch x86_64
BuildConfig %{SOURCE1000}
%endif
%ifarch aarch64
BuildConfig %{SOURCE1001}
%endif
%ifarch riscv64
BuildConfig %{SOURCE1002}
%endif
BuildKernel
%endif
%if %{with_perf}
BuildPerf
%endif
%if %{with_tools}
BuildTools
%endif
%if %{with_bpftool}
BuildBpfTool
%endif
###### Rpmbuild Install Stage ##################################################
%install
%{prepare_buildvar}
InstKernelBasic() {
####### Basic environment ##################
# prepare and pushd into the kernel module top dir
mkdir -p $KernModule
pushd $KernModule
####### modules_install ##################
pushd $_KernBuild
# Override $(mod-fw) because we don't want it to install any firmware
# we'll get it from the linux-firmware package and we don't want conflicts
grep -q "CONFIG_MODULES=y" ".config" && %{kernel_make} mod-fw= modules_install
# Check again, don't package firmware, use linux-firmware rpm instead
rm -rf %{buildroot}/lib/firmware
popd
####### Prepare kernel modules files for packaging ################
# Don't package depmod files, they should be auto generated by depmod at rpm -i
rm -f modules.{alias,alias.bin,builtin.alias.bin,builtin.bin} \
modules.{dep,dep.bin,devname,softdep,symbols,symbols.bin}
# Process kernel modules
find . -name "*.ko" -type f | \
while read -r _kmodule; do
# Mark it executable so strip and find-debuginfo can see it
chmod u+x "$_kmodule"
# Detect missing or incorrect license tags
modinfo "$_kmodule" -l | grep -E -qv \
'GPL( v2)?$|Dual BSD/GPL$|Dual MPL/GPL$|GPL and additional rights$' && \
echo "Module $_kmodule has incorrect license." >&2 && exit 1
# Collect module symbol reference info for later usage
case "$kmodule" in */drivers/*) nm -upA "$_kmodule" ;;
esac | sed -n 's,^.*/\([^/]*\.ko\): *U \(.*\)$,\1 \2,p' >> drivers.undef
done || exit $?
# Generate a list of modules for block and networking.
collect_modules_list() {
sed -r -n -e "s/^([^ ]+) \\.?($2)\$/\\1/p" drivers.undef |
LC_ALL=C sort -u > $KernModule/modules.$1
if [ ! -z "$3" ]; then
sed -r -e "/^($3)\$/d" -i $KernModule/modules.$1
fi
}
collect_modules_list networking \
'register_netdev|ieee80211_register_hw|usbnet_probe|phy_driver_register|rt(l_|2x00)(pci|usb)_probe|register_netdevice'
collect_modules_list block \
'ata_scsi_ioctl|scsi_add_host|scsi_add_host_with_dma|blk_alloc_queue|blk_init_queue|register_mtd_blktrans|scsi_esp_register|scsi_register_device_handler|blk_queue_physical_block_size' \
'pktcdvd.ko|dm-mod.ko'
collect_modules_list drm \
'drm_open|drm_init'
collect_modules_list modesetting \
'drm_crtc_init'
# Finish preparing the kernel module files
###### Install kernel core components #############################
mkdir -p %{buildroot}/boot
install -m 644 $_KernBuild/.config config
install -m 644 $_KernBuild/.config %{buildroot}/boot/config-$KernUnameR
install -m 644 $_KernBuild/System.map System.map
install -m 644 $_KernBuild/System.map %{buildroot}/boot/System.map-$KernUnameR
# NOTE: If we need to sign the vmlinuz, this is the place to do it.
%ifarch aarch64
INSTALL_DTB_ARCH_PATH=$_KernBuild/arch/arm64/boot/dts
install -m 644 $_KernBuild/arch/arm64/boot/Image vmlinuz
%endif
%ifarch riscv64
INSTALL_DTB_ARCH_PATH=$_KernBuild/arch/riscv/boot/dts
install -m 644 $_KernBuild/arch/riscv/boot/Image vmlinuz
%endif
%ifarch x86_64
INSTALL_DTB_ARCH_PATH=
install -m 644 $_KernBuild/arch/x86/boot/bzImage vmlinuz
%endif
%ifarch loongarch64
INSTALL_DTB_ARCH_PATH=
install -m 644 $_KernBuild/vmlinuz vmlinuz
%endif
# Install Arch DTB if exists
if [ -n "$INSTALL_DTB_ARCH_PATH" ]; then
pushd $INSTALL_DTB_ARCH_PATH || :
find . -name "*.dtb" | while read -r dtb; do
mkdir -p %{buildroot}/boot/dtb-$KernUnameR/$(dirname $dtb)
cp $dtb %{buildroot}/boot/dtb-$KernUnameR/$(dirname $dtb)
done
popd
fi
# Sign the vmlinuz for supporting secure boot feature only when
# external efi secure boot signer provided.
%if 0%{?_sb_signer:1}
%{_sb_signer vmlinuz vmlinuz.signed}
mv vmlinuz.signed vmlinuz
%endif
# Install Arch vmlinuz
install -m 644 vmlinuz %{buildroot}/boot/vmlinuz-$KernUnameR
sha512hmac %{buildroot}/boot/vmlinuz-$KernUnameR | sed -e "s,%{buildroot},," > .vmlinuz.hmac
cp .vmlinuz.hmac %{buildroot}/boot/.vmlinuz-$KernUnameR.hmac
###### Doc and certs #############################
mkdir -p %{buildroot}/%{_datadir}/doc/kernel-keys/$KernUnameR
if [ -e $_KernBuild/certs/signing_key.x509 ]; then
install -m 0644 $_KernBuild/certs/signing_key.x509 %{buildroot}/%{_datadir}/doc/kernel-keys/$KernUnameR/kernel-signing-ca.cer
%if %{with_keypkg}
if [ -e $_KernBuild/certs/signing_key.pem ]; then
install -m 0644 $_KernBuild/certs/signing_key.pem %{buildroot}/%{_datadir}/doc/kernel-keys/$KernUnameR/kernel-signing-ca.pem
fi
%endif
fi
###### kABI checking and packaging #############################
# Always create the kABI metadata for use in packaging
echo "**** GENERATING kernel ABI metadata ****"
gzip -c9 < $_KernBuild/Module.symvers > symvers.gz
cp symvers.gz %{buildroot}/boot/symvers-$KernUnameR.gz
###### End of installing kernel modules and core
popd
}
CheckKernelABI() {
echo "**** kABI checking is enabled. ****"
if ! [ -s "$1" ]; then
echo "**** But cannot find reference Module.kabi file. ****"
else
cp $1 %{buildroot}/Module.kabi
%{SOURCE30} -k %{buildroot}/Module.kabi -s $_KernBuild/Module.symvers || exit 1
rm %{buildroot}/Module.kabi
fi
}
InstKernelDevel() {
###### Install kernel-devel package ###############################
### TODO: need tidy up
### Save the headers/makefiles etc for building modules against.
# This all looks scary, but the end result is supposed to be:
# * all arch relevant include/ files
# * all Makefile/Kconfig files
# * all script/ files
# `modules_install` will symlink build to $_KernBuild, and source to $_KernSrc, remove the symlinks first
rm -rf $KernModule/{build,source}
mkdir -p $KernModule/{extra,updates,weak-updates}
# Symlink $KernDevel to kernel module build path
ln -sf /usr/src/kernels/$KernUnameR $KernModule/build
ln -sf /usr/src/kernels/$KernUnameR $KernModule/source
# Start installing kernel devel files
mkdir -p $KernDevel
pushd $KernDevel
# First copy everything
(cd $_KernSrc; cp --parents $(find . -type f -name "Makefile*" -o -name "Kconfig*" -o -name "Kbuild*") $KernDevel/)
# Copy built config and sym files
cp $_KernBuild/Module.symvers .
cp $_KernBuild/System.map .
cp $_KernBuild/.config .
if [ -s $_KernBuild/Module.markers ]; then
cp $_KernBuild/Module.markers .
fi
# We may want to keep Documentation, I got complain from users of missing Makefile
# of Documentation when building custom module with document.
# rm -rf build/Documentation
# Script files
rm -rf scripts
cp -a $_KernSrc/scripts .
cp -a $_KernBuild/scripts .
# Include files
rm -rf include
cp -a $_KernSrc/include .
cp -a $_KernBuild/include/config include/
cp -a $_KernBuild/include/generated include/
# SELinux
mkdir -p security/selinux/
cp -a $_KernSrc/security/selinux/include security/selinux/
# Set arch name
Arch=$(head -4 $_KernBuild/.config | sed -ne "s/.*Linux\/\([^\ ]*\).*/\1/p" | sed -e "s/x86_64/x86/" )
# Arch include
mkdir -p arch/$Arch
cp -a $_KernSrc/arch/$Arch/include arch/$Arch/
cp -a $_KernBuild/arch/$Arch/include arch/$Arch/
%ifarch loongarch64
if [ -f $_KernSrc/arch/$Arch/la64/Platform ]; then
mkdir -p arch/$Arch/la64
cp -a $_KernSrc/arch/$Arch/la64/Platform arch/$Arch/la64
fi
%endif
if [ -d $_KernBuild/arch/$Arch/scripts ]; then
cp -a $_KernBuild/arch/$Arch/scripts arch/$Arch/ || :
fi
# Kernel module build dependency
if [ -f $_KernBuild/tools/objtool/objtool ]; then
cp -a $_KernBuild/tools/objtool/objtool tools/objtool/ || :
fi
if [ -f $_KernBuild/tools/objtool/fixdep ]; then
cp -a $_KernBuild/tools/objtool/fixdep tools/objtool/ || :
fi
cp -a $_KernSrc/arch/$Arch/*lds arch/$Arch/ &>/dev/null || :
cp -a $_KernBuild/arch/$Arch/*lds arch/$Arch/ &>/dev/null || :
mkdir -p arch/$Arch/kernel
if [ -f $_KernSrc/arch/$Arch/kernel/module.lds ]; then
cp -a $_KernSrc/arch/$Arch/kernel/module.lds arch/$Arch/kernel/
fi
if [ -f $_KernBuild/arch/$Arch/kernel/module.lds ]; then
cp -a $_KernBuild/arch/$Arch/kernel/module.lds arch/$Arch/kernel/
fi
# Symlink include/asm-$Arch for better compatibility with some old system
ln -sfr arch/$Arch include/asm-$Arch
# Make sure the Makefile and version.h have a matching timestamp so that
# external modules can be built
touch -r Makefile include/generated/uapi/linux/version.h
touch -r .config include/linux/autoconf.h
# If we have with_modsign, the key should be installed under _datadir, make a symlink here:
if [ -e %{buildroot}/%{_datadir}/doc/kernel-keys/$KernUnameR/kernel-signing-ca.cer ]; then
mkdir -p certs
ln -sf %{_datadir}/doc/kernel-keys/$KernUnameR/kernel-signing-ca.cer signing_key.x509
ln -sf %{_datadir}/doc/kernel-keys/$KernUnameR/kernel-signing-ca.cer certs/signing_key.x509
ln -sf %{_datadir}/doc/kernel-keys/$KernUnameR/kernel-signing-ca.pem signing_key.pem
ln -sf %{_datadir}/doc/kernel-keys/$KernUnameR/kernel-signing-ca.pem certs/signing_key.pem
fi
# Delete obj files
find . -iname "*.o" -o -iname "*.cmd" -delete
# Done
popd
}
InstKernelHeaders () {
%{kernel_make} headers_install
find %{buildroot}/usr/include \
\( -name .install -o -name .check -o \
-name ..install.cmd -o -name ..check.cmd \) -delete
}
InstPerf () {
%{perf_make} -C tools/perf install-bin install-python_ext install-man
# remove the 'trace' symlink.
rm -f %{buildroot}%{_bindir}/trace
# Be just like CentOS:
# remove any tracevent files, eg. its plugins still gets built and installed,
# even if we build against system's libtracevent during perf build (by setting
# LIBTRACEEVENT_DYNAMIC=1 above in perf_make macro). Those files should already
# ship with libtraceevent package.
rm -rf %{buildroot}%{_libdir}/traceevent
}
InstTools() {
%{tools_make} -C tools/power/cpupower DESTDIR=%{buildroot} libdir=%{_libdir} mandir=%{_mandir} CPUFREQ_BENCH=false install
rm -f %{buildroot}%{_libdir}/*.{a,la}
%find_lang cpupower
mv cpupower.lang ../
%ifarch x86_64
pushd tools/power/cpupower/debug/x86_64
install -m755 centrino-decode %{buildroot}%{_bindir}/centrino-decode
install -m755 powernow-k8-decode %{buildroot}%{_bindir}/powernow-k8-decode
popd
%endif
chmod 0755 %{buildroot}%{_libdir}/libcpupower.so*
mkdir -p %{buildroot}%{_unitdir} %{buildroot}%{_sysconfdir}/sysconfig
install -m644 %{SOURCE2000} %{buildroot}%{_unitdir}/cpupower.service
install -m644 %{SOURCE2001} %{buildroot}%{_sysconfdir}/sysconfig/cpupower
%ifarch x86_64
mkdir -p %{buildroot}%{_mandir}/man8
%{tools_make} -C tools/power/x86/x86_energy_perf_policy DESTDIR=%{buildroot} install
%{tools_make} -C tools/power/x86/turbostat DESTDIR=%{buildroot} install
%{tools_make} -C tools/power/x86/intel-speed-select DESTDIR=%{buildroot} install
%endif
%{tools_make} -C tools/thermal/tmon install
%{tools_make} -C tools/iio install
%{tools_make} -C tools/gpio install
pushd tools/mm/
install -m755 slabinfo %{buildroot}%{_bindir}/slabinfo
install -m755 page_owner_sort %{buildroot}%{_bindir}/page_owner_sort
popd
# with_tools
}
InstBpfTool () {
%{bpftool_make} -C tools/bpf/bpftool bash_compdir=%{_sysconfdir}/bash_completion.d/ mandir=%{_mandir} install doc-install
}
CollectKernelFile() {
###### Collect file list #########################################
pushd %{buildroot}
# Collect all module files, dtb files, and dirs
{
# Install certs in core package if found
echo "%%dir %{_datadir}/doc/kernel-keys"
if [ -e "%{buildroot}/%{_datadir}/doc/kernel-keys/%{kernel_unamer}/kernel-signing-ca.cer" ]; then
echo %{_datadir}/doc/kernel-keys/%{kernel_unamer}/kernel-signing-ca.cer
fi
find lib/modules/$KernUnameR/ boot/dtb-$KernUnameR/ -not -type d -printf '/%%p\n' 2>/dev/null
find lib/modules/$KernUnameR/ boot/dtb-$KernUnameR/ -type d -printf '%%%%dir /%%p\n' 2>/dev/null
} | sort -u > core.list
%if %{with_keypkg}
# Install private key in cert package if found
# Echo a dir so it don't fail as a empty list if signing is disabled.
echo "%%dir %{_datadir}/doc/kernel-keys" > signing-keys.list
if [ -e "%{buildroot}/%{_datadir}/doc/kernel-keys/%{kernel_unamer}/kernel-signing-ca.pem" ]; then
echo %{_datadir}/doc/kernel-keys/%{kernel_unamer}/kernel-signing-ca.pem >> signing-keys.list
fi
%endif
# Do module splitting, filter-modules.sh will generate a list of
# modules to be split into external module package
# Rest of the modules stay in core package
%SOURCE10 "%{buildroot}" "$KernUnameR" "%{_target_cpu}" "$_KernBuild/System.map" non-core-modules >> modules.list || exit $?
comm -23 core.list modules.list > core.list.tmp
mv core.list.tmp core.list
popd
# Make these file list usable in rpm build dir
mv %{buildroot}/*.list ../
}
###### Start Kernel Install
%if %{with_core}
InstKernelBasic
%if %{with_kabichk}
%ifnarch x86_64 aarch64 riscv64
{error:unsupported arch}
%endif
%ifarch x86_64
CheckKernelABI %{SOURCE1200}
%endif
%ifarch aarch64
CheckKernelABI %{SOURCE1201}
%endif
%ifarch riscv64
CheckKernelABI %{SOURCE1202}
%endif
%endif
InstKernelDevel
%endif
%if %{with_headers}
InstKernelHeaders
%endif
%if %{with_perf}
InstPerf
%endif
%if %{with_tools}
InstTools
%endif
%if %{with_bpftool}
InstBpfTool
%endif
%if %{with_core}
CollectKernelFile
%endif
###### Debuginfo ###############################################################
%if %{with_debuginfo}
###### Kernel core debuginfo #######
%if %{with_core}
mkdir -p %{buildroot}%{debuginfo_dir}/lib/modules/$KernUnameR
cp -rpf $_KernBuild/vmlinux %{buildroot}%{debuginfo_dir}/lib/modules/$KernUnameR/vmlinux
ln -sf %{debuginfo_dir}/lib/modules/$KernUnameR/vmlinux %{buildroot}/boot/vmlinux-$KernUnameR
%endif
#with_core
# All binary installation are done here, so run __debug_install_post, then undefine it.
# This triggers find-debuginfo.sh, undefine prevents it from being triggered again
# in post %%install. we do this here because we need to compress and sign modules
# after the debuginfo extraction.
%__debug_install_post
# Delete the debuginfo for kernel-devel files
rm -rf %{buildroot}%{debuginfo_dir}/usr/src
%undefine __debug_install_post
###### Finally, module sign and compress ######
%if %{with_modsign} && %{with_core}
### Sign after debuginfo extration, extraction breaks signature
%{_module_signer} "$KernUnameR" "$_KernBuild" "%{buildroot}" || exit $?
%endif
### Compression after signing, compressed module can't be signed
# Spawn at most 16 workers, at least 2 workers, each worker compress 4 files
NPROC=$(nproc --all)
[ "$NPROC" ] || NPROC=2
[ "$NPROC" -gt 16 ] && NPROC=16
find "$KernModule" -type f -name '*.ko' -print0 | xargs -0r -P${NPROC} -n4 xz -T1;
### Change module path in file lists
for list in ../*.list; do
sed -i -e 's/\.ko$/\.ko.xz/' $list
done
%endif
#with_debuginfo
###### RPM scriptslets #########################################################
### Core package
# Pre
%if %{with_core}
%pre core
# Best effort try to avoid installing with wrong arch
if command -v uname > /dev/null; then
system_arch=$(uname -m)
if [ %{_target_cpu} != $system_arch ]; then
echo "WARN: This kernel is built for %{_target_cpu}. but your system is $system_arch." > /dev/stderr
fi
fi
%post core
touch %{_localstatedir}/lib/rpm-state/%{name}-%{version}-%{version}%{?dist}.installing_core
%posttrans core
# Weak modules
if command -v weak-modules > /dev/null; then
weak-modules --add-kernel %{kernel_unamer} || exit $?
fi
# Boot entry and depmod files
if command -v kernel-install > /dev/null; then
kernel-install add %{kernel_unamer} /lib/modules/%{kernel_unamer}/vmlinuz
elif command -v new-kernel-pkg > /dev/null; then
new-kernel-pkg --package kernel --install %{kernel_unamer} --kernel-args="crashkernel=512M-12G:128M,12G-64G:256M,64G-128G:512M,128G-:768M" --make-default || exit $?
new-kernel-pkg --package kernel --mkinitrd --dracut --depmod --update %{kernel_unamer} || exit $?
else
echo "NOTICE: No available kernel install handler found. Please make sure boot loader and initramfs are properly configured after the installation." > /dev/stderr
fi
# Just in case kernel-install didn't depmod
depmod -A %{kernel_unamer}
# Core install done
rm -f %{_localstatedir}/lib/rpm-state/%{name}-%{version}-%{version}%{?dist}.installing_core
# XXX: Workaround for TLinux 2.x, TLinux 2.x has broken SELinux rule, enabling SELinux will cause boot failure.
%if "%{dist}" == ".tl2"
if command -v grubby > /dev/null; then
grubby --update-kernel /boot/vmlinuz-%{kernel_unamer} --args selinux=0
else
echo "NOTICE: TL2 detected, but grubby is missing, please set selinux=0 for new installed kernel manually, or it may fail to boot due to broken SELinux rule." > /dev/stderr
fi
%endif
%preun core
# Boot entry and depmod files
if command -v kernel-install > /dev/null; then
kernel-install remove %{kernel_unamer} /lib/modules/%{kernel_unamer}/vmlinuz || exit $?
elif command -v new-kernel-pkg > /dev/null; then
/sbin/new-kernel-pkg --rminitrd --dracut --remove %{kernel_unamer}
else
echo "NOTICE: No available kernel uninstall handler found. Please make sure boot loader and initramfs are properly cleared after the uninstallation." > /dev/stderr
fi
# Weak modules
if command -v weak-modules > /dev/null; then
weak-modules --remove-kernel %{kernel_unamer} || exit $?
fi
### Module package
%post modules
depmod -a %{kernel_unamer}
if [ ! -f %{_localstatedir}/lib/rpm-state/%{name}-%{version}-%{version}%{?dist}.installing_core ]; then
touch %{_localstatedir}/lib/rpm-state/%{name}-%{version}-%{version}%{?dist}.need_to_run_dracut
fi
%posttrans modules
if [ -f %{_localstatedir}/lib/rpm-state/%{name}-%{version}-%{version}%{?dist}.need_to_run_dracut ]; then\
dracut -f --kver "%{kernel_unamer}"
rm -f %{_localstatedir}/lib/rpm-state/%{name}-%{version}-%{version}%{?dist}.need_to_run_dracut
fi
%postun modules
depmod -a %{kernel_unamer}
### Devel package
%post devel
if [ -f /etc/sysconfig/kernel ]; then
. /etc/sysconfig/kernel || exit $?
fi
# This hardlink merges same devel files across different kernel packages
if [ "$HARDLINK" != "no" -a -x /usr/bin/hardlink -a ! -e /run/ostree-booted ]; then
(cd /usr/src/kernels/%{kernel_unamer} && /usr/bin/find . -type f | while read -r f; do
hardlink /usr/src/kernels/*/$f $f > /dev/null
done)
fi
%endif
### kernel-tools package
%if %{with_tools}
%post -n kernel-tools-libs
/sbin/ldconfig
%postun -n kernel-tools-libs
/sbin/ldconfig
%endif
###### Rpmbuild packaging file list ############################################
### empty meta-package
%if %{with_core}
%files
%{nil}
%files core -f core.list
%defattr(-,root,root)
# Mark files as ghost in case rewritten after install (eg. by kernel-install script)
%ghost /boot/vmlinuz-%{kernel_unamer}
%ghost /boot/.vmlinuz-%{kernel_unamer}.hmac
/boot/System.map-%{kernel_unamer}
/boot/config-%{kernel_unamer}
/boot/symvers-%{kernel_unamer}.gz
# Initramfs will be generated after install
%ghost /boot/initramfs-%{kernel_unamer}.img
%ghost /boot/initramfs-%{kernel_unamer}kdump.img
# Make depmod files ghost files of the core package
%dir /lib/modules/%{kernel_unamer}
%ghost /lib/modules/%{kernel_unamer}/modules.alias
%ghost /lib/modules/%{kernel_unamer}/modules.alias.bin
%ghost /lib/modules/%{kernel_unamer}/modules.builtin.bin
%ghost /lib/modules/%{kernel_unamer}/modules.builtin.alias.bin
%ghost /lib/modules/%{kernel_unamer}/modules.dep
%ghost /lib/modules/%{kernel_unamer}/modules.dep.bin
%ghost /lib/modules/%{kernel_unamer}/modules.devname
%ghost /lib/modules/%{kernel_unamer}/modules.softdep
%ghost /lib/modules/%{kernel_unamer}/modules.symbols
%ghost /lib/modules/%{kernel_unamer}/modules.symbols.bin
%{!?_licensedir:%global license %%doc}
%license %{kernel_tarname}/COPYING.%{kernel_unamer}
%files modules -f modules.list
%defattr(-,root,root)
%if %{with_keypkg}
%files signing-keys -f signing-keys.list
%defattr(-,root,root)
%endif
%files devel
%defattr(-,root,root)
/usr/src/kernels/%{kernel_unamer}
%if %{with_debuginfo}
%files debuginfo -f debuginfo.list
%defattr(-,root,root)
/boot/vmlinux-%{kernel_unamer}
%endif
# with_core
%endif
%if %{with_debuginfo}
%files debuginfo-common -f debugfiles.list
%defattr(-,root,root)
%endif
%if %{with_headers}
%files headers
%defattr(-,root,root)
/usr/include/*
%endif
%if %{with_perf}
%files -n perf
%defattr(-,root,root)
%{_bindir}/perf*
%{_libdir}/libperf-jvmti.so
%dir %{_libexecdir}/perf-core
%{_libexecdir}/perf-core/*
%{_datadir}/perf-core/*
%{_mandir}/man[1-8]/perf*
%{_sysconfdir}/bash_completion.d/perf
%{_docdir}/perf-tip/tips.txt
# TODO: Missing doc?
# %%doc linux-%%{kernel_unamer}/tools/perf/Documentation/examples.txt
%files -n python3-perf
%defattr(-,root,root)
%{python3_sitearch}/*
%if %{with_debuginfo}
%files -f perf-debuginfo.list -n perf-debuginfo
%defattr(-,root,root)
%files -f python3-perf-debuginfo.list -n python3-perf-debuginfo
%defattr(-,root,root)
%endif
# with_perf
%endif
%if %{with_tools}
%files -n kernel-tools -f cpupower.lang
%defattr(-,root,root)
%{_bindir}/cpupower
%{_datadir}/bash-completion/completions/cpupower
%ifarch x86_64
%{_bindir}/centrino-decode
%{_bindir}/powernow-k8-decode
%endif
%{_unitdir}/cpupower.service
%{_mandir}/man[1-8]/cpupower*
%config(noreplace) %{_sysconfdir}/sysconfig/cpupower
%ifarch x86_64
%{_bindir}/x86_energy_perf_policy
%{_mandir}/man8/x86_energy_perf_policy*
%{_bindir}/turbostat
%{_mandir}/man8/turbostat*
%{_bindir}/intel-speed-select
%endif
%{_bindir}/tmon
%{_bindir}/iio_event_monitor
%{_bindir}/iio_generic_buffer
%{_bindir}/lsiio
%{_bindir}/lsgpio
%{_bindir}/gpio-*
%{_bindir}/page_owner_sort
%{_bindir}/slabinfo
%files -n kernel-tools-libs
%defattr(-,root,root)
%{_libdir}/libcpupower.so
%{_libdir}/libcpupower.so.*
%files -n kernel-tools-libs-devel
%defattr(-,root,root)
%{_includedir}/cpufreq.h
%if %{with_debuginfo}
%files -f kernel-tools-debuginfo.list -n kernel-tools-debuginfo
%defattr(-,root,root)
%endif
# with_tools
%endif
%if %{with_bpftool}
%files -n bpftool
%defattr(-,root,root)
%{_sbindir}/bpftool
%{_sysconfdir}/bash_completion.d/bpftool
%{_mandir}/man8/bpftool.8.gz
%{_mandir}/man8/bpftool-*.8.gz
%if %{with_debuginfo}
%files -f bpftool-debuginfo.list -n bpftool-debuginfo
%defattr(-,root,root)
%endif
# with_bpftool
%endif
###### Changelog ###############################################################
%changelog
* Thu May 23 2024 Miaojun Dong <zoedong@tencent.com> - 6.6.6-2401.0.3
- Add shangmi support in x86_64 and aarch64
- Support FS encrypt
- Support shangmi(SM2/SM3/SM4) and AVX/CE/NEON instruction set optimization
* Wed Jan 17 2024 Rebuild Robot <rebot@opencloudos.org> - 6.6.6-2401.0.2
- Rebuilt for elfutils
* Wed Dec 20 2023 Kairui Song <kasong@tencent.com> - 6.6.6-2401.0.1
- kabi: freeze kabi for x86_64 and arm64
- x86/mpparse, kexec: switch apic driver early when x2apic is pre-enabled
- tracing: workaround UAF caused by memory ordering issue
- mm/slub.c: sanitize freelist pointer assignment even more
- mm/slub.c: fix a potential UAF
- cgroup: use a standalone workqueue for killing css
- mm/vmscan.c: add cond_resched function call into __shrink_page_cache
- swap: expose required symbols for some 3rd part modules
- swapfile: add a helper get_cached_swap_page_of_type
- mm: memcg: introduce v2's interface to v1
- psi: only show SOME PSI for non-IRQ in cgroup v1
- psi: support cgroup v1 psi accounting
- psi: expose cgroup v1 interface for psi
- psi: link legacy root to psi_system
- sched/psi: simplify cgroup psi retrieving
- arm64: fake a reliable stacktrace for livepath
- arm64: enable livepatch without stable stacktrace
- arm64: basic infrastructure for livepatch
- pagecachelimit: limit the pagecache ratio of totalram
- blkcg: add buffer IO throttle for cgroup v1
- cgroupfs: support stat based on cpuacct
- cgroupfs: fix non inited i_ino when inode created
- cgroupfs: add files inside sys
- cgroupfs: support for proc and sys
- cgroupfs: quota aware support
- cgroupfs: refactor cgroup resource statistics for reuse
- memcg: make meminfo optionally recursive and rework
- memcg: add meminfo and vmstat show
- cpuset: add switch support for cpuset.stat in container
- cpuset: fix cpuset.stat process field value exception
- cpuset: add switch for cpuinfo in container
- cpuset: add loadavg calc for each container
- cpuset: add cpuinfo and stat show
- sysfs: add sysfs attribute to hide disk devices
- blkcg/diskstats/dm: add support for blkcg diskstats
- blkcg/diskstats/md: add support for blkcg diskstats
- blkcg/diskstats: add per blkcg diskstats support
- ext4: Add an error info during new_inode
- ext4: fix soft lockup caused by sbi->s_es_lru
- ceph: add mds request pid info into debugfs
- ceph: Add new mount option req_resend
- ceph: re-send osd requests if timeout
- nvme: add the hotplug info output about drive letter and BDF
- nbd: add the nbd_ignore_blksize_set support
- xfs: add kmem_alloc_by_vmalloc and kmem_alloc_large_dump_stack sysctl
- xfs: set xfs default error level to 5
- ceph: add sysctl to ignore error epoch barrier
- ext3: set nobarrier as default
- block: check whether queue is NULL or not in stats functions
- net: modify default value of host max_orphan
- net: namespaceify sysctl_tcp_max_orphans
- vm: isolate max_map_count by pid namespace
- cpuacct: get the uptime of container
- proc: add pid mapping between host and container
- taskstats: expose taskstats to all netspace
- tcp: make TCP_RTO_MIN/MAX be tunable
- tcp: support self define parameter to tune rto of syn/synack packets
- tcp: introduce sysctl tcp_inherit_buffsize
- net: ipv6 neigh tunnel bypass
- net: add sysctl to control page frag
- net: add sriov debug info
- net: increase tcp listen hash
- tcp: add TCP_FULLNAT_REAL setsockopt options for fullnat real ip
- net: reduce the confliction while multi threads connecting same host
- bonding: add broadcast_arp param to send arp broadcast
- netlink: don't modprobe proto audit & selinux
- tcp: add proc parameter to change init cwnd
- net: add tcp_no_delay_ack to enable absolute quick ack
- tcp: add tcp_loss_init_cwnd sysctl to tunnel packet numbers in loss
- network: default zero bond_devices to support
- tcp: double the default value of thash_entries
- tcp: backoff the commit allowing timestamps even if SYN packet has tsval=0
- net: dev ipv4/v6 stat
- net: add tcp drop stats
- ipmi: set kipmid_max_busy_us default to 1
- sched: adaptive default skew_tick value
- ipc/msg: increase defaults for shmmall, shmmax, msgmax and msgmnb
- mm: increase dirty-ratio from 20 to 40
- tkernel: netfilter: conntrack: add netagent extention slot
- tkernel: net: add toa support
- tkernel: mounts: add shield mountpoint in container support
- tkernel: netatop: add netatop module in kernel/tkernel/
- tkernel: ttools: add ttools module to support ptrace protect
- tkernel: initial support and nonpriv_bind
- sysrq: add ALT+LEFTCTRL to trigger crash dump
- kabi: add paddings and optimize (part 3)
- kabi: add paddings (part 2)
- kabi: add paddings (part 1)
- kabi: add kabi.h
- kabi: modules: better vermagic check on module load
- config: update config for ocks-2401
- dist: config: update config from ocks-2303
- dist: config: add default config files
- dist: fix script checker
- dist: tools/vm -> tools/mm
- dist: move libcpupower.so to kernel-libs
- dist: initial support
- Linux 6.6.6
* Mon Mar 14 2022 Kairui Song <kasong@tencent.com> - 5.17.0-0.20220314git47581bb4d9ae.rc7-tks
- Initial release
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。