ba564c
# We have to override the new %%install behavior because, well... the kernel is special.
ba564c
%global __spec_install_pre %{___build_pre}
ba564c
74e6ae
# At the time of this writing (2019-03), RHEL8 packages use w2.xzdio
74e6ae
# compression for rpms (xz, level 2).
74e6ae
# Kernel has several large (hundreds of mbytes) rpms, they take ~5 mins
74e6ae
# to compress by single-threaded xz. Switch to threaded compression,
74e6ae
# and from level 2 to 3 to keep compressed sizes close to "w2" results.
74e6ae
#
74e6ae
# NB: if default compression in /usr/lib/rpm/redhat/macros ever changes,
74e6ae
# this one might need tweaking (e.g. if default changes to w3.xzdio,
74e6ae
# change below to w4T.xzdio):
74e6ae
%define _binary_payload w3T.xzdio
ba564c
ba564c
# For a kernel released for public testing, released_kernel should be 1.
ba564c
# For internal testing builds during development, it should be 0.
ba564c
%global released_kernel 1
ba564c
74e6ae
%global distro_build 147
ba564c
ba564c
# Sign the x86_64 kernel for secure boot authentication
3fb3f3
%ifarch x86_64 aarch64 s390x ppc64le
ba564c
%global signkernel 1
ba564c
%else
ba564c
%global signkernel 0
ba564c
%endif
ba564c
ba564c
# Sign modules on all arches
ba564c
%global signmodules 1
ba564c
ba564c
# Compress modules only for architectures that build modules
ba564c
%ifarch noarch
ba564c
%global zipmodules 0
ba564c
%else
ba564c
%global zipmodules 1
ba564c
%endif
ba564c
ba564c
%if %{zipmodules}
ba564c
%global zipsed -e 's/\.ko$/\.ko.xz/'
ba564c
%endif
ba564c
ba564c
# define buildid .local
ba564c
ba564c
%define rpmversion 4.18.0
3fb3f3
%define pkgrelease 147.5.1.el8_1
ba564c
ba564c
# allow pkg_release to have configurable %%{?dist} tag
3fb3f3
%define specrelease 147.5.1%{?dist}
ba564c
ba564c
%define pkg_release %{specrelease}%{?buildid}
ba564c
ba564c
# What parts do we want to build?  We must build at least one kernel.
ba564c
# These are the kernels that are built IF the architecture allows it.
ba564c
# All should default to 1 (enabled) and be flipped to 0 (disabled)
ba564c
# by later arch-specific checks.
ba564c
11fc6a
%define _with_kabidupchk 1
ba564c
# The following build options are enabled by default.
ba564c
# Use either --without <opt> in your rpmbuild command or force values
ba564c
# to 0 in here to disable them.
ba564c
#
ba564c
# standard kernel
ba564c
%define with_up        %{?_without_up:        0} %{?!_without_up:        1}
ba564c
# kernel-debug
ba564c
%define with_debug     %{?_without_debug:     0} %{?!_without_debug:     1}
ba564c
# kernel-doc
ba564c
%define with_doc       %{?_without_doc:       0} %{?!_without_doc:       1}
ba564c
# kernel-headers
ba564c
%define with_headers   %{?_without_headers:   0} %{?!_without_headers:   1}
ba564c
%define with_cross_headers   %{?_without_cross_headers:   0} %{?!_without_cross_headers:   1}
ba564c
# perf
ba564c
%define with_perf      %{?_without_perf:      0} %{?!_without_perf:      1}
ba564c
# tools
ba564c
%define with_tools     %{?_without_tools:     0} %{?!_without_tools:     1}
ba564c
# bpf tool
ba564c
%define with_bpftool   %{?_without_bpftool:   0} %{?!_without_bpftool:   1}
ba564c
# kernel-debuginfo
ba564c
%define with_debuginfo %{?_without_debuginfo: 0} %{?!_without_debuginfo: 1}
ba564c
# Want to build a the vsdo directories installed
ba564c
%define with_vdso_install %{?_without_vdso_install: 0} %{?!_without_vdso_install: 1}
ba564c
# kernel-zfcpdump (s390 specific kernel for zfcpdump)
ba564c
%define with_zfcpdump  %{?_without_zfcpdump:  0} %{?!_without_zfcpdump:  1}
ba564c
# kernel-abi-whitelists
ba564c
%define with_kernel_abi_whitelists %{?_without_kernel_abi_whitelists: 0} %{?!_without_kernel_abi_whitelists: 1}
74e6ae
# internal samples and selftests
74e6ae
%define with_selftests %{?_without_selftests: 0} %{?!_without_selftests: 1}
ba564c
#
ba564c
# Additional options for user-friendly one-off kernel building:
ba564c
#
ba564c
# Only build the base kernel (--with baseonly):
ba564c
%define with_baseonly  %{?_with_baseonly:     1} %{?!_with_baseonly:     0}
ba564c
# Only build the debug kernel (--with dbgonly):
ba564c
%define with_dbgonly   %{?_with_dbgonly:      1} %{?!_with_dbgonly:      0}
ba564c
# Control whether we perform a compat. check against published ABI.
ba564c
%define with_kabichk   %{?_without_kabichk:   0} %{?!_without_kabichk:   1}
ba564c
# Control whether we perform a compat. check against DUP ABI.
ba564c
%define with_kabidupchk %{?_with_kabidupchk:  1} %{?!_with_kabidupchk:   0}
ba564c
#
ba564c
# Control whether to run an extensive DWARF based kABI check.
ba564c
# Note that this option needs to have baseline setup in SOURCE300.
ba564c
%define with_kabidwchk %{?_without_kabidwchk: 0} %{?!_without_kabidwchk: 1}
ba564c
%define with_kabidw_base %{?_with_kabidw_base: 1} %{?!_with_kabidw_base: 0}
ba564c
#
ba564c
# should we do C=1 builds with sparse
ba564c
%define with_sparse    %{?_with_sparse:       1} %{?!_with_sparse:       0}
ba564c
#
ba564c
# Cross compile requested?
ba564c
%define with_cross    %{?_with_cross:         1} %{?!_with_cross:        0}
ba564c
#
ba564c
# build a release kernel on rawhide
ba564c
%define with_release   %{?_with_release:      1} %{?!_with_release:      0}
ba564c
ba564c
# The kernel tarball/base version
ba564c
%define kversion 4.18
ba564c
ba564c
%define with_gcov %{?_with_gcov: 1} %{?!_with_gcov: 0}
ba564c
ba564c
# turn off debug kernel and kabichk for gcov builds
ba564c
%if %{with_gcov}
ba564c
%define with_debug 0
ba564c
%define with_kabichk 0
ba564c
%define with_kabidupchk 0
ba564c
%define with_kabidwchk 0
ba564c
%endif
ba564c
ba564c
# turn off kABI DWARF-based check if we're generating the base dataset
ba564c
%if %{with_kabidw_base}
ba564c
%define with_kabidwchk 0
ba564c
%endif
ba564c
74e6ae
# kpatch_kcflags are extra compiler flags applied to base kernel
74e6ae
# -fdump-ipa-clones is enabled only for base kernels on selected arches
74e6ae
%define with_ipaclones %{?_without_ipaclones: 0} %{?!_without_ipaclones: 1}
74e6ae
%if %{with_ipaclones}
74e6ae
%ifarch x86_64 ppc64le
74e6ae
%define kpatch_kcflags -fdump-ipa-clones
74e6ae
%else
74e6ae
%define with_ipaclones 0
74e6ae
%endif
74e6ae
%endif
74e6ae
ba564c
%define make_target bzImage
ba564c
%define image_install_path boot
ba564c
ba564c
%define KVERREL %{version}-%{release}.%{_target_cpu}
ba564c
%define KVERREL_RE %(echo %KVERREL | sed 's/+/[+]/g')
ba564c
%define hdrarch %_target_cpu
ba564c
%define asmarch %_target_cpu
ba564c
ba564c
%if !%{with_debuginfo}
ba564c
%define _enable_debug_packages 0
ba564c
%endif
ba564c
%define debuginfodir /usr/lib/debug
ba564c
# Needed because we override almost everything involving build-ids
ba564c
# and debuginfo generation. Currently we rely on the old alldebug setting.
ba564c
%global _build_id_links alldebug
ba564c
ba564c
# if requested, only build base kernel
ba564c
%if %{with_baseonly}
ba564c
%define with_debug 0
ba564c
%endif
ba564c
ba564c
# if requested, only build debug kernel
ba564c
%if %{with_dbgonly}
ba564c
%define with_up 0
ba564c
%define with_tools 0
ba564c
%define with_perf 0
ba564c
%define with_bpftool 0
ba564c
%endif
ba564c
ba564c
# turn off kABI DUP check and DWARF-based check if kABI check is disabled
ba564c
%if !%{with_kabichk}
ba564c
%define with_kabidupchk 0
ba564c
%define with_kabidwchk 0
ba564c
%endif
ba564c
ba564c
%ifnarch noarch
ba564c
%define with_kernel_abi_whitelists 0
ba564c
%endif
ba564c
ba564c
# Overrides for generic default options
ba564c
ba564c
# only package docs noarch
ba564c
%ifnarch noarch
ba564c
%define with_doc 0
ba564c
%define doc_build_fail true
ba564c
%endif
ba564c
ba564c
# don't build noarch kernels or headers (duh)
ba564c
%ifarch noarch
ba564c
%define with_up 0
ba564c
%define with_headers 0
ba564c
%define with_cross_headers 0
ba564c
%define with_tools 0
ba564c
%define with_perf 0
ba564c
%define with_bpftool 0
74e6ae
%define with_selftests 0
ba564c
%define with_debug 0
ba564c
%define all_arch_configs kernel-%{version}-*.config
ba564c
%endif
ba564c
ba564c
# sparse blows up on ppc
ba564c
%ifnarch ppc64le
ba564c
%define with_sparse 0
ba564c
%endif
ba564c
ba564c
# zfcpdump mechanism is s390 only
ba564c
%ifnarch s390x
ba564c
%define with_zfcpdump 0
ba564c
%endif
ba564c
ba564c
# Per-arch tweaks
ba564c
ba564c
%ifarch i686
ba564c
%define asmarch x86
ba564c
%define hdrarch i386
ba564c
%endif
ba564c
ba564c
%ifarch x86_64
ba564c
%define asmarch x86
ba564c
%define all_arch_configs kernel-%{version}-x86_64*.config
ba564c
%define kernel_image arch/x86/boot/bzImage
ba564c
%endif
ba564c
ba564c
%ifarch ppc64le
ba564c
%define asmarch powerpc
ba564c
%define hdrarch powerpc
ba564c
%define make_target vmlinux
ba564c
%define kernel_image vmlinux
ba564c
%define kernel_image_elf 1
ba564c
%define all_arch_configs kernel-%{version}-ppc64le*.config
ba564c
%define kcflags -O3
ba564c
%endif
ba564c
ba564c
%ifarch s390x
ba564c
%define asmarch s390
ba564c
%define hdrarch s390
ba564c
%define all_arch_configs kernel-%{version}-s390x.config
ba564c
%define kernel_image arch/s390/boot/bzImage
ba564c
%endif
ba564c
ba564c
%ifarch aarch64
ba564c
%define all_arch_configs kernel-%{version}-aarch64*.config
ba564c
%define asmarch arm64
ba564c
%define hdrarch arm64
ba564c
%define make_target Image.gz
ba564c
%define kernel_image arch/arm64/boot/Image.gz
ba564c
%endif
ba564c
ba564c
# To temporarily exclude an architecture from being built, add it to
ba564c
# %%nobuildarches. Do _NOT_ use the ExclusiveArch: line, because if we
ba564c
# don't build kernel-headers then the new build system will no longer let
ba564c
# us use the previous build of that package -- it'll just be completely AWOL.
ba564c
# Which is a BadThing(tm).
ba564c
ba564c
# We only build kernel-headers on the following...
ba564c
%define nobuildarches i386 i686
ba564c
ba564c
%ifarch %nobuildarches
ba564c
%define with_up 0
ba564c
%define with_debug 0
ba564c
%define with_debuginfo 0
ba564c
%define with_perf 0
ba564c
%define with_tools 0
ba564c
%define with_bpftool 0
74e6ae
%define with_selftests 0
ba564c
%define _enable_debug_packages 0
ba564c
%endif
ba564c
ba564c
# Architectures we build tools/cpupower on
ba564c
%define cpupowerarchs x86_64 ppc64le aarch64
ba564c
ba564c
ba564c
#
ba564c
# Packages that need to be installed before the kernel is, because the %%post
ba564c
# scripts use them.
ba564c
#
ba564c
%define kernel_prereq  coreutils, systemd >= 203-2, /usr/bin/kernel-install
ba564c
%define initrd_prereq  dracut >= 027
ba564c
ba564c
ba564c
Name: kernel%{?variant}
ba564c
Group: System Environment/Kernel
ba564c
License: GPLv2 and Redistributable, no modification permitted
ba564c
URL: http://www.kernel.org/
ba564c
Version: %{rpmversion}
ba564c
Release: %{pkg_release}
74e6ae
Summary: The Linux kernel, based on version %{version}, heavily modified with backports
ba564c
# DO NOT CHANGE THE 'ExclusiveArch' LINE TO TEMPORARILY EXCLUDE AN ARCHITECTURE BUILD.
ba564c
# SET %%nobuildarches (ABOVE) INSTEAD
ba564c
ExclusiveArch: noarch i386 i686 x86_64 s390x aarch64 ppc64le
ba564c
ExclusiveOS: Linux
ba564c
%ifnarch %{nobuildarches}
ba564c
Requires: kernel-core-uname-r = %{KVERREL}%{?variant}
ba564c
Requires: kernel-modules-uname-r = %{KVERREL}%{?variant}
ba564c
%endif
ba564c
ba564c
ba564c
#
ba564c
# List the packages used during the kernel build
ba564c
#
ba564c
BuildRequires: kmod, patch, bash, sh-utils, tar, git
ba564c
BuildRequires: bzip2, xz, findutils, gzip, m4, perl-interpreter, perl-Carp, perl-devel, perl-generators, make, diffutils, gawk
ba564c
BuildRequires: gcc, binutils, redhat-rpm-config, hmaccalc, python3-devel
ba564c
BuildRequires: net-tools, hostname, bc, bison, flex, elfutils-devel
ba564c
%if %{with_doc}
ba564c
BuildRequires: xmlto, asciidoc, python3-sphinx
ba564c
%endif
ba564c
%if %{with_sparse}
ba564c
BuildRequires: sparse
ba564c
%endif
ba564c
%if %{with_perf}
ba564c
BuildRequires: zlib-devel binutils-devel newt-devel perl(ExtUtils::Embed) bison flex xz-devel
ba564c
BuildRequires: audit-libs-devel
ba564c
BuildRequires: java-devel
ba564c
%ifnarch s390x
ba564c
BuildRequires: numactl-devel
ba564c
%endif
ba564c
%endif
ba564c
%if %{with_tools}
ba564c
BuildRequires: gettext ncurses-devel
ba564c
%ifnarch s390x
ba564c
BuildRequires: pciutils-devel
ba564c
%endif
ba564c
%endif
ba564c
%if %{with_bpftool}
ba564c
BuildRequires: python3-docutils
ba564c
BuildRequires: zlib-devel binutils-devel
ba564c
%endif
74e6ae
%if %{with_selftests}
74e6ae
BuildRequires: libcap-devel libcap-ng-devel llvm-toolset numactl-devel rsync
ba564c
%endif
ba564c
BuildConflicts: rhbuildsys(DiskFree) < 500Mb
ba564c
%if %{with_debuginfo}
ba564c
BuildRequires: rpm-build, elfutils
ba564c
BuildConflicts: rpm < 4.13.0.1-19
ba564c
# Most of these should be enabled after more investigation
ba564c
%undefine _include_minidebuginfo
ba564c
%undefine _find_debuginfo_dwz_opts
ba564c
%undefine _unique_build_ids
ba564c
%undefine _unique_debug_names
ba564c
%undefine _unique_debug_srcs
ba564c
%undefine _debugsource_packages
ba564c
%undefine _debuginfo_subpackages
ba564c
%global _find_debuginfo_opts -r
ba564c
%global _missing_build_ids_terminate_build 1
ba564c
%global _no_recompute_build_ids 1
ba564c
%endif
ba564c
%if %{with_kabidwchk} || %{with_kabidw_base}
ba564c
BuildRequires: kabi-dw
ba564c
%endif
ba564c
ba564c
%if %{signkernel}%{signmodules}
ba564c
BuildRequires: openssl openssl-devel
ba564c
%if %{signkernel}
74e6ae
%ifarch x86_64 aarch64
ba564c
BuildRequires: nss-tools
ba564c
BuildRequires: pesign >= 0.10-4
ba564c
%endif
ba564c
%endif
74e6ae
%endif
ba564c
ba564c
%if %{with_cross}
ba564c
BuildRequires: binutils-%{_build_arch}-linux-gnu, gcc-%{_build_arch}-linux-gnu
ba564c
%define cross_opts CROSS_COMPILE=%{_build_arch}-linux-gnu-
ba564c
%endif
ba564c
ba564c
# These below are required to build man pages
ba564c
%if %{with_perf}
ba564c
BuildRequires: xmlto
ba564c
%endif
ba564c
%if %{with_perf} || %{with_tools}
ba564c
BuildRequires: asciidoc
ba564c
%endif
ba564c
ba564c
Source0: linux-%{rpmversion}-%{pkgrelease}.tar.xz
ba564c
ba564c
Source11: x509.genkey
74e6ae
74e6ae
# Name of the packaged file containing signing key
74e6ae
%ifarch ppc64le
74e6ae
%define signing_key_filename kernel-signing-ppc.cer
74e6ae
%endif
74e6ae
%ifarch s390x
74e6ae
%define signing_key_filename kernel-signing-s390.cer
74e6ae
%endif
74e6ae
ba564c
%if %{?released_kernel}
74e6ae
3fb3f3
Source12: securebootca.cer
3fb3f3
Source13: secureboot.cer
3fb3f3
Source14: secureboot_s390.cer
3fb3f3
Source15: secureboot_ppc.cer
74e6ae
74e6ae
%define secureboot_ca %{SOURCE12}
74e6ae
%ifarch x86_64 aarch64
74e6ae
%define secureboot_key %{SOURCE13}
3fb3f3
%define pesign_name redhatsecureboot301
3fb3f3
%endif
3fb3f3
%ifarch s390x
3fb3f3
%define secureboot_key %{SOURCE14}
3fb3f3
%define pesign_name redhatsecureboot302
3fb3f3
%endif
3fb3f3
%ifarch ppc64le
3fb3f3
%define secureboot_key %{SOURCE15}
3fb3f3
%define pesign_name redhatsecureboot303
74e6ae
%endif
74e6ae
74e6ae
%else # released_kernel
74e6ae
3fb3f3
Source12: redhatsecurebootca2.cer
3fb3f3
Source13: redhatsecureboot003.cer
74e6ae
74e6ae
%define secureboot_ca %{SOURCE12}
74e6ae
%define secureboot_key %{SOURCE13}
3fb3f3
%define pesign_name redhatsecureboot003
74e6ae
74e6ae
%endif # released_kernel
74e6ae
ba564c
Source16: mod-extra.list
74e6ae
Source17: mod-blacklist.sh
ba564c
Source18: mod-sign.sh
74e6ae
Source80: parallel_xz.sh
ba564c
Source90: filter-x86_64.sh
ba564c
Source93: filter-aarch64.sh
ba564c
Source96: filter-ppc64le.sh
ba564c
Source97: filter-s390x.sh
ba564c
Source99: filter-modules.sh
ba564c
%define modsign_cmd %{SOURCE18}
ba564c
ba564c
Source20: kernel-aarch64.config
ba564c
Source21: kernel-aarch64-debug.config
ba564c
Source32: kernel-ppc64le.config
ba564c
Source33: kernel-ppc64le-debug.config
ba564c
Source36: kernel-s390x.config
ba564c
Source37: kernel-s390x-debug.config
ba564c
Source38: kernel-s390x-zfcpdump.config
ba564c
Source39: kernel-x86_64.config
ba564c
Source40: kernel-x86_64-debug.config
ba564c
Source41: generate_all_configs.sh
ba564c
ba564c
Source42: process_configs.sh
ba564c
Source43: generate_bls_conf.sh
ba564c
74e6ae
Source44: mod-internal.list
74e6ae
ba564c
Source200: check-kabi
ba564c
ba564c
Source201: Module.kabi_aarch64
ba564c
Source202: Module.kabi_ppc64le
ba564c
Source203: Module.kabi_s390x
ba564c
Source204: Module.kabi_x86_64
ba564c
ba564c
Source210: Module.kabi_dup_aarch64
ba564c
Source211: Module.kabi_dup_ppc64le
ba564c
Source212: Module.kabi_dup_s390x
ba564c
Source213: Module.kabi_dup_x86_64
ba564c
ba564c
Source300: kernel-abi-whitelists-%{rpmversion}-%{distro_build}.tar.bz2
ba564c
Source301: kernel-kabi-dw-%{rpmversion}-%{distro_build}.tar.bz2
ba564c
ba564c
# Sources for kernel-tools
ba564c
Source2000: cpupower.service
ba564c
Source2001: cpupower.config
ba564c
ba564c
## Patches needed for building this package
86247d
86247d
# empty final patch to facilitate testing of kernel patches
86247d
Patch999999: linux-kernel-test.patch
ba564c
ba564c
# END OF PATCH DEFINITIONS
ba564c
ba564c
BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root
ba564c
ba564c
%description
3fb3f3
This is the package which provides the Linux kernel for Red Hat Enterprise
74e6ae
Linux. It is based on upstream Linux at version %{version} and maintains kABI
74e6ae
compatibility of a set of approved symbols, however it is heavily modified with
74e6ae
backports and fixes pulled from newer upstream Linux kernel releases. This means
74e6ae
this is not a %{version} kernel anymore: it includes several components which come
74e6ae
from newer upstream linux versions, while maintaining a well tested and stable
74e6ae
core. Some of the components/backports that may be pulled in are: changes like
74e6ae
updates to the core kernel (eg.: scheduler, cgroups, memory management, security
74e6ae
fixes and features), updates to block layer, supported filesystems, major driver
3fb3f3
updates for supported hardware in Red Hat Enterprise Linux, enhancements for
74e6ae
enterprise customers, etc.
ba564c
ba564c
#
ba564c
# This macro does requires, provides, conflicts, obsoletes for a kernel package.
ba564c
#	%%kernel_reqprovconf <subpackage>
ba564c
# It uses any kernel_<subpackage>_conflicts and kernel_<subpackage>_obsoletes
ba564c
# macros defined above.
ba564c
#
ba564c
%define kernel_reqprovconf \
ba564c
Provides: kernel = %{rpmversion}-%{pkg_release}\
ba564c
Provides: kernel-%{_target_cpu} = %{rpmversion}-%{pkg_release}%{?1:+%{1}}\
ba564c
Provides: kernel-drm-nouveau = 16\
ba564c
Provides: kernel-uname-r = %{KVERREL}%{?variant}%{?1:+%{1}}\
ba564c
Requires(pre): %{kernel_prereq}\
ba564c
Requires(pre): %{initrd_prereq}\
ba564c
Requires(pre): linux-firmware >= 20150904-56.git6ebf5d57\
ba564c
Requires(preun): systemd >= 200\
ba564c
Conflicts: xfsprogs < 4.3.0-1\
ba564c
Conflicts: xorg-x11-drv-vmmouse < 13.0.99\
ba564c
%{expand:%%{?kernel%{?1:_%{1}}_conflicts:Conflicts: %%{kernel%{?1:_%{1}}_conflicts}}}\
ba564c
%{expand:%%{?kernel%{?1:_%{1}}_obsoletes:Obsoletes: %%{kernel%{?1:_%{1}}_obsoletes}}}\
ba564c
%{expand:%%{?kernel%{?1:_%{1}}_provides:Provides: %%{kernel%{?1:_%{1}}_provides}}}\
ba564c
# We can't let RPM do the dependencies automatic because it'll then pick up\
ba564c
# a correct but undesirable perl dependency from the module headers which\
ba564c
# isn't required for the kernel proper to function\
ba564c
AutoReq: no\
ba564c
AutoProv: yes\
ba564c
%{nil}
ba564c
ba564c
ba564c
%package doc
ba564c
Summary: Various documentation bits found in the kernel source
ba564c
Group: Documentation
ba564c
%description doc
ba564c
This package contains documentation files from the kernel
ba564c
source. Various bits of information about the Linux kernel and the
ba564c
device drivers shipped with it are documented in these files.
ba564c
ba564c
You'll want to install this package if you need a reference to the
ba564c
options that can be passed to Linux kernel modules at load time.
ba564c
ba564c
ba564c
%package headers
ba564c
Summary: Header files for the Linux kernel for use by glibc
ba564c
Group: Development/System
ba564c
Obsoletes: glibc-kernheaders < 3.0-46
ba564c
Provides: glibc-kernheaders = 3.0-46
ba564c
%if "0%{?variant}"
ba564c
Obsoletes: kernel-headers < %{rpmversion}-%{pkg_release}
ba564c
Provides: kernel-headers = %{rpmversion}-%{pkg_release}
ba564c
%endif
ba564c
%description headers
ba564c
Kernel-headers includes the C header files that specify the interface
ba564c
between the Linux kernel and userspace libraries and programs.  The
ba564c
header files define structures and constants that are needed for
ba564c
building most standard programs and are also needed for rebuilding the
ba564c
glibc package.
ba564c
ba564c
%package cross-headers
ba564c
Summary: Header files for the Linux kernel for use by cross-glibc
ba564c
Group: Development/System
ba564c
%description cross-headers
ba564c
Kernel-cross-headers includes the C header files that specify the interface
ba564c
between the Linux kernel and userspace libraries and programs.  The
ba564c
header files define structures and constants that are needed for
ba564c
building most standard programs and are also needed for rebuilding the
ba564c
cross-glibc package.
ba564c
ba564c
ba564c
%package debuginfo-common-%{_target_cpu}
ba564c
Summary: Kernel source files used by %{name}-debuginfo packages
ba564c
Group: Development/Debug
ba564c
Provides: installonlypkg(kernel)
ba564c
%description debuginfo-common-%{_target_cpu}
ba564c
This package is required by %{name}-debuginfo subpackages.
ba564c
It provides the kernel source files common to all builds.
ba564c
ba564c
%if %{with_perf}
ba564c
%package -n perf
ba564c
Summary: Performance monitoring for the Linux kernel
ba564c
Group: Development/System
ba564c
License: GPLv2
ba564c
%description -n perf
ba564c
This package contains the perf tool, which enables performance monitoring
ba564c
of the Linux kernel.
ba564c
ba564c
%package -n perf-debuginfo
ba564c
Summary: Debug information for package perf
ba564c
Group: Development/Debug
ba564c
Requires: %{name}-debuginfo-common-%{_target_cpu} = %{version}-%{release}
ba564c
AutoReqProv: no
ba564c
%description -n perf-debuginfo
ba564c
This package provides debug information for the perf package.
ba564c
ba564c
# Note that this pattern only works right to match the .build-id
ba564c
# symlinks because of the trailing nonmatching alternation and
ba564c
# the leading .*, because of find-debuginfo.sh's buggy handling
ba564c
# of matching the pattern against the symlinks file.
ba564c
%{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '.*%%{_bindir}/perf(\.debug)?|.*%%{_libexecdir}/perf-core/.*|.*%%{_libdir}/traceevent/plugins/.*|.*%%{_libdir}/libperf-jvmti.so(\.debug)?|XXX' -o perf-debuginfo.list}
ba564c
ba564c
%package -n python3-perf
ba564c
Summary: Python bindings for apps which will manipulate perf events
ba564c
Group: Development/Libraries
ba564c
%description -n python3-perf
ba564c
The python3-perf package contains a module that permits applications
ba564c
written in the Python programming language to use the interface
ba564c
to manipulate perf events.
ba564c
ba564c
%package -n python3-perf-debuginfo
ba564c
Summary: Debug information for package perf python bindings
ba564c
Group: Development/Debug
ba564c
Requires: %{name}-debuginfo-common-%{_target_cpu} = %{version}-%{release}
ba564c
AutoReqProv: no
ba564c
%description -n python3-perf-debuginfo
ba564c
This package provides debug information for the perf python bindings.
ba564c
ba564c
# the python_sitearch macro should already be defined from above
ba564c
%{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '.*%%{python3_sitearch}/perf.*so(\.debug)?|XXX' -o python3-perf-debuginfo.list}
ba564c
ba564c
ba564c
%endif # with_perf
ba564c
ba564c
%if %{with_tools}
ba564c
%package -n kernel-tools
ba564c
Summary: Assortment of tools for the Linux kernel
ba564c
Group: Development/System
ba564c
License: GPLv2
ba564c
%ifarch %{cpupowerarchs}
ba564c
Provides:  cpupowerutils = 1:009-0.6.p1
ba564c
Obsoletes: cpupowerutils < 1:009-0.6.p1
ba564c
Provides:  cpufreq-utils = 1:009-0.6.p1
ba564c
Provides:  cpufrequtils = 1:009-0.6.p1
ba564c
Obsoletes: cpufreq-utils < 1:009-0.6.p1
ba564c
Obsoletes: cpufrequtils < 1:009-0.6.p1
ba564c
Obsoletes: cpuspeed < 1:1.5-16
ba564c
Requires: kernel-tools-libs = %{version}-%{release}
ba564c
%endif
ba564c
%define __requires_exclude ^%{_bindir}/python
ba564c
%description -n kernel-tools
ba564c
This package contains the tools/ directory from the kernel source
ba564c
and the supporting documentation.
ba564c
ba564c
%package -n kernel-tools-libs
ba564c
Summary: Libraries for the kernels-tools
ba564c
Group: Development/System
ba564c
License: GPLv2
ba564c
%description -n kernel-tools-libs
ba564c
This package contains the libraries built from the tools/ directory
ba564c
from the kernel source.
ba564c
ba564c
%package -n kernel-tools-libs-devel
ba564c
Summary: Assortment of tools for the Linux kernel
ba564c
Group: Development/System
ba564c
License: GPLv2
ba564c
Requires: kernel-tools = %{version}-%{release}
ba564c
%ifarch %{cpupowerarchs}
ba564c
Provides:  cpupowerutils-devel = 1:009-0.6.p1
ba564c
Obsoletes: cpupowerutils-devel < 1:009-0.6.p1
ba564c
%endif
ba564c
Requires: kernel-tools-libs = %{version}-%{release}
ba564c
Provides: kernel-tools-devel
ba564c
%description -n kernel-tools-libs-devel
ba564c
This package contains the development files for the tools/ directory from
ba564c
the kernel source.
ba564c
ba564c
%package -n kernel-tools-debuginfo
ba564c
Summary: Debug information for package kernel-tools
ba564c
Group: Development/Debug
ba564c
Requires: %{name}-debuginfo-common-%{_target_cpu} = %{version}-%{release}
ba564c
AutoReqProv: no
ba564c
%description -n kernel-tools-debuginfo
ba564c
This package provides debug information for package kernel-tools.
ba564c
ba564c
# Note that this pattern only works right to match the .build-id
ba564c
# symlinks because of the trailing nonmatching alternation and
ba564c
# the leading .*, because of find-debuginfo.sh's buggy handling
ba564c
# of matching the pattern against the symlinks file.
ba564c
%{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '.*%%{_bindir}/centrino-decode(\.debug)?|.*%%{_bindir}/powernow-k8-decode(\.debug)?|.*%%{_bindir}/cpupower(\.debug)?|.*%%{_libdir}/libcpupower.*|.*%%{_bindir}/turbostat(\.debug)?|.*%%{_bindir}/x86_energy_perf_policy(\.debug)?|.*%%{_bindir}/tmon(\.debug)?|.*%%{_bindir}/lsgpio(\.debug)?|.*%%{_bindir}/gpio-hammer(\.debug)?|.*%%{_bindir}/gpio-event-mon(\.debug)?|.*%%{_bindir}/iio_event_monitor(\.debug)?|.*%%{_bindir}/iio_generic_buffer(\.debug)?|.*%%{_bindir}/lsiio(\.debug)?|XXX' -o kernel-tools-debuginfo.list}
ba564c
ba564c
%endif # with_tools
ba564c
ba564c
%if %{with_bpftool}
ba564c
ba564c
%package -n bpftool
ba564c
Summary: Inspection and simple manipulation of eBPF programs and maps
ba564c
License: GPLv2
ba564c
%description -n bpftool
ba564c
This package contains the bpftool, which allows inspection and simple
ba564c
manipulation of eBPF programs and maps.
ba564c
ba564c
%package -n bpftool-debuginfo
ba564c
Summary: Debug information for package bpftool
ba564c
Group: Development/Debug
ba564c
Requires: %{name}-debuginfo-common-%{_target_cpu} = %{version}-%{release}
ba564c
AutoReqProv: no
ba564c
%description -n bpftool-debuginfo
ba564c
This package provides debug information for the bpftool package.
ba564c
ba564c
%{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '.*%%{_sbindir}/bpftool(\.debug)?|XXX' -o bpftool-debuginfo.list}
ba564c
ba564c
%endif # with_bpftool
ba564c
74e6ae
%if %{with_selftests}
ba564c
74e6ae
%package selftests-internal
74e6ae
Summary: Kernel samples and selftests
ba564c
License: GPLv2
74e6ae
Requires: binutils, bpftool, iproute-tc, nmap-ncat
74e6ae
%description selftests-internal
74e6ae
Kernel sample programs and selftests.
74e6ae
74e6ae
# Note that this pattern only works right to match the .build-id
74e6ae
# symlinks because of the trailing nonmatching alternation and
74e6ae
# the leading .*, because of find-debuginfo.sh's buggy handling
74e6ae
# of matching the pattern against the symlinks file.
74e6ae
%{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '.*%%{_libexecdir}/(ksamples|kselftests)/.*|XXX' -o selftests-debuginfo.list}
ba564c
74e6ae
%endif # with_selftests
ba564c
ba564c
%if %{with_gcov}
ba564c
%package gcov
ba564c
Summary: gcov graph and source files for coverage data collection.
ba564c
Group: Development/System
ba564c
%description gcov
ba564c
kernel-gcov includes the gcov graph and source files for gcov coverage collection.
ba564c
%endif
ba564c
ba564c
%package -n kernel-abi-whitelists
3fb3f3
Summary: The Red Hat Enterprise Linux kernel ABI symbol whitelists
ba564c
Group: System Environment/Kernel
ba564c
AutoReqProv: no
ba564c
%description -n kernel-abi-whitelists
3fb3f3
The kABI package contains information pertaining to the Red Hat Enterprise
ba564c
Linux kernel ABI, including lists of kernel symbols that are needed by
ba564c
external Linux kernel modules, and a yum plugin to aid enforcement.
ba564c
ba564c
%if %{with_kabidw_base}
ba564c
%package kabidw-base
ba564c
Summary: The baseline dataset for kABI verification using DWARF data
ba564c
Group: System Environment/Kernel
ba564c
AutoReqProv: no
ba564c
%description kabidw-base
3fb3f3
The kabidw-base package contains data describing the current ABI of the Red Hat
3fb3f3
Enterprise Linux kernel, suitable for the kabi-dw tool.
ba564c
%endif
ba564c
ba564c
#
ba564c
# This macro creates a kernel-<subpackage>-debuginfo package.
ba564c
#	%%kernel_debuginfo_package <subpackage>
ba564c
#
ba564c
%define kernel_debuginfo_package() \
ba564c
%package %{?1:%{1}-}debuginfo\
ba564c
Summary: Debug information for package %{name}%{?1:-%{1}}\
ba564c
Group: Development/Debug\
ba564c
Requires: %{name}-debuginfo-common-%{_target_cpu} = %{version}-%{release}\
ba564c
Provides: %{name}%{?1:-%{1}}-debuginfo-%{_target_cpu} = %{version}-%{release}\
ba564c
Provides: installonlypkg(kernel)\
ba564c
AutoReqProv: no\
ba564c
%description %{?1:%{1}-}debuginfo\
ba564c
This package provides debug information for package %{name}%{?1:-%{1}}.\
ba564c
This is required to use SystemTap with %{name}%{?1:-%{1}}-%{KVERREL}.\
ba564c
%{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '/.*/%%{KVERREL_RE}%{?1:[+]%{1}}/.*|/.*%%{KVERREL_RE}%{?1:\+%{1}}(\.debug)?' -o debuginfo%{?1}.list}\
ba564c
%{nil}
ba564c
ba564c
#
ba564c
# This macro creates a kernel-<subpackage>-devel package.
ba564c
#	%%kernel_devel_package <subpackage> <pretty-name>
ba564c
#
ba564c
%define kernel_devel_package() \
ba564c
%package %{?1:%{1}-}devel\
ba564c
Summary: Development package for building kernel modules to match the %{?2:%{2} }kernel\
ba564c
Group: System Environment/Kernel\
ba564c
Provides: kernel%{?1:-%{1}}-devel-%{_target_cpu} = %{version}-%{release}\
ba564c
Provides: kernel-devel-%{_target_cpu} = %{version}-%{release}%{?1:+%{1}}\
ba564c
Provides: kernel-devel-uname-r = %{KVERREL}%{?variant}%{?1:+%{1}}\
ba564c
Provides: installonlypkg(kernel)\
ba564c
AutoReqProv: no\
ba564c
Requires(pre): findutils\
ba564c
Requires: findutils\
ba564c
Requires: perl-interpreter\
ba564c
%description %{?1:%{1}-}devel\
ba564c
This package provides kernel headers and makefiles sufficient to build modules\
ba564c
against the %{?2:%{2} }kernel package.\
ba564c
%{nil}
ba564c
ba564c
#
74e6ae
# kernel-<variant>-ipaclones-internal package
74e6ae
#
74e6ae
%define kernel_ipaclones_package() \
74e6ae
%package %{?1:%{1}-}ipaclones-internal\
74e6ae
Summary: *.ipa-clones files generated by -fdump-ipa-clones for kernel%{?1:-%{1}}\
74e6ae
Group: System Environment/Kernel\
74e6ae
AutoReqProv: no\
74e6ae
%description %{?1:%{1}-}ipaclones-internal\
74e6ae
This package provides *.ipa-clones files.\
74e6ae
%{nil}
74e6ae
74e6ae
#
74e6ae
# This macro creates a kernel-<subpackage>-modules-internal package.
74e6ae
#	%%kernel_modules_internal_package <subpackage> <pretty-name>
74e6ae
#
74e6ae
%define kernel_modules_internal_package() \
74e6ae
%package %{?1:%{1}-}modules-internal\
74e6ae
Summary: Extra kernel modules to match the %{?2:%{2} }kernel\
74e6ae
Group: System Environment/Kernel\
74e6ae
Provides: kernel%{?1:-%{1}}-modules-internal-%{_target_cpu} = %{version}-%{release}\
74e6ae
Provides: kernel%{?1:-%{1}}-modules-internal-%{_target_cpu} = %{version}-%{release}%{?1:+%{1}}\
74e6ae
Provides: kernel%{?1:-%{1}}-modules-internal = %{version}-%{release}%{?1:+%{1}}\
74e6ae
Provides: installonlypkg(kernel-module)\
74e6ae
Provides: kernel%{?1:-%{1}}-modules-internal-uname-r = %{KVERREL}%{?variant}%{?1:+%{1}}\
74e6ae
Requires: kernel-uname-r = %{KVERREL}%{?variant}%{?1:+%{1}}\
74e6ae
Requires: kernel%{?1:-%{1}}-modules-uname-r = %{KVERREL}%{?variant}%{?1:+%{1}}\
74e6ae
AutoReq: no\
74e6ae
AutoProv: yes\
74e6ae
%description %{?1:%{1}-}modules-internal\
3fb3f3
This package provides kernel modules for the %{?2:%{2} }kernel package for Red Hat internal usage.\
74e6ae
%{nil}
74e6ae
74e6ae
#
ba564c
# This macro creates a kernel-<subpackage>-modules-extra package.
ba564c
#	%%kernel_modules_extra_package <subpackage> <pretty-name>
ba564c
#
ba564c
%define kernel_modules_extra_package() \
ba564c
%package %{?1:%{1}-}modules-extra\
ba564c
Summary: Extra kernel modules to match the %{?2:%{2} }kernel\
ba564c
Group: System Environment/Kernel\
ba564c
Provides: kernel%{?1:-%{1}}-modules-extra-%{_target_cpu} = %{version}-%{release}\
ba564c
Provides: kernel%{?1:-%{1}}-modules-extra-%{_target_cpu} = %{version}-%{release}%{?1:+%{1}}\
ba564c
Provides: kernel%{?1:-%{1}}-modules-extra = %{version}-%{release}%{?1:+%{1}}\
ba564c
Provides: installonlypkg(kernel-module)\
ba564c
Provides: kernel%{?1:-%{1}}-modules-extra-uname-r = %{KVERREL}%{?variant}%{?1:+%{1}}\
ba564c
Requires: kernel-uname-r = %{KVERREL}%{?variant}%{?1:+%{1}}\
ba564c
Requires: kernel%{?1:-%{1}}-modules-uname-r = %{KVERREL}%{?variant}%{?1:+%{1}}\
ba564c
AutoReq: no\
ba564c
AutoProv: yes\
ba564c
%description %{?1:%{1}-}modules-extra\
ba564c
This package provides less commonly used kernel modules for the %{?2:%{2} }kernel package.\
ba564c
%{nil}
ba564c
ba564c
#
ba564c
# This macro creates a kernel-<subpackage>-modules package.
ba564c
#	%%kernel_modules_package <subpackage> <pretty-name>
ba564c
#
ba564c
%define kernel_modules_package() \
ba564c
%package %{?1:%{1}-}modules\
ba564c
Summary: kernel modules to match the %{?2:%{2}-}core kernel\
ba564c
Group: System Environment/Kernel\
ba564c
Provides: kernel%{?1:-%{1}}-modules-%{_target_cpu} = %{version}-%{release}\
ba564c
Provides: kernel-modules-%{_target_cpu} = %{version}-%{release}%{?1:+%{1}}\
ba564c
Provides: kernel-modules = %{version}-%{release}%{?1:+%{1}}\
ba564c
Provides: installonlypkg(kernel-module)\
ba564c
Provides: kernel%{?1:-%{1}}-modules-uname-r = %{KVERREL}%{?variant}%{?1:+%{1}}\
ba564c
Requires: kernel-uname-r = %{KVERREL}%{?variant}%{?1:+%{1}}\
ba564c
AutoReq: no\
ba564c
AutoProv: yes\
ba564c
%description %{?1:%{1}-}modules\
ba564c
This package provides commonly used kernel modules for the %{?2:%{2}-}core kernel package.\
ba564c
%{nil}
ba564c
ba564c
#
ba564c
# this macro creates a kernel-<subpackage> meta package.
ba564c
#	%%kernel_meta_package <subpackage>
ba564c
#
ba564c
%define kernel_meta_package() \
ba564c
%package %{1}\
ba564c
summary: kernel meta-package for the %{1} kernel\
ba564c
group: system environment/kernel\
ba564c
Requires: kernel-%{1}-core-uname-r = %{KVERREL}%{?variant}+%{1}\
ba564c
Requires: kernel-%{1}-modules-uname-r = %{KVERREL}%{?variant}+%{1}\
ba564c
Provides: installonlypkg(kernel)\
ba564c
%description %{1}\
ba564c
The meta-package for the %{1} kernel\
ba564c
%{nil}
ba564c
ba564c
#
ba564c
# This macro creates a kernel-<subpackage> and its -devel and -debuginfo too.
ba564c
#	%%define variant_summary The Linux kernel compiled for <configuration>
ba564c
#	%%kernel_variant_package [-n <pretty-name>] <subpackage>
ba564c
#
ba564c
%define kernel_variant_package(n:) \
ba564c
%package %{?1:%{1}-}core\
ba564c
Summary: %{variant_summary}\
ba564c
Group: System Environment/Kernel\
ba564c
Provides: kernel-%{?1:%{1}-}core-uname-r = %{KVERREL}%{?variant}%{?1:+%{1}}\
ba564c
Provides: installonlypkg(kernel)\
ba564c
%{expand:%%kernel_reqprovconf}\
ba564c
%if %{?1:1} %{!?1:0} \
ba564c
%{expand:%%kernel_meta_package %{?1:%{1}}}\
ba564c
%endif\
ba564c
%{expand:%%kernel_devel_package %{?1:%{1}} %{!?{-n}:%{1}}%{?{-n}:%{-n*}}}\
ba564c
%{expand:%%kernel_modules_package %{?1:%{1}} %{!?{-n}:%{1}}%{?{-n}:%{-n*}}}\
ba564c
%{expand:%%kernel_modules_extra_package %{?1:%{1}} %{!?{-n}:%{1}}%{?{-n}:%{-n*}}}\
74e6ae
%{expand:%%kernel_modules_internal_package %{?1:%{1}} %{!?{-n}:%{1}}%{?{-n}:%{-n*}}}\
ba564c
%{expand:%%kernel_debuginfo_package %{?1:%{1}}}\
ba564c
%{nil}
ba564c
ba564c
# Now, each variant package.
ba564c
ba564c
%if %{with_zfcpdump}
ba564c
%define variant_summary The Linux kernel compiled for zfcpdump usage
ba564c
%kernel_variant_package zfcpdump
ba564c
%description zfcpdump-core
ba564c
The kernel package contains the Linux kernel (vmlinuz) for use by the
ba564c
zfcpdump infrastructure.
ba564c
%endif # with_zfcpdump
ba564c
ba564c
%define variant_summary The Linux kernel compiled with extra debugging enabled
ba564c
%kernel_variant_package debug
ba564c
%description debug-core
ba564c
The kernel package contains the Linux kernel (vmlinuz), the core of any
ba564c
Linux operating system.  The kernel handles the basic functions
ba564c
of the operating system:  memory allocation, process allocation, device
ba564c
input and output, etc.
ba564c
ba564c
This variant of the kernel has numerous debugging options enabled.
ba564c
It should only be installed when trying to gather additional information
ba564c
on kernel bugs, as some of these options impact performance noticably.
ba564c
ba564c
# And finally the main -core package
ba564c
ba564c
%define variant_summary The Linux kernel
ba564c
%kernel_variant_package
ba564c
%description core
ba564c
The kernel package contains the Linux kernel (vmlinuz), the core of any
ba564c
Linux operating system.  The kernel handles the basic functions
ba564c
of the operating system: memory allocation, process allocation, device
ba564c
input and output, etc.
ba564c
74e6ae
%if %{with_ipaclones}
74e6ae
%kernel_ipaclones_package
74e6ae
%endif
ba564c
ba564c
%prep
ba564c
# do a few sanity-checks for --with *only builds
ba564c
%if %{with_baseonly}
ba564c
%if !%{with_up}
ba564c
echo "Cannot build --with baseonly, up build is disabled"
ba564c
exit 1
ba564c
%endif
ba564c
%endif
ba564c
ba564c
# more sanity checking; do it quietly
ba564c
if [ "%{patches}" != "%%{patches}" ] ; then
ba564c
  for patch in %{patches} ; do
ba564c
    if [ ! -f $patch ] ; then
ba564c
      echo "ERROR: Patch  ${patch##/*/}  listed in specfile but is missing"
ba564c
      exit 1
ba564c
    fi
ba564c
  done
ba564c
fi 2>/dev/null
ba564c
ba564c
patch_command='patch -p1 -F1 -s'
ba564c
ApplyPatch()
ba564c
{
ba564c
  local patch=$1
ba564c
  shift
ba564c
  if [ ! -f $RPM_SOURCE_DIR/$patch ]; then
ba564c
    exit 1
ba564c
  fi
ba564c
  if ! grep -E "^Patch[0-9]+: $patch\$" %{_specdir}/${RPM_PACKAGE_NAME%%%%%{?variant}}.spec ; then
ba564c
    if [ "${patch:0:8}" != "patch-4." ] ; then
ba564c
      echo "ERROR: Patch  $patch  not listed as a source patch in specfile"
ba564c
      exit 1
ba564c
    fi
ba564c
  fi 2>/dev/null
ba564c
  case "$patch" in
ba564c
  *.bz2) bunzip2 < "$RPM_SOURCE_DIR/$patch" | $patch_command ${1+"$@"} ;;
ba564c
  *.gz)  gunzip  < "$RPM_SOURCE_DIR/$patch" | $patch_command ${1+"$@"} ;;
ba564c
  *.xz)  unxz    < "$RPM_SOURCE_DIR/$patch" | $patch_command ${1+"$@"} ;;
ba564c
  *) $patch_command ${1+"$@"} < "$RPM_SOURCE_DIR/$patch" ;;
ba564c
  esac
ba564c
}
ba564c
ba564c
# don't apply patch if it's empty
ba564c
ApplyOptionalPatch()
ba564c
{
ba564c
  local patch=$1
ba564c
  shift
ba564c
  if [ ! -f $RPM_SOURCE_DIR/$patch ]; then
ba564c
    exit 1
ba564c
  fi
ba564c
  local C=$(wc -l $RPM_SOURCE_DIR/$patch | awk '{print $1}')
ba564c
  if [ "$C" -gt 9 ]; then
ba564c
    ApplyPatch $patch ${1+"$@"}
ba564c
  fi
ba564c
}
ba564c
ba564c
%setup -q -n kernel-%{rpmversion}-%{pkgrelease} -c
ba564c
mv linux-%{rpmversion}-%{pkgrelease} linux-%{KVERREL}
ba564c
ba564c
cd linux-%{KVERREL}
ba564c
86247d
ApplyOptionalPatch linux-kernel-test.patch
6bf75d
ba564c
# END OF PATCH APPLICATIONS
ba564c
ba564c
# Any further pre-build tree manipulations happen here.
ba564c
ba564c
chmod +x scripts/checkpatch.pl
ba564c
mv COPYING COPYING-%{version}
ba564c
ba564c
# This Prevents scripts/setlocalversion from mucking with our version numbers.
ba564c
touch .scmversion
ba564c
ba564c
# Do not use "ambiguous" python shebangs. RHEL 8 now has a new script
ba564c
# (/usr/lib/rpm/redhat/brp-mangle-shebangs), which forces us to specify a
ba564c
# "non-ambiguous" python shebang for scripts we ship in buildroot. This
ba564c
# script throws an error like below:
ba564c
# *** ERROR: ambiguous python shebang in /usr/bin/kvm_stat: #!/usr/bin/python. Change it to python3 (or python2) explicitly.
ba564c
# We patch all sources below for which we got a report/error.
ba564c
pathfix.py -i %{__python3} -p -n \
ba564c
	scripts/show_delta \
ba564c
	scripts/diffconfig \
ba564c
	scripts/bloat-o-meter \
ba564c
	tools/perf/tests/attr.py \
ba564c
	tools/perf/scripts/python/stat-cpi.py \
ba564c
	tools/perf/scripts/python/sched-migration.py \
ba564c
	Documentation
ba564c
74e6ae
%define make make %{?cross_opts} HOSTCFLAGS="%{?build_hostcflags}" HOSTLDFLAGS="%{?build_hostldflags}"
74e6ae
ba564c
# only deal with configs if we are going to build for the arch
ba564c
%ifnarch %nobuildarches
ba564c
ba564c
if [ -L configs ]; then
ba564c
	rm -f configs
ba564c
fi
ba564c
mkdir configs
ba564c
cd configs
ba564c
ba564c
# Drop some necessary files from the source dir into the buildroot
ba564c
cp $RPM_SOURCE_DIR/kernel-*.config .
ba564c
cp %{SOURCE41} .
ba564c
VERSION=%{version} ./generate_all_configs.sh
ba564c
86247d
# Note we need to disable these flags for cross builds because the flags
86247d
# from redhat-rpm-config assume that host == target so target arch
86247d
# flags cause issues with the host compiler.
86247d
%if !%{with_cross}
86247d
%define build_hostcflags  ${RPM_OPT_FLAGS}
86247d
%define build_hostldflags %{__global_ldflags}
86247d
%endif
86247d
ba564c
# enable GCOV kernel config options if gcov is on
ba564c
%if %{with_gcov}
ba564c
for i in *.config
ba564c
do
ba564c
  sed -i 's/# CONFIG_GCOV_KERNEL is not set/CONFIG_GCOV_KERNEL=y\nCONFIG_GCOV_PROFILE_ALL=y\n/' $i
ba564c
done
ba564c
%endif
ba564c
ba564c
cp %{SOURCE42} .
ba564c
./process_configs.sh -w -c kernel %{rpmversion}
ba564c
ba564c
# end of kernel config
ba564c
%endif
ba564c
ba564c
cd ..
ba564c
# # End of Configs stuff
ba564c
ba564c
# get rid of unwanted files resulting from patch fuzz
ba564c
find . \( -name "*.orig" -o -name "*~" \) -exec rm -f {} \; >/dev/null
ba564c
ba564c
# remove unnecessary SCM files
ba564c
find . -name .gitignore -exec rm -f {} \; >/dev/null
ba564c
ba564c
cd ..
ba564c
ba564c
###
ba564c
### build
ba564c
###
ba564c
%build
ba564c
ba564c
%if %{with_sparse}
ba564c
%define sparse_mflags	C=1
ba564c
%endif
ba564c
ba564c
cp_vmlinux()
ba564c
{
ba564c
  eu-strip --remove-comment -o "$2" "$1"
ba564c
}
ba564c
ba564c
BuildKernel() {
ba564c
    MakeTarget=$1
ba564c
    KernelImage=$2
ba564c
    Flavour=$4
ba564c
    DoVDSO=$3
ba564c
    Flav=${Flavour:++${Flavour}}
ba564c
    InstallName=${5:-vmlinuz}
ba564c
ba564c
    DoModules=1
ba564c
    if [ "$Flavour" = "zfcpdump" ]; then
ba564c
	    DoModules=0
ba564c
    fi
ba564c
ba564c
    # Pick the right config file for the kernel we're building
ba564c
    Config=kernel-%{version}-%{_target_cpu}${Flavour:+-${Flavour}}.config
ba564c
    DevelDir=/usr/src/kernels/%{KVERREL}${Flav}
ba564c
ba564c
    # When the bootable image is just the ELF kernel, strip it.
ba564c
    # We already copy the unstripped file into the debuginfo package.
ba564c
    if [ "$KernelImage" = vmlinux ]; then
ba564c
      CopyKernel=cp_vmlinux
ba564c
    else
ba564c
      CopyKernel=cp
ba564c
    fi
ba564c
ba564c
    KernelVer=%{version}-%{release}.%{_target_cpu}${Flav}
ba564c
    echo BUILDING A KERNEL FOR ${Flavour} %{_target_cpu}...
ba564c
ba564c
    # make sure EXTRAVERSION says what we want it to say
ba564c
    perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{release}.%{_target_cpu}${Flav}/" Makefile
ba564c
ba564c
    # and now to start the build process
ba564c
74e6ae
    %{make} -s %{?_smp_mflags} mrproper
ba564c
    cp configs/$Config .config
ba564c
ba564c
    %if %{signkernel}%{signmodules}
ba564c
    cp %{SOURCE11} certs/.
ba564c
    %endif
ba564c
ba564c
    Arch=`head -1 .config | cut -b 3-`
ba564c
    echo USING ARCH=$Arch
ba564c
74e6ae
    KCFLAGS="%{?kcflags}"
74e6ae
74e6ae
    # add kpatch flags for base kernel
74e6ae
    if [ "$Flavour" == "" ]; then
74e6ae
        KCFLAGS="$KCFLAGS %{?kpatch_kcflags}"
74e6ae
    fi
74e6ae
ba564c
    %{make} -s ARCH=$Arch oldnoconfig >/dev/null
74e6ae
    %{make} -s ARCH=$Arch V=1 %{?_smp_mflags} KCFLAGS="$KCFLAGS" WITH_GCOV="%{?with_gcov}" $MakeTarget %{?sparse_mflags} %{?kernel_mflags}
ba564c
    if [ $DoModules -eq 1 ]; then
74e6ae
	%{make} -s ARCH=$Arch V=1 %{?_smp_mflags} KCFLAGS="$KCFLAGS" WITH_GCOV="%{?with_gcov}" modules %{?sparse_mflags} || exit 1
ba564c
    fi
ba564c
ba564c
    mkdir -p $RPM_BUILD_ROOT/%{image_install_path}
ba564c
    mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer
ba564c
%if %{with_debuginfo}
ba564c
    mkdir -p $RPM_BUILD_ROOT%{debuginfodir}/%{image_install_path}
ba564c
%endif
ba564c
ba564c
%ifarch aarch64
ba564c
    %{make} -s ARCH=$Arch V=1 dtbs dtbs_install INSTALL_DTBS_PATH=$RPM_BUILD_ROOT/%{image_install_path}/dtb-$KernelVer
ba564c
    cp -r $RPM_BUILD_ROOT/%{image_install_path}/dtb-$KernelVer $RPM_BUILD_ROOT/lib/modules/$KernelVer/dtb
ba564c
    find arch/$Arch/boot/dts -name '*.dtb' -type f | xargs rm -f
ba564c
%endif
ba564c
ba564c
    # Start installing the results
ba564c
    install -m 644 .config $RPM_BUILD_ROOT/boot/config-$KernelVer
ba564c
    install -m 644 .config $RPM_BUILD_ROOT/lib/modules/$KernelVer/config
ba564c
    install -m 644 System.map $RPM_BUILD_ROOT/boot/System.map-$KernelVer
ba564c
    install -m 644 System.map $RPM_BUILD_ROOT/lib/modules/$KernelVer/System.map
ba564c
ba564c
    # We estimate the size of the initramfs because rpm needs to take this size
ba564c
    # into consideration when performing disk space calculations. (See bz #530778)
ba564c
    dd if=/dev/zero of=$RPM_BUILD_ROOT/boot/initramfs-$KernelVer.img bs=1M count=20
ba564c
ba564c
    if [ -f arch/$Arch/boot/zImage.stub ]; then
ba564c
      cp arch/$Arch/boot/zImage.stub $RPM_BUILD_ROOT/%{image_install_path}/zImage.stub-$KernelVer || :
ba564c
      cp arch/$Arch/boot/zImage.stub $RPM_BUILD_ROOT/lib/modules/$KernelVer/zImage.stub-$KernelVer || :
ba564c
    fi
74e6ae
ba564c
    %if %{signkernel}
74e6ae
    if [ "$KernelImage" = vmlinux ]; then
74e6ae
        # We can't strip and sign $KernelImage in place, because
74e6ae
        # we need to preserve original vmlinux for debuginfo.
74e6ae
        # Use a copy for signing.
74e6ae
        $CopyKernel $KernelImage $KernelImage.tosign
74e6ae
        KernelImage=$KernelImage.tosign
74e6ae
        CopyKernel=cp
74e6ae
    fi
74e6ae
ba564c
    # Sign the image if we're using EFI
ba564c
    # aarch64 kernels are gziped EFI images
ba564c
    KernelExtension=${KernelImage##*.}
ba564c
    if [ "$KernelExtension" == "gz" ]; then
ba564c
        SignImage=${KernelImage%.*}
ba564c
    else
ba564c
        SignImage=$KernelImage
ba564c
    fi
74e6ae
74e6ae
    %ifarch x86_64 aarch64
74e6ae
    %pesign -s -i $SignImage -o vmlinuz.signed -a %{secureboot_ca} -c %{secureboot_key} -n %{pesign_name}
74e6ae
    %endif
74e6ae
    %ifarch s390x ppc64le
74e6ae
    if [ -x /usr/bin/rpm-sign ]; then
74e6ae
	rpm-sign --key "%{pesign_name}" --lkmsign $SignImage --output vmlinuz.signed
74e6ae
    elif [ $DoModules -eq 1 ]; then
74e6ae
	chmod +x scripts/sign-file
74e6ae
	./scripts/sign-file -p sha256 certs/signing_key.pem certs/signing_key.x509 $SignImage vmlinuz.signed
74e6ae
    else
74e6ae
	mv $SignImage vmlinuz.signed
74e6ae
    fi
74e6ae
    %endif
74e6ae
ba564c
    if [ ! -s vmlinuz.signed ]; then
ba564c
        echo "pesigning failed"
ba564c
        exit 1
ba564c
    fi
ba564c
    mv vmlinuz.signed $SignImage
ba564c
    if [ "$KernelExtension" == "gz" ]; then
ba564c
        gzip -f9 $SignImage
ba564c
    fi
74e6ae
    %endif # signkernel
74e6ae
ba564c
    $CopyKernel $KernelImage \
ba564c
                $RPM_BUILD_ROOT/%{image_install_path}/$InstallName-$KernelVer
ba564c
    chmod 755 $RPM_BUILD_ROOT/%{image_install_path}/$InstallName-$KernelVer
ba564c
    cp $RPM_BUILD_ROOT/%{image_install_path}/$InstallName-$KernelVer $RPM_BUILD_ROOT/lib/modules/$KernelVer/$InstallName
ba564c
ba564c
    # hmac sign the kernel for FIPS
ba564c
    echo "Creating hmac file: $RPM_BUILD_ROOT/%{image_install_path}/.vmlinuz-$KernelVer.hmac"
ba564c
    ls -l $RPM_BUILD_ROOT/%{image_install_path}/$InstallName-$KernelVer
ba564c
    sha512hmac $RPM_BUILD_ROOT/%{image_install_path}/$InstallName-$KernelVer | sed -e "s,$RPM_BUILD_ROOT,," > $RPM_BUILD_ROOT/%{image_install_path}/.vmlinuz-$KernelVer.hmac;
ba564c
    cp $RPM_BUILD_ROOT/%{image_install_path}/.vmlinuz-$KernelVer.hmac $RPM_BUILD_ROOT/lib/modules/$KernelVer/.vmlinuz.hmac
ba564c
ba564c
    if [ $DoModules -eq 1 ]; then
ba564c
	# Override $(mod-fw) because we don't want it to install any firmware
ba564c
	# we'll get it from the linux-firmware package and we don't want conflicts
74e6ae
	%{make} -s %{?_smp_mflags} ARCH=$Arch INSTALL_MOD_PATH=$RPM_BUILD_ROOT modules_install KERNELRELEASE=$KernelVer mod-fw=
ba564c
    fi
ba564c
ba564c
%if %{with_gcov}
ba564c
    # install gcov-needed files to $BUILDROOT/$BUILD/...:
ba564c
    #   gcov_info->filename is absolute path
ba564c
    #   gcno references to sources can use absolute paths (e.g. in out-of-tree builds)
ba564c
    #   sysfs symlink targets (set up at compile time) use absolute paths to BUILD dir
ba564c
    find . \( -name '*.gcno' -o -name '*.[chS]' \) -exec install -D '{}' "$RPM_BUILD_ROOT/$(pwd)/{}" \;
ba564c
%endif
ba564c
ba564c
    if [ $DoVDSO -ne 0 ]; then
ba564c
        %{make} -s ARCH=$Arch INSTALL_MOD_PATH=$RPM_BUILD_ROOT vdso_install KERNELRELEASE=$KernelVer
ba564c
        if [ ! -s ldconfig-kernel.conf ]; then
ba564c
          echo > ldconfig-kernel.conf "\
ba564c
    # Placeholder file, no vDSO hwcap entries used in this kernel."
ba564c
        fi
ba564c
        %{__install} -D -m 444 ldconfig-kernel.conf \
ba564c
            $RPM_BUILD_ROOT/etc/ld.so.conf.d/kernel-$KernelVer.conf
ba564c
        rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/vdso/.build-id
ba564c
    fi
ba564c
ba564c
    # And save the headers/makefiles etc for building modules against
ba564c
    #
ba564c
    # This all looks scary, but the end result is supposed to be:
ba564c
    # * all arch relevant include/ files
ba564c
    # * all Makefile/Kconfig files
ba564c
    # * all script/ files
ba564c
ba564c
    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
ba564c
    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/source
ba564c
    mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
ba564c
    (cd $RPM_BUILD_ROOT/lib/modules/$KernelVer ; ln -s build source)
ba564c
    # dirs for additional modules per module-init-tools, kbuild/modules.txt
ba564c
    mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/updates
ba564c
    mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/weak-updates
ba564c
    # first copy everything
ba564c
    cp --parents `find  -type f -name "Makefile*" -o -name "Kconfig*"` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
ba564c
    cp Module.symvers $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
ba564c
    cp System.map $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
ba564c
    if [ -s Module.markers ]; then
ba564c
      cp Module.markers $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
ba564c
    fi
ba564c
ba564c
    # create the kABI metadata for use in packaging
ba564c
    # NOTENOTE: the name symvers is used by the rpm backend
ba564c
    # NOTENOTE: to discover and run the /usr/lib/rpm/fileattrs/kabi.attr
ba564c
    # NOTENOTE: script which dynamically adds exported kernel symbol
ba564c
    # NOTENOTE: checksums to the rpm metadata provides list.
ba564c
    # NOTENOTE: if you change the symvers name, update the backend too
ba564c
    echo "**** GENERATING kernel ABI metadata ****"
ba564c
    gzip -c9 < Module.symvers > $RPM_BUILD_ROOT/boot/symvers-$KernelVer.gz
ba564c
    cp $RPM_BUILD_ROOT/boot/symvers-$KernelVer.gz $RPM_BUILD_ROOT/lib/modules/$KernelVer/symvers.gz
ba564c
ba564c
%if %{with_kabichk}
ba564c
    echo "**** kABI checking is enabled in kernel SPEC file. ****"
ba564c
    chmod 0755 $RPM_SOURCE_DIR/check-kabi
ba564c
    if [ -e $RPM_SOURCE_DIR/Module.kabi_%{_target_cpu}$Flavour ]; then
ba564c
        cp $RPM_SOURCE_DIR/Module.kabi_%{_target_cpu}$Flavour $RPM_BUILD_ROOT/Module.kabi
ba564c
        $RPM_SOURCE_DIR/check-kabi -k $RPM_BUILD_ROOT/Module.kabi -s Module.symvers || exit 1
ba564c
        rm $RPM_BUILD_ROOT/Module.kabi # for now, don't keep it around.
ba564c
    else
ba564c
        echo "**** NOTE: Cannot find reference Module.kabi file. ****"
ba564c
    fi
ba564c
%endif
ba564c
ba564c
%if %{with_kabidupchk}
ba564c
    echo "**** kABI DUP checking is enabled in kernel SPEC file. ****"
ba564c
    if [ -e $RPM_SOURCE_DIR/Module.kabi_dup_%{_target_cpu}$Flavour ]; then
ba564c
        cp $RPM_SOURCE_DIR/Module.kabi_dup_%{_target_cpu}$Flavour $RPM_BUILD_ROOT/Module.kabi
ba564c
        $RPM_SOURCE_DIR/check-kabi -k $RPM_BUILD_ROOT/Module.kabi -s Module.symvers || exit 1
ba564c
        rm $RPM_BUILD_ROOT/Module.kabi # for now, don't keep it around.
ba564c
    else
ba564c
        echo "**** NOTE: Cannot find DUP reference Module.kabi file. ****"
ba564c
    fi
ba564c
%endif
ba564c
ba564c
%if %{with_kabidw_base}
ba564c
    # Don't build kabi base for debug kernels
ba564c
    if [ "$Flavour" != "kdump" -a "$Flavour" != "debug" ]; then
ba564c
        mkdir -p $RPM_BUILD_ROOT/kabi-dwarf
ba564c
        tar xjvf %{SOURCE301} -C $RPM_BUILD_ROOT/kabi-dwarf
ba564c
ba564c
        mkdir -p $RPM_BUILD_ROOT/kabi-dwarf/whitelists
ba564c
        tar xjvf %{SOURCE300} -C $RPM_BUILD_ROOT/kabi-dwarf/whitelists
ba564c
ba564c
        echo "**** GENERATING DWARF-based kABI baseline dataset ****"
ba564c
        chmod 0755 $RPM_BUILD_ROOT/kabi-dwarf/run_kabi-dw.sh
ba564c
        $RPM_BUILD_ROOT/kabi-dwarf/run_kabi-dw.sh generate \
ba564c
            "$RPM_BUILD_ROOT/kabi-dwarf/whitelists/kabi-current/kabi_whitelist_%{_target_cpu}" \
ba564c
            "$(pwd)" \
ba564c
            "$RPM_BUILD_ROOT/kabidw-base/%{_target_cpu}${Flavour:+.${Flavour}}" || :
ba564c
ba564c
        rm -rf $RPM_BUILD_ROOT/kabi-dwarf
ba564c
    fi
ba564c
%endif
ba564c
ba564c
%if %{with_kabidwchk}
ba564c
    if [ "$Flavour" != "kdump" ]; then
ba564c
        mkdir -p $RPM_BUILD_ROOT/kabi-dwarf
ba564c
        tar xjvf %{SOURCE301} -C $RPM_BUILD_ROOT/kabi-dwarf
ba564c
        if [ -d "$RPM_BUILD_ROOT/kabi-dwarf/base/%{_target_cpu}${Flavour:+.${Flavour}}" ]; then
ba564c
            mkdir -p $RPM_BUILD_ROOT/kabi-dwarf/whitelists
ba564c
            tar xjvf %{SOURCE300} -C $RPM_BUILD_ROOT/kabi-dwarf/whitelists
ba564c
ba564c
            echo "**** GENERATING DWARF-based kABI dataset ****"
ba564c
            chmod 0755 $RPM_BUILD_ROOT/kabi-dwarf/run_kabi-dw.sh
ba564c
            $RPM_BUILD_ROOT/kabi-dwarf/run_kabi-dw.sh generate \
ba564c
                "$RPM_BUILD_ROOT/kabi-dwarf/whitelists/kabi-current/kabi_whitelist_%{_target_cpu}" \
ba564c
                "$(pwd)" \
ba564c
                "$RPM_BUILD_ROOT/kabi-dwarf/base/%{_target_cpu}${Flavour:+.${Flavour}}.tmp" || :
ba564c
ba564c
            echo "**** kABI DWARF-based comparison report ****"
ba564c
            $RPM_BUILD_ROOT/kabi-dwarf/run_kabi-dw.sh compare \
ba564c
                "$RPM_BUILD_ROOT/kabi-dwarf/base/%{_target_cpu}${Flavour:+.${Flavour}}" \
ba564c
                "$RPM_BUILD_ROOT/kabi-dwarf/base/%{_target_cpu}${Flavour:+.${Flavour}}.tmp" || :
ba564c
            echo "**** End of kABI DWARF-based comparison report ****"
ba564c
        else
ba564c
            echo "**** Baseline dataset for kABI DWARF-BASED comparison report not found ****"
ba564c
        fi
ba564c
ba564c
        rm -rf $RPM_BUILD_ROOT/kabi-dwarf
ba564c
    fi
ba564c
%endif
ba564c
ba564c
    # then drop all but the needed Makefiles/Kconfig files
ba564c
    rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Documentation
ba564c
    rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts
ba564c
    rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
ba564c
    cp .config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
ba564c
    cp -a scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
ba564c
    rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/tracing
ba564c
    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/spdxcheck.py
ba564c
    if [ -f tools/objtool/objtool ]; then
ba564c
      cp -a tools/objtool/objtool $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/tools/objtool/ || :
ba564c
    fi
ba564c
    if [ -d arch/$Arch/scripts ]; then
ba564c
      cp -a arch/$Arch/scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch} || :
ba564c
    fi
ba564c
    if [ -f arch/$Arch/*lds ]; then
ba564c
      cp -a arch/$Arch/*lds $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch}/ || :
ba564c
    fi
ba564c
    if [ -f arch/%{asmarch}/kernel/module.lds ]; then
ba564c
      cp -a --parents arch/%{asmarch}/kernel/module.lds $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    fi
ba564c
    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/*.o
ba564c
    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/*/*.o
ba564c
%ifarch ppc64le
ba564c
    cp -a --parents arch/powerpc/lib/crtsavres.[So] $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
%endif
ba564c
    if [ -d arch/%{asmarch}/include ]; then
ba564c
      cp -a --parents arch/%{asmarch}/include $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    fi
ba564c
%ifarch aarch64
ba564c
    # arch/arm64/include/asm/xen references arch/arm
ba564c
    cp -a --parents arch/arm/include/asm/xen $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    # arch/arm64/include/asm/opcodes.h references arch/arm
ba564c
    cp -a --parents arch/arm/include/asm/opcodes.h $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
%endif
ba564c
    cp -a include $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
ba564c
%ifarch x86_64
ba564c
    # files for 'make prepare' to succeed with kernel-devel
ba564c
    cp -a --parents arch/x86/entry/syscalls/syscall_32.tbl $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/entry/syscalls/syscalltbl.sh $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/entry/syscalls/syscallhdr.sh $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/entry/syscalls/syscall_64.tbl $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/tools/relocs_32.c $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/tools/relocs_64.c $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/tools/relocs.c $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/tools/relocs_common.c $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/tools/relocs.h $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents tools/include/tools/le_byteshift.h $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/purgatory/purgatory.c $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/purgatory/stack.S $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/purgatory/string.c $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/purgatory/setup-x86_64.S $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/purgatory/entry64.S $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/boot/string.h $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/boot/string.c $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
    cp -a --parents arch/x86/boot/ctype.h $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/
ba564c
%endif
ba564c
    # Make sure the Makefile and version.h have a matching timestamp so that
ba564c
    # external modules can be built
ba564c
    touch -r $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Makefile $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/generated/uapi/linux/version.h
ba564c
ba564c
    # Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
ba564c
    cp $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/.config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/config/auto.conf
ba564c
ba564c
%if %{with_debuginfo}
ba564c
    eu-readelf -n vmlinux | grep "Build ID" | awk '{print $NF}' > vmlinux.id
ba564c
    cp vmlinux.id $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/vmlinux.id
ba564c
ba564c
    #
ba564c
    # save the vmlinux file for kernel debugging into the kernel-debuginfo rpm
ba564c
    #
ba564c
    mkdir -p $RPM_BUILD_ROOT%{debuginfodir}/lib/modules/$KernelVer
ba564c
    cp vmlinux $RPM_BUILD_ROOT%{debuginfodir}/lib/modules/$KernelVer
ba564c
%endif
ba564c
ba564c
    find $RPM_BUILD_ROOT/lib/modules/$KernelVer -name "*.ko" -type f >modnames
ba564c
ba564c
    # mark modules executable so that strip-to-file can strip them
ba564c
    xargs --no-run-if-empty chmod u+x < modnames
ba564c
ba564c
    # Generate a list of modules for block and networking.
ba564c
ba564c
    grep -F /drivers/ modnames | xargs --no-run-if-empty nm -upA |
ba564c
    sed -n 's,^.*/\([^/]*\.ko\):  *U \(.*\)$,\1 \2,p' > drivers.undef
ba564c
ba564c
    collect_modules_list()
ba564c
    {
ba564c
      sed -r -n -e "s/^([^ ]+) \\.?($2)\$/\\1/p" drivers.undef |
ba564c
        LC_ALL=C sort -u > $RPM_BUILD_ROOT/lib/modules/$KernelVer/modules.$1
ba564c
      if [ ! -z "$3" ]; then
ba564c
        sed -r -e "/^($3)\$/d" -i $RPM_BUILD_ROOT/lib/modules/$KernelVer/modules.$1
ba564c
      fi
ba564c
    }
ba564c
ba564c
    collect_modules_list networking \
ba564c
      'register_netdev|ieee80211_register_hw|usbnet_probe|phy_driver_register|rt(l_|2x00)(pci|usb)_probe|register_netdevice'
ba564c
    collect_modules_list block \
ba564c
      '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'
ba564c
    collect_modules_list drm \
ba564c
      'drm_open|drm_init'
ba564c
    collect_modules_list modesetting \
ba564c
      'drm_crtc_init'
ba564c
ba564c
    # detect missing or incorrect license tags
ba564c
    ( find $RPM_BUILD_ROOT/lib/modules/$KernelVer -name '*.ko' | xargs /sbin/modinfo -l | \
ba564c
        grep -E -v 'GPL( v2)?$|Dual BSD/GPL$|Dual MPL/GPL$|GPL and additional rights$' ) && exit 1
ba564c
ba564c
    # remove files that will be auto generated by depmod at rpm -i time
ba564c
    pushd $RPM_BUILD_ROOT/lib/modules/$KernelVer/
ba564c
        rm -f modules.{alias*,builtin.bin,dep*,*map,symbols*,devname,softdep}
ba564c
    popd
ba564c
74e6ae
    # Identify modules in the kernel-modules-extras package
74e6ae
    %{SOURCE17} $RPM_BUILD_ROOT lib/modules/$KernelVer %{SOURCE16}
74e6ae
    # Identify modules in the kernel-modules-internal package
74e6ae
    %{SOURCE17} $RPM_BUILD_ROOT lib/modules/$KernelVer %{SOURCE44} internal
74e6ae
ba564c
    #
ba564c
    # Generate the kernel-core and kernel-modules files lists
ba564c
    #
ba564c
ba564c
    # Copy the System.map file for depmod to use, and create a backup of the
ba564c
    # full module tree so we can restore it after we're done filtering
ba564c
    cp System.map $RPM_BUILD_ROOT/.
ba564c
    pushd $RPM_BUILD_ROOT
ba564c
    mkdir restore
ba564c
    cp -r lib/modules/$KernelVer/* restore/.
ba564c
74e6ae
    # don't include anything going into kernel-modules-extra in the file lists
74e6ae
    xargs rm -rf < mod-extra.list
74e6ae
    # don't include anything going int kernel-modules-internal in the file lists
74e6ae
    xargs rm -rf < mod-internal.list
ba564c
ba564c
    if [ $DoModules -eq 1 ]; then
ba564c
	# Find all the module files and filter them out into the core and
ba564c
	# modules lists.  This actually removes anything going into -modules
ba564c
	# from the dir.
ba564c
	find lib/modules/$KernelVer/kernel -name *.ko | sort -n > modules.list
ba564c
	cp $RPM_SOURCE_DIR/filter-*.sh .
ba564c
	%{SOURCE99} modules.list %{_target_cpu}
ba564c
	rm filter-*.sh
ba564c
ba564c
	# Run depmod on the resulting module tree and make sure it isn't broken
ba564c
	depmod -b . -aeF ./System.map $KernelVer &> depmod.out
ba564c
	if [ -s depmod.out ]; then
ba564c
	    echo "Depmod failure"
ba564c
	    cat depmod.out
ba564c
	    exit 1
ba564c
	else
ba564c
	    rm depmod.out
ba564c
	fi
ba564c
    else
ba564c
	# Ensure important files/directories exist to let the packaging succeed
ba564c
	echo '%%defattr(-,-,-)' > modules.list
ba564c
	echo '%%defattr(-,-,-)' > k-d.list
ba564c
	mkdir -p lib/modules/$KernelVer/kernel
ba564c
	# Add files usually created by make modules, needed to prevent errors
ba564c
	# thrown by depmod during package installation
ba564c
	touch lib/modules/$KernelVer/modules.order
ba564c
	touch lib/modules/$KernelVer/modules.builtin
ba564c
    fi
ba564c
ba564c
    # remove files that will be auto generated by depmod at rpm -i time
ba564c
    pushd $RPM_BUILD_ROOT/lib/modules/$KernelVer/
ba564c
        rm -f modules.{alias*,builtin.bin,dep*,*map,symbols*,devname,softdep}
ba564c
    popd
ba564c
ba564c
    # Go back and find all of the various directories in the tree.  We use this
ba564c
    # for the dir lists in kernel-core
ba564c
    find lib/modules/$KernelVer/kernel -mindepth 1 -type d | sort -n > module-dirs.list
ba564c
ba564c
    # Cleanup
ba564c
    rm System.map
ba564c
    cp -r restore/* lib/modules/$KernelVer/.
ba564c
    rm -rf restore
ba564c
    popd
ba564c
ba564c
    # Make sure the files lists start with absolute paths or rpmbuild fails.
ba564c
    # Also add in the dir entries
ba564c
    sed -e 's/^lib*/\/lib/' %{?zipsed} $RPM_BUILD_ROOT/k-d.list > ../kernel${Flavour:+-${Flavour}}-modules.list
ba564c
    sed -e 's/^lib*/%dir \/lib/' %{?zipsed} $RPM_BUILD_ROOT/module-dirs.list > ../kernel${Flavour:+-${Flavour}}-core.list
ba564c
    sed -e 's/^lib*/\/lib/' %{?zipsed} $RPM_BUILD_ROOT/modules.list >> ../kernel${Flavour:+-${Flavour}}-core.list
74e6ae
    sed -e 's/^lib*/\/lib/' %{?zipsed} $RPM_BUILD_ROOT/mod-extra.list >> ../kernel${Flavour:+-${Flavour}}-modules-extra.list
74e6ae
    sed -e 's/^lib*/\/lib/' %{?zipsed} $RPM_BUILD_ROOT/mod-internal.list >> ../kernel${Flavour:+-${Flavour}}-modules-internal.list
ba564c
ba564c
    # Cleanup
ba564c
    rm -f $RPM_BUILD_ROOT/k-d.list
ba564c
    rm -f $RPM_BUILD_ROOT/modules.list
ba564c
    rm -f $RPM_BUILD_ROOT/module-dirs.list
74e6ae
    rm -f $RPM_BUILD_ROOT/mod-extra.list
74e6ae
    rm -f $RPM_BUILD_ROOT/mod-internal.list
ba564c
ba564c
%if %{signmodules}
ba564c
    if [ $DoModules -eq 1 ]; then
ba564c
	# Save the signing keys so we can sign the modules in __modsign_install_post
ba564c
	cp certs/signing_key.pem certs/signing_key.pem.sign${Flav}
ba564c
	cp certs/signing_key.x509 certs/signing_key.x509.sign${Flav}
ba564c
    fi
ba564c
%endif
ba564c
ba564c
    # Move the devel headers out of the root file system
ba564c
    mkdir -p $RPM_BUILD_ROOT/usr/src/kernels
ba564c
    mv $RPM_BUILD_ROOT/lib/modules/$KernelVer/build $RPM_BUILD_ROOT/$DevelDir
ba564c
ba564c
    # This is going to create a broken link during the build, but we don't use
ba564c
    # it after this point.  We need the link to actually point to something
ba564c
    # when kernel-devel is installed, and a relative link doesn't work across
ba564c
    # the F17 UsrMove feature.
ba564c
    ln -sf $DevelDir $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
ba564c
ba564c
    # prune junk from kernel-devel
ba564c
    find $RPM_BUILD_ROOT/usr/src/kernels -name ".*.cmd" -exec rm -f {} \;
ba564c
ba564c
    # build a BLS config for this kernel
ba564c
    %{SOURCE43} "$KernelVer" "$RPM_BUILD_ROOT" "%{?variant}"
ba564c
3fb3f3
    # Red Hat UEFI Secure Boot CA cert, which can be used to authenticate the kernel
ba564c
    mkdir -p $RPM_BUILD_ROOT%{_datadir}/doc/kernel-keys/$KernelVer
74e6ae
    install -m 0644 %{secureboot_ca} $RPM_BUILD_ROOT%{_datadir}/doc/kernel-keys/$KernelVer/kernel-signing-ca.cer
74e6ae
    %ifarch s390x ppc64le
74e6ae
    if [ $DoModules -eq 1 ]; then
74e6ae
	if [ -x /usr/bin/rpm-sign ]; then
74e6ae
	    install -m 0644 %{secureboot_key} $RPM_BUILD_ROOT%{_datadir}/doc/kernel-keys/$KernelVer/%{signing_key_filename}
74e6ae
	else
74e6ae
	    install -m 0644 certs/signing_key.x509.sign${Flav} $RPM_BUILD_ROOT%{_datadir}/doc/kernel-keys/$KernelVer/kernel-signing-ca.cer
74e6ae
	    openssl x509 -in certs/signing_key.pem.sign${Flav} -outform der -out $RPM_BUILD_ROOT%{_datadir}/doc/kernel-keys/$KernelVer/%{signing_key_filename}
74e6ae
	    chmod 0644 $RPM_BUILD_ROOT%{_datadir}/doc/kernel-keys/$KernelVer/%{signing_key_filename}
74e6ae
	fi
74e6ae
    fi
74e6ae
    %endif
74e6ae
74e6ae
%if %{with_ipaclones}
74e6ae
    MAXPROCS=$(echo %{?_smp_mflags} | sed -n 's/-j\s*\([0-9]\+\)/\1/p')
74e6ae
    if [ -z "$MAXPROCS" ]; then
74e6ae
        MAXPROCS=1
74e6ae
    fi
74e6ae
    if [ "$Flavour" == "" ]; then
74e6ae
        mkdir -p $RPM_BUILD_ROOT/$DevelDir-ipaclones
74e6ae
        find . -name '*.ipa-clones' | xargs -i{} -r -n 1 -P $MAXPROCS install -m 644 -D "{}" "$RPM_BUILD_ROOT/$DevelDir-ipaclones/{}"
74e6ae
    fi
74e6ae
%endif
ba564c
ba564c
}
ba564c
ba564c
###
ba564c
# DO it...
ba564c
###
ba564c
ba564c
# prepare directories
ba564c
rm -rf $RPM_BUILD_ROOT
ba564c
mkdir -p $RPM_BUILD_ROOT/boot
ba564c
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}
ba564c
ba564c
cd linux-%{KVERREL}
ba564c
ba564c
ba564c
%if %{with_debug}
ba564c
BuildKernel %make_target %kernel_image %{with_vdso_install} debug
ba564c
%endif
ba564c
ba564c
%if %{with_zfcpdump}
ba564c
BuildKernel %make_target %kernel_image %{with_vdso_install} zfcpdump
ba564c
%endif
ba564c
ba564c
%if %{with_up}
ba564c
BuildKernel %make_target %kernel_image %{with_vdso_install}
ba564c
%endif
ba564c
ba564c
%global perf_make \
ba564c
  make EXTRA_CFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags}" %{?cross_opts} -C tools/perf V=1 NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 WERROR=0 NO_LIBUNWIND=1 HAVE_CPLUS_DEMANGLE=1 NO_GTK2=1 NO_STRLCPY=1 NO_BIONIC=1 prefix=%{_prefix} PYTHON=%{__python3}
ba564c
%if %{with_perf}
ba564c
# perf
ba564c
# make sure check-headers.sh is executable
ba564c
chmod +x tools/perf/check-headers.sh
ba564c
%{perf_make} DESTDIR=$RPM_BUILD_ROOT all
ba564c
%endif
ba564c
ba564c
%global tools_make \
ba564c
  %{make} CFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags}" V=1
ba564c
ba564c
%if %{with_tools}
ba564c
%ifarch %{cpupowerarchs}
ba564c
# cpupower
ba564c
# make sure version-gen.sh is executable.
ba564c
chmod +x tools/power/cpupower/utils/version-gen.sh
ba564c
%{tools_make} -C tools/power/cpupower CPUFREQ_BENCH=false DEBUG=false
ba564c
%ifarch x86_64
ba564c
    pushd tools/power/cpupower/debug/x86_64
ba564c
    %{tools_make} centrino-decode powernow-k8-decode
ba564c
    popd
ba564c
%endif
ba564c
%ifarch x86_64
ba564c
   pushd tools/power/x86/x86_energy_perf_policy/
74e6ae
   %{tools_make}
ba564c
   popd
ba564c
   pushd tools/power/x86/turbostat
74e6ae
   %{tools_make}
ba564c
   popd
ba564c
%endif #turbostat/x86_energy_perf_policy
ba564c
%endif
ba564c
pushd tools/thermal/tmon/
74e6ae
%{tools_make}
ba564c
popd
ba564c
pushd tools/iio/
74e6ae
%{tools_make}
ba564c
popd
ba564c
pushd tools/gpio/
74e6ae
%{tools_make}
ba564c
popd
ba564c
%endif
ba564c
ba564c
%global bpftool_make \
ba564c
  make EXTRA_CFLAGS="${RPM_OPT_FLAGS}" EXTRA_LDFLAGS="%{__global_ldflags}" DESTDIR=$RPM_BUILD_ROOT V=1
ba564c
%if %{with_bpftool}
ba564c
pushd tools/bpf/bpftool
ba564c
%{bpftool_make}
ba564c
popd
ba564c
%endif
ba564c
74e6ae
%if %{with_selftests}
ba564c
# Unfortunately, samples/bpf/Makefile expects that the headers are installed
ba564c
# in the source tree. We installed them previously to $RPM_BUILD_ROOT/usr
ba564c
# but there's no way to tell the Makefile to take them from there.
74e6ae
%{make} headers_install
ba564c
%{make} -s ARCH=$Arch V=1 samples/bpf/
ba564c
pushd tools/testing/selftests
ba564c
# We need to install here because we need to call make with ARCH set which
ba564c
# doesn't seem possible to do in the install section.
74e6ae
%{make} -s ARCH=$Arch V=1 TARGETS="bpf net" INSTALL_PATH=%{buildroot}%{_libexecdir}/kselftests install
ba564c
popd
ba564c
%endif
ba564c
ba564c
%if %{with_doc}
ba564c
# Make the HTML pages.
ba564c
make htmldocs || %{doc_build_fail}
ba564c
ba564c
# sometimes non-world-readable files sneak into the kernel source tree
ba564c
chmod -R a=rX Documentation
ba564c
find Documentation -type d | xargs chmod u+w
ba564c
%endif
ba564c
ba564c
# In the modsign case, we do 3 things.  1) We check the "flavour" and hard
ba564c
# code the value in the following invocations.  This is somewhat sub-optimal
ba564c
# but we're doing this inside of an RPM macro and it isn't as easy as it
ba564c
# could be because of that.  2) We restore the .tmp_versions/ directory from
ba564c
# the one we saved off in BuildKernel above.  This is to make sure we're
ba564c
# signing the modules we actually built/installed in that flavour.  3) We
ba564c
# grab the arch and invoke mod-sign.sh command to actually sign the modules.
ba564c
#
ba564c
# We have to do all of those things _after_ find-debuginfo runs, otherwise
ba564c
# that will strip the signature off of the modules.
ba564c
#
ba564c
# Don't sign modules for the zfcpdump flavour as it is monolithic.
ba564c
ba564c
%define __modsign_install_post \
ba564c
  if [ "%{signmodules}" -eq "1" ]; then \
ba564c
    if [ "%{with_debug}" -ne "0" ]; then \
ba564c
      %{modsign_cmd} certs/signing_key.pem.sign+debug certs/signing_key.x509.sign+debug $RPM_BUILD_ROOT/lib/modules/%{KVERREL}+debug/ \
ba564c
    fi \
ba564c
    if [ "%{with_up}" -ne "0" ]; then \
ba564c
      %{modsign_cmd} certs/signing_key.pem.sign certs/signing_key.x509.sign $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/ \
ba564c
    fi \
ba564c
  fi \
ba564c
  if [ "%{zipmodules}" -eq "1" ]; then \
74e6ae
    find $RPM_BUILD_ROOT/lib/modules/ -type f -name '*.ko' | %{SOURCE80} %{?_smp_mflags}; \
ba564c
  fi \
ba564c
%{nil}
ba564c
ba564c
###
ba564c
### Special hacks for debuginfo subpackages.
ba564c
###
ba564c
ba564c
# This macro is used by %%install, so we must redefine it before that.
ba564c
%define debug_package %{nil}
ba564c
ba564c
%if %{with_debuginfo}
ba564c
ba564c
%ifnarch noarch
ba564c
%global __debug_package 1
ba564c
%files -f debugfiles.list debuginfo-common-%{_target_cpu}
ba564c
%defattr(-,root,root)
ba564c
%endif
ba564c
ba564c
%endif
ba564c
74e6ae
# We don't want to package debuginfo for self-tests and samples but
74e6ae
# we have to delete them to avoid an error messages about unpackaged
74e6ae
# files.
74e6ae
%define __remove_unwanted_dbginfo_install_post \
74e6ae
  if [ "%{with_selftests}" -ne "0" ]; then \
74e6ae
    rm -rf $RPM_BUILD_ROOT/usr/lib/debug/usr/libexec/ksamples; \
74e6ae
    rm -rf $RPM_BUILD_ROOT/usr/lib/debug/usr/libexec/kselftests; \
74e6ae
  fi \
74e6ae
%{nil}
74e6ae
ba564c
#
ba564c
# Disgusting hack alert! We need to ensure we sign modules *after* all
ba564c
# invocations of strip occur, which is in __debug_install_post if
ba564c
# find-debuginfo.sh runs, and __os_install_post if not.
ba564c
#
ba564c
%define __spec_install_post \
ba564c
  %{?__debug_package:%{__debug_install_post}}\
ba564c
  %{__arch_install_post}\
ba564c
  %{__os_install_post}\
74e6ae
  %{__remove_unwanted_dbginfo_install_post}\
ba564c
  %{__modsign_install_post}
ba564c
ba564c
###
ba564c
### install
ba564c
###
ba564c
ba564c
%install
ba564c
ba564c
cd linux-%{KVERREL}
ba564c
ba564c
%if %{with_doc}
ba564c
docdir=$RPM_BUILD_ROOT%{_datadir}/doc/kernel-doc-%{rpmversion}
ba564c
ba564c
# copy the source over
ba564c
mkdir -p $docdir
ba564c
tar -h -f - --exclude=man --exclude='.*' -c Documentation | tar xf - -C $docdir
ba564c
ba564c
%endif # with_doc
ba564c
ba564c
# We have to do the headers install before the tools install because the
ba564c
# kernel headers_install will remove any header files in /usr/include that
ba564c
# it doesn't install itself.
ba564c
ba564c
%if %{with_headers}
ba564c
# Install kernel headers
74e6ae
%{make} ARCH=%{hdrarch} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr headers_install
ba564c
ba564c
find $RPM_BUILD_ROOT/usr/include \
ba564c
     \( -name .install -o -name .check -o \
ba564c
        -name ..install.cmd -o -name ..check.cmd \) | xargs rm -f
ba564c
ba564c
%endif
ba564c
ba564c
%if %{with_cross_headers}
74e6ae
HDR_ARCH_LIST='arm64 powerpc s390 x86'
ba564c
mkdir -p $RPM_BUILD_ROOT/usr/tmp-headers
74e6ae
%{make} ARCH=%{hdrarch} HDR_ARCH_LIST="$HDR_ARCH_LIST" INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr/tmp-headers headers_install_all
ba564c
ba564c
find $RPM_BUILD_ROOT/usr/tmp-headers/include \
ba564c
     \( -name .install -o -name .check -o \
ba564c
        -name ..install.cmd -o -name ..check.cmd \) | xargs rm -f
ba564c
ba564c
# Copy all the architectures we care about to their respective asm directories
74e6ae
for arch in $HDR_ARCH_LIST ; do
ba564c
mkdir -p $RPM_BUILD_ROOT/usr/${arch}-linux-gnu/include
ba564c
mv $RPM_BUILD_ROOT/usr/tmp-headers/include/arch-${arch}/asm $RPM_BUILD_ROOT/usr/${arch}-linux-gnu/include/
ba564c
cp -a $RPM_BUILD_ROOT/usr/tmp-headers/include/asm-generic $RPM_BUILD_ROOT/usr/${arch}-linux-gnu/include/.
ba564c
done
ba564c
ba564c
# Remove the rest of the architectures
ba564c
rm -rf $RPM_BUILD_ROOT/usr/tmp-headers/include/arch*
ba564c
rm -rf $RPM_BUILD_ROOT/usr/tmp-headers/include/asm-*
ba564c
ba564c
# Copy the rest of the headers over
74e6ae
for arch in $HDR_ARCH_LIST ; do
ba564c
cp -a $RPM_BUILD_ROOT/usr/tmp-headers/include/* $RPM_BUILD_ROOT/usr/${arch}-linux-gnu/include/.
ba564c
done
ba564c
ba564c
rm -rf $RPM_BUILD_ROOT/usr/tmp-headers
ba564c
%endif
ba564c
ba564c
%if %{with_kernel_abi_whitelists}
ba564c
# kabi directory
ba564c
INSTALL_KABI_PATH=$RPM_BUILD_ROOT/lib/modules/
ba564c
mkdir -p $INSTALL_KABI_PATH
ba564c
ba564c
# install kabi releases directories
ba564c
tar xjvf %{SOURCE300} -C $INSTALL_KABI_PATH
ba564c
%endif  # with_kernel_abi_whitelists
ba564c
ba564c
%if %{with_perf}
ba564c
# perf tool binary and supporting scripts/binaries
ba564c
%{perf_make} DESTDIR=$RPM_BUILD_ROOT lib=%{_lib} install-bin install-traceevent-plugins
ba564c
# remove the 'trace' symlink.
ba564c
rm -f %{buildroot}%{_bindir}/trace
ba564c
ba564c
# For both of the below, yes, this should be using a macro but right now
ba564c
# it's hard coded and we don't actually want it anyway right now.
ba564c
# Whoever wants examples can fix it up!
ba564c
ba564c
# remove examples
ba564c
rm -rf %{buildroot}/usr/lib/examples/perf
ba564c
# remove the stray header file that somehow got packaged in examples
ba564c
rm -rf %{buildroot}/usr/lib/include/perf/bpf/bpf.h
ba564c
74e6ae
# remove perf-bpf examples
74e6ae
rm -rf %{buildroot}/usr/lib/perf/examples
74e6ae
rm -rf %{buildroot}/usr/lib/perf/include
74e6ae
ba564c
# python-perf extension
ba564c
%{perf_make} DESTDIR=$RPM_BUILD_ROOT install-python_ext
ba564c
ba564c
# perf man pages (note: implicit rpm magic compresses them later)
ba564c
mkdir -p %{buildroot}/%{_mandir}/man1
ba564c
%{perf_make} DESTDIR=$RPM_BUILD_ROOT install-man
ba564c
%endif
ba564c
ba564c
%if %{with_tools}
ba564c
%ifarch %{cpupowerarchs}
ba564c
%{make} -C tools/power/cpupower DESTDIR=$RPM_BUILD_ROOT libdir=%{_libdir} mandir=%{_mandir} CPUFREQ_BENCH=false install
ba564c
rm -f %{buildroot}%{_libdir}/*.{a,la}
ba564c
%find_lang cpupower
ba564c
mv cpupower.lang ../
ba564c
%ifarch x86_64
ba564c
    pushd tools/power/cpupower/debug/x86_64
ba564c
    install -m755 centrino-decode %{buildroot}%{_bindir}/centrino-decode
ba564c
    install -m755 powernow-k8-decode %{buildroot}%{_bindir}/powernow-k8-decode
ba564c
    popd
ba564c
%endif
ba564c
chmod 0755 %{buildroot}%{_libdir}/libcpupower.so*
ba564c
mkdir -p %{buildroot}%{_unitdir} %{buildroot}%{_sysconfdir}/sysconfig
ba564c
install -m644 %{SOURCE2000} %{buildroot}%{_unitdir}/cpupower.service
ba564c
install -m644 %{SOURCE2001} %{buildroot}%{_sysconfdir}/sysconfig/cpupower
ba564c
%endif
ba564c
%ifarch x86_64
ba564c
   mkdir -p %{buildroot}%{_mandir}/man8
ba564c
   pushd tools/power/x86/x86_energy_perf_policy
ba564c
   %{tools_make} DESTDIR=%{buildroot} install
ba564c
   popd
ba564c
   pushd tools/power/x86/turbostat
ba564c
   %{tools_make} DESTDIR=%{buildroot} install
ba564c
   popd
ba564c
%endif #turbostat/x86_energy_perf_policy
ba564c
pushd tools/thermal/tmon
ba564c
%{tools_make} INSTALL_ROOT=%{buildroot} install
ba564c
popd
ba564c
pushd tools/iio
ba564c
%{tools_make} DESTDIR=%{buildroot} install
ba564c
popd
ba564c
pushd tools/gpio
ba564c
%{tools_make} DESTDIR=%{buildroot} install
ba564c
popd
ba564c
pushd tools/kvm/kvm_stat
ba564c
make INSTALL_ROOT=%{buildroot} install-tools
ba564c
make INSTALL_ROOT=%{buildroot} install-man
ba564c
popd
ba564c
%endif
ba564c
ba564c
%if %{with_bpftool}
ba564c
pushd tools/bpf/bpftool
ba564c
%{bpftool_make} prefix=%{_prefix} bash_compdir=%{_sysconfdir}/bash_completion.d/ mandir=%{_mandir} install doc-install
ba564c
popd
ba564c
%endif
ba564c
74e6ae
%if %{with_selftests}
74e6ae
pushd samples
74e6ae
install -d %{buildroot}%{_libexecdir}/ksamples
74e6ae
# install bpf samples
74e6ae
pushd bpf
74e6ae
install -d %{buildroot}%{_libexecdir}/ksamples/bpf
74e6ae
find -type f -executable -exec install -m755 {} %{buildroot}%{_libexecdir}/ksamples/bpf \;
74e6ae
install -m755 *.sh %{buildroot}%{_libexecdir}/ksamples/bpf
ba564c
# test_lwt_bpf.sh compiles test_lwt_bpf.c when run; this works only from the
ba564c
# kernel tree. Just remove it.
74e6ae
rm %{buildroot}%{_libexecdir}/ksamples/bpf/test_lwt_bpf.sh
74e6ae
install -m644 *_kern.o %{buildroot}%{_libexecdir}/ksamples/bpf
74e6ae
install -m644 tcp_bpf.readme %{buildroot}%{_libexecdir}/ksamples/bpf
74e6ae
popd
74e6ae
# install pktgen samples
74e6ae
pushd pktgen
74e6ae
install -d %{buildroot}%{_libexecdir}/ksamples/pktgen
74e6ae
find . -type f -executable -exec install -m755 {} %{buildroot}%{_libexecdir}/ksamples/pktgen/{} \;
74e6ae
find . -type f ! -executable -exec install -m644 {} %{buildroot}%{_libexecdir}/ksamples/pktgen/{} \;
74e6ae
popd
74e6ae
popd
74e6ae
# install drivers/net/mlxsw selftests
74e6ae
pushd tools/testing/selftests/drivers/net/mlxsw
74e6ae
find -type d -exec install -d %{buildroot}%{_libexecdir}/kselftests/drivers/net/mlxsw/{} \;
74e6ae
find -type f -executable -exec install -D -m755 {} %{buildroot}%{_libexecdir}/kselftests/drivers/net/mlxsw/{} \;
74e6ae
find -type f ! -executable -exec install -D -m644 {} %{buildroot}%{_libexecdir}/kselftests/drivers/net/mlxsw/{} \;
74e6ae
popd
74e6ae
# install net/forwarding selftests
74e6ae
pushd tools/testing/selftests/net/forwarding
74e6ae
find -type d -exec install -d %{buildroot}%{_libexecdir}/kselftests/net/forwarding/{} \;
74e6ae
find -type f -executable -exec install -D -m755 {} %{buildroot}%{_libexecdir}/kselftests/net/forwarding/{} \;
74e6ae
find -type f ! -executable -exec install -D -m644 {} %{buildroot}%{_libexecdir}/kselftests/net/forwarding/{} \;
74e6ae
popd
74e6ae
# install tc-testing selftests
74e6ae
pushd tools/testing/selftests/tc-testing
74e6ae
find -type d -exec install -d %{buildroot}%{_libexecdir}/kselftests/tc-testing/{} \;
74e6ae
find -type f -executable -exec install -D -m755 {} %{buildroot}%{_libexecdir}/kselftests/tc-testing/{} \;
74e6ae
find -type f ! -executable -exec install -D -m644 {} %{buildroot}%{_libexecdir}/kselftests/tc-testing/{} \;
ba564c
popd
ba564c
%endif
ba564c
ba564c
# We have to do the headers checksum calculation after the tools install because
ba564c
# these might end up installing their own set of headers on top of kernel's
ba564c
%if %{with_headers}
ba564c
# compute a content hash to export as Provides: kernel-headers-checksum
ba564c
HEADERS_CHKSUM=$(export LC_ALL=C; find $RPM_BUILD_ROOT/usr/include -type f -name "*.h" \
ba564c
			! -path $RPM_BUILD_ROOT/usr/include/linux/version.h | \
ba564c
		 sort | xargs cat | sha1sum - | cut -f 1 -d ' ');
ba564c
# export the checksum via usr/include/linux/version.h, so the dynamic
ba564c
# find-provides can grab the hash to update it accordingly
ba564c
echo "#define KERNEL_HEADERS_CHECKSUM \"$HEADERS_CHKSUM\"" >> $RPM_BUILD_ROOT/usr/include/linux/version.h
ba564c
%endif
ba564c
ba564c
###
ba564c
### clean
ba564c
###
ba564c
ba564c
%clean
ba564c
rm -rf $RPM_BUILD_ROOT
ba564c
ba564c
###
ba564c
### scripts
ba564c
###
ba564c
ba564c
%if %{with_tools}
ba564c
%post -n kernel-tools-libs
ba564c
/sbin/ldconfig
ba564c
ba564c
%postun -n kernel-tools-libs
ba564c
/sbin/ldconfig
ba564c
%endif
ba564c
ba564c
#
ba564c
# This macro defines a %%post script for a kernel*-devel package.
ba564c
#	%%kernel_devel_post [<subpackage>]
ba564c
#
ba564c
%define kernel_devel_post() \
ba564c
%{expand:%%post %{?1:%{1}-}devel}\
ba564c
if [ -f /etc/sysconfig/kernel ]\
ba564c
then\
ba564c
    . /etc/sysconfig/kernel || exit $?\
ba564c
fi\
ba564c
if [ "$HARDLINK" != "no" -a -x /usr/sbin/hardlink ]\
ba564c
then\
ba564c
    (cd /usr/src/kernels/%{KVERREL}%{?1:+%{1}} &&\
ba564c
     /usr/bin/find . -type f | while read f; do\
ba564c
       hardlink -c /usr/src/kernels/*%{?dist}.*/$f $f\
ba564c
     done)\
ba564c
fi\
ba564c
%{nil}
ba564c
ba564c
#
ba564c
# This macro defines a %%post script for a kernel*-modules-extra package.
ba564c
# It also defines a %%postun script that does the same thing.
ba564c
#	%%kernel_modules_extra_post [<subpackage>]
ba564c
#
ba564c
%define kernel_modules_extra_post() \
ba564c
%{expand:%%post %{?1:%{1}-}modules-extra}\
ba564c
/sbin/depmod -a %{KVERREL}%{?1:+%{1}}\
ba564c
%{nil}\
ba564c
%{expand:%%postun %{?1:%{1}-}modules-extra}\
ba564c
/sbin/depmod -a %{KVERREL}%{?1:+%{1}}\
ba564c
%{nil}
ba564c
ba564c
#
74e6ae
# This macro defines a %%post script for a kernel*-modules-internal package.
74e6ae
# It also defines a %%postun script that does the same thing.
74e6ae
#	%%kernel_modules_internal_post [<subpackage>]
74e6ae
#
74e6ae
%define kernel_modules_internal_post() \
74e6ae
%{expand:%%post %{?1:%{1}-}modules-internal}\
74e6ae
/sbin/depmod -a %{KVERREL}%{?1:+%{1}}\
74e6ae
%{nil}\
74e6ae
%{expand:%%postun %{?1:%{1}-}modules-internal}\
74e6ae
/sbin/depmod -a %{KVERREL}%{?1:+%{1}}\
74e6ae
%{nil}
74e6ae
74e6ae
#
ba564c
# This macro defines a %%post script for a kernel*-modules package.
ba564c
# It also defines a %%postun script that does the same thing.
ba564c
#	%%kernel_modules_post [<subpackage>]
ba564c
#
ba564c
%define kernel_modules_post() \
ba564c
%{expand:%%post %{?1:%{1}-}modules}\
ba564c
/sbin/depmod -a %{KVERREL}%{?1:+%{1}}\
ba564c
%{nil}\
ba564c
%{expand:%%postun %{?1:%{1}-}modules}\
ba564c
/sbin/depmod -a %{KVERREL}%{?1:+%{1}}\
ba564c
%{nil}
ba564c
ba564c
# This macro defines a %%posttrans script for a kernel package.