Blame kernel-binary.spec.in

Bernhard M. Wiedemann 6ebc4a
#
Bernhard M. Wiedemann 6ebc4a
# spec file for package kernel-@FLAVOR@
Bernhard M. Wiedemann 6ebc4a
#
5c5b33
# Copyright (c) @YEAR@ SUSE LLC
Bernhard M. Wiedemann 6ebc4a
#
Bernhard M. Wiedemann 6ebc4a
# All modifications and additions to the file contributed by third parties
Bernhard M. Wiedemann 6ebc4a
# remain the property of their copyright owners, unless otherwise agreed
Bernhard M. Wiedemann 6ebc4a
# upon. The license for this file, and modifications and additions to the
Bernhard M. Wiedemann 6ebc4a
# file, is the same license as for the pristine package itself (unless the
Bernhard M. Wiedemann 6ebc4a
# license for the pristine package is not an Open Source License, in which
Bernhard M. Wiedemann 6ebc4a
# case the license is the MIT License). An "Open Source License" is a
Bernhard M. Wiedemann 6ebc4a
# license that conforms to the Open Source Definition (Version 1.9)
Bernhard M. Wiedemann 6ebc4a
# published by the Open Source Initiative.
Bernhard M. Wiedemann 6ebc4a
57a832
# Please submit bugfixes or comments via https://bugs.opensuse.org/
Bernhard M. Wiedemann 6ebc4a
#
Bernhard M. Wiedemann 6ebc4a
# needssslcertforbuild
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
%define srcversion @SRCVERSION@
Bernhard M. Wiedemann 6ebc4a
%define patchversion @PATCHVERSION@
Bernhard M. Wiedemann 878168
%define git_commit @COMMIT_FULL@
Bernhard M. Wiedemann 6ebc4a
%define variant @VARIANT@%{nil}
Bernhard M. Wiedemann 6ebc4a
%define compress_modules @COMPRESS_MODULES@
Bernhard M. Wiedemann b687c9
%define compress_vmlinux @COMPRESS_VMLINUX@
Bernhard M. Wiedemann 6ebc4a
%define livepatch @LIVEPATCH@%{nil}
c3597e
%define livepatch_rt @LIVEPATCH_RT@%{nil}
6a054f
%define sb_efi_only @SB_EFI_ONLY@
6a054f
%define split_base @SPLIT_BASE@
6a054f
%define split_optional @SPLIT_OPTIONAL@
6a054f
%define supported_modules_check @SUPPORTED_MODULES_CHECK@
7a1991
%define build_flavor @FLAVOR@
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
%include %_sourcedir/kernel-spec-macros
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
%(chmod +x %_sourcedir/{@SCRIPTS@})
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
Name:           kernel-@FLAVOR@
Bernhard M. Wiedemann 6ebc4a
Version:        @RPMVERSION@
Bernhard M. Wiedemann 6ebc4a
%if 0%{?is_kotd}
Bernhard M. Wiedemann 6ebc4a
Release:        <RELEASE>.g@COMMIT@
Bernhard M. Wiedemann 6ebc4a
%else
Bernhard M. Wiedemann 6ebc4a
Release:        @RELEASE@
Bernhard M. Wiedemann 6ebc4a
%endif
7a1991
Summary:        @SUMMARY@
7a1991
License:        GPL-2.0-only
7a1991
Group:          System/Kernel
57a832
URL:            https://www.kernel.org/
5c34fe
%if 0%{?suse_version} > 1500 || 0%{?sle_version} > 150300
5c34fe
BuildRequires:  bash-sh
5c34fe
%endif
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  bc
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  bison
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  coreutils
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  fdupes
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  flex
Bernhard M. Wiedemann 6ebc4a
# Cannot test %%CONFIG_GCC_PLUGINS here because the buildservice parser
Bernhard M. Wiedemann 6ebc4a
# does not expand %%(...)
Bernhard M. Wiedemann 6ebc4a
%if "%build_flavor" == "syzkaller"
Bernhard M. Wiedemann 6ebc4a
# Needed by scripts/gcc-plugin.sh
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  gcc-c++
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  gcc-devel
Bernhard M. Wiedemann 6ebc4a
%endif
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  hmaccalc
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  libopenssl-devel
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  modutils
db694b
BuildRequires:  python3-base
Bernhard M. Wiedemann 6ebc4a
# Used to sign the kernel in the buildservice
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  openssl
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  pesign-obs-integration
0af339
%if 0%{?suse_version} > 1500 || 0%{?sle_version} >= 150300
0af339
# pahole for CONFIG_DEBUG_INFO_BTF
0ccffb
BuildRequires:  dwarves >= 1.22
0af339
%endif
Bernhard M. Wiedemann 6ebc4a
# for objtool
Bernhard M. Wiedemann 6ebc4a
BuildRequires:  libelf-devel
dd32e5
# required for 50-check-kernel-build-id rpm check
dd32e5
BuildRequires:  elfutils
7999ff
%ifarch %arm
7999ff
BuildRequires:  u-boot-tools
7999ff
%endif
7999ff
# Do not install p-b and dracut for the install check, the %post script is
7999ff
# able to handle this
786718
#!BuildIgnore: perl-Bootloader dracut distribution-release suse-kernel-rpm-scriptlets
7999ff
# Remove some packages that are installed automatically by the build system,
7999ff
# but are not needed to build the kernel
7999ff
#!BuildIgnore: autoconf automake gettext-runtime libtool cvs gettext-tools udev insserv
Bernhard M. Wiedemann 878168
%if ! 0%{?is_kotd} || ! %{?is_kotd_qa}%{!?is_kotd_qa:0}
db694b
ExclusiveArch:  @ARCHS@
Bernhard M. Wiedemann 878168
%else
Bernhard M. Wiedemann 878168
ExclusiveArch:  do_not_build
Bernhard M. Wiedemann 878168
%endif
7a1991
7a1991
%ifarch %ix86 x86_64
7a1991
%define image vmlinuz
7a1991
%endif
7a1991
%ifarch ppc ppc64 ppc64le
7a1991
%define image vmlinux
7a1991
%endif
7a1991
%ifarch s390 s390x
7a1991
%define image image
7a1991
%endif
7a1991
%ifarch %arm
7a1991
%define image zImage
7a1991
%endif
7a1991
%ifarch aarch64 riscv64
7a1991
%define image Image
7a1991
%endif
7a1991
7a1991
%ifarch %ix86 x86_64
7a1991
%define install_vdso 1
7a1991
%if 0%{?suse_version} > 1500 || 0%{?sle_version} >= 150500
7a1991
%define separate_vdso 1
7a1991
%endif
7a1991
%else
7a1991
%define install_vdso 0
7a1991
%endif
7a1991
7a1991
%define build_default	("%build_flavor" == "default")
7a1991
%define build_vanilla	("%build_flavor" == "vanilla")
7a1991
%define vanilla_only    %{lua: if (rpm.expand("%variant") == "-vanilla") then print(1) else print(0) end}
7a1991
7a1991
%if ! %build_vanilla
7a1991
%define src_install_dir /usr/src/linux-%kernelrelease%variant
7a1991
%else
7a1991
%define src_install_dir /usr/src/linux-%kernelrelease-vanilla
7a1991
%endif
7a1991
%define obj_install_dir /usr/src/linux-%kernelrelease%variant-obj
7a1991
%define rpm_install_dir %buildroot%obj_install_dir
7a1991
%define kernel_build_dir %my_builddir/linux-%srcversion/linux-obj
7a1991
%define modules_dir %kernel_module_directory/%kernelrelease-%build_flavor
7a1991
7a1991
%global cpu_arch %(%_sourcedir/arch-symbols %_target_cpu)
7a1991
%define cpu_arch_flavor %cpu_arch/%build_flavor
7a1991
7a1991
%if 0%{?_project:1} && ( %(echo %_project | grep -Ex -f %_sourcedir/release-projects | grep -v ^PTF | grep -vc openSUSE) || %(echo %_project | grep -Ec "^(Devel:)?Kernel:") )
7a1991
	%define klp_symbols 1
7a1991
%endif
7a1991
7a1991
# Define some CONFIG variables as rpm macros as well. (rpm cannot handle
7a1991
# defining them all at once.)
7a1991
%define config_vars CONFIG_MODULES CONFIG_MODULE_SIG CONFIG_MODULE_SIG_HASH CONFIG_KMSG_IDS CONFIG_SUSE_KERNEL_SUPPORTED CONFIG_EFI_STUB CONFIG_LIVEPATCH_IPA_CLONES CONFIG_DEBUG_INFO_BTF_MODULES CONFIG_PREEMPT_DYNAMIC
7a1991
%{expand:%(eval "$(test -n "%cpu_arch_flavor" && tar -xjf %_sourcedir/config.tar.bz2 --to-stdout config/%cpu_arch_flavor)"; for config in %config_vars; do echo "%%global $config ${!config:-n}"; done)}
7a1991
%define split_extra ("%CONFIG_MODULES" == "y" && "%CONFIG_SUSE_KERNEL_SUPPORTED" == "y")
7a1991
7a1991
%if "%CONFIG_MODULES" != "y"
7a1991
	%define klp_symbols 0
7a1991
%endif
7a1991
7a1991
%global certs %( space="" ; for f in %_sourcedir/*.crt; do                                              \
7a1991
    if ! test -e "$f"; then                                                                             \
7a1991
        continue                                                                                        \
7a1991
    fi                                                                                                  \
7a1991
    h=$(openssl x509 -inform PEM -fingerprint -noout -in "$f")                                          \
7a1991
    if [ -z "$h" ] ; then                                                                               \
7a1991
        echo Cannot parse "$f" >&2                                                                      \
7a1991
        confinue                                                                                        \
7a1991
    fi                                                                                                  \
7a1991
    cert=$(echo "$h" | sed -rn 's/^SHA1 Fingerprint=//; T; s/://g; s/(.{8}).*/\\1/p')                   \
7a1991
    echo Found signing certificate "$f" "($cert)" >&2                                                   \
7a1991
    cat "$f" >>%_sourcedir/.kernel_signing_key.pem                                                      \
7a1991
    mkdir -p %_sourcedir/.kernel_signing_certs                                                          \
7a1991
    openssl x509 -inform PEM -in "$f" -outform DER -out %_sourcedir/.kernel_signing_certs/"$cert".crt   \
7a1991
    echo -n "$space$cert" ; space=" "                                                                   \
7a1991
done )
7a1991
7a1991
@SOURCES@
7a1991
db694b
%ifarch %ix86
db694b
# Only i386/default supports i586, mark other flavors' packages as i686
db694b
%if ! %build_default
db694b
BuildArch:      i686
db694b
%endif
db694b
%endif
7999ff
# Force bzip2 instead of lzma compression to
7999ff
# 1) allow install on older dist versions, and
7999ff
# 2) decrease build times (bsc#962356 boo#1175882)
7999ff
%define _binary_payload w9.bzdio
7999ff
# Do not recompute the build-id of vmlinux in find-debuginfo.sh (bsc#964063)
7999ff
%undefine _unique_build_ids
7999ff
%define _no_recompute_build_ids 1
7999ff
# prevent usr/lib/debug/boot/vmlinux-4.12.14-11.10-default-4.12.14-11.10.ppc64le.debug
7999ff
%undefine _unique_debug_names
7999ff
2e84a6
%if "%{compress_modules}" == "zstd"
2e84a6
BuildRequires:  zstd
2e84a6
# Make sure kmod supports zstd compressed modules
2e84a6
Requires(post): kmod-zstd
2e84a6
%endif
Bernhard M. Wiedemann 6ebc4a
Provides:       %name = %version-%source_rel
Bernhard M. Wiedemann 6ebc4a
# bnc#901925
Bernhard M. Wiedemann 6ebc4a
Provides:       %name-%version-%source_rel
Bernhard M. Wiedemann 6ebc4a
Provides:       %{name}_%_target_cpu = %version-%source_rel
Bernhard M. Wiedemann 6ebc4a
Provides:       kernel-base = %version-%source_rel
Bernhard M. Wiedemann 6ebc4a
Provides:       multiversion(kernel)
Bernhard M. Wiedemann 6ebc4a
# In SLE11, kernel-$flavor complemented kernel-$flavor-base. With SLE12,
Bernhard M. Wiedemann 6ebc4a
# kernel-$flavor itself contains all the needed files and kernel-$flavor-base
Bernhard M. Wiedemann 6ebc4a
# is a subset that can replace kernel-$flavor in some scenarios. We need to
Bernhard M. Wiedemann 6ebc4a
# obsolete the -base subpackage from SLE11, so that the base files are not
Bernhard M. Wiedemann 6ebc4a
# owned by multiple packages now. The dependency is not correct wrt openSUSE
Bernhard M. Wiedemann 6ebc4a
# 11.2 - 11.4, but we primarily care about the supported upgrade path.
Bernhard M. Wiedemann 6ebc4a
Obsoletes:      %name-base < 3.1
Bernhard M. Wiedemann 1fce88
%if ("%build_flavor" != "kvmsmall") && ("%build_flavor" != "azure")
Bernhard M. Wiedemann 6ebc4a
Recommends: kernel-firmware
Bernhard M. Wiedemann 1fce88
%endif
Bernhard M. Wiedemann 6ebc4a
# The following is copied to the -base subpackage as well
Bernhard M. Wiedemann 6ebc4a
# BEGIN COMMON DEPS
7a4f11
Requires(pre):  suse-kernel-rpm-scriptlets
0d5147
Requires(post): suse-kernel-rpm-scriptlets
0d5147
Requires:       suse-kernel-rpm-scriptlets
0d5147
Requires(preun): suse-kernel-rpm-scriptlets
7a4f11
Requires(postun): suse-kernel-rpm-scriptlets
Bernhard M. Wiedemann 6ebc4a
Requires(pre):  coreutils awk
Bernhard M. Wiedemann 878168
# For /usr/lib/module-init-tools/weak-modules2 and /usr/lib/modprobe.d/*.conf
Bernhard M. Wiedemann 6ebc4a
Requires(post): suse-module-tools
Bernhard M. Wiedemann 878168
Requires:       suse-module-tools
Bernhard M. Wiedemann 6ebc4a
# For depmod (modutils is a dependency provided by both module-init-tools and
Bernhard M. Wiedemann 6ebc4a
# kmod-compat)
Bernhard M. Wiedemann 6ebc4a
Requires(post): modutils
Bernhard M. Wiedemann 6ebc4a
# This Requires is wrong, because the post/postun scripts have a
Bernhard M. Wiedemann 6ebc4a
# test -x update-bootloader, having perl-Bootloader is not a hard requirement.
Bernhard M. Wiedemann 6ebc4a
# But, there is no way to tell rpm or yast to schedule the installation
Bernhard M. Wiedemann 6ebc4a
# of perl-Bootloader before kernel-binary.rpm if both are in the list of
0d5147
# packages to install/update. Likewise, this is true for dracut.
Bernhard M. Wiedemann 6ebc4a
# Need a perl-Bootloader with /usr/lib/bootloader/bootloader_entry
Bernhard M. Wiedemann 6ebc4a
Requires(post): perl-Bootloader >= 0.4.15
0d5147
Requires(post): dracut
Bernhard M. Wiedemann 6ebc4a
# Install the package providing /etc/SuSE-release early enough, so that
Bernhard M. Wiedemann 6ebc4a
# the grub entry has correct title (bnc#757565)
Bernhard M. Wiedemann 6ebc4a
Requires(post): distribution-release
Bernhard M. Wiedemann 6ebc4a
7a1991
%if %{usrmerged}
c69a94
# make sure we have a post-usrmerge system
c69a94
Conflicts:      filesystem < 16
9a48dc
%endif
Bernhard M. Wiedemann 6ebc4a
ca360f
Obsoletes:      microcode_ctl < 1.18
Bernhard M. Wiedemann 6ebc4a
6a054f
%{lua:	fd, err = io.open(rpm.expand('%_sourcedir') .. '/kernel-binary-conflicts')
6a054f
	if not fd then io.stderr:write(err) end
6a054f
	unpack = table.unpack or unpack
6a054f
	for l in fd:lines() do
6a054f
		if #l > 0 and l:sub(1,1) ~= '#' then
6a054f
			words = {} ; for w in l:gmatch("([^%s]+)%s*") do table.insert(words, w) end
6a054f
			package, version = unpack(words)
6a054f
			print('Conflicts: ' .. package .. ' < '.. version .. '\n')
6a054f
		end
6a054f
	end
6a054f
	fd:close()
6a054f
}
6a054f
Bernhard M. Wiedemann 6ebc4a
%ifarch %ix86
Bernhard M. Wiedemann 6ebc4a
Conflicts:      libc.so.6()(64bit)
Bernhard M. Wiedemann 6ebc4a
%endif
Bernhard M. Wiedemann 6ebc4a
Provides:       kernel = %version-%source_rel
Bernhard M. Wiedemann 878168
Provides:       kernel-%build_flavor-base-srchash-%git_commit
Bernhard M. Wiedemann 878168
Provides:       kernel-srchash-%git_commit
Bernhard M. Wiedemann 6ebc4a
# END COMMON DEPS
Bernhard M. Wiedemann 878168
Provides:       %name-srchash-%git_commit
Bernhard M. Wiedemann 6ebc4a
@PROVIDES_OBSOLETES@
Bernhard M. Wiedemann 6ebc4a
@PROVIDES_OBSOLETES_BASE@
Bernhard M. Wiedemann 6ebc4a
%obsolete_rebuilds %name
1d2ab9
Bernhard M. Wiedemann 6ebc4a
%define kmp_target_cpu %_target_cpu
Bernhard M. Wiedemann 6ebc4a
%ifarch %ix86
Bernhard M. Wiedemann 6ebc4a
# KMPs are always built as i586, because rpm does not allow to build
Bernhard M. Wiedemann 6ebc4a
# subpackages for different architectures. Therefore, we change the
Bernhard M. Wiedemann 6ebc4a
# /usr/src/linux-obj/<arch> symlink to i586.
Bernhard M. Wiedemann 6ebc4a
%define kmp_target_cpu i586
Bernhard M. Wiedemann 6ebc4a
%endif
Bernhard M. Wiedemann 6ebc4a
6a054f
%if %build_default
6a054f
%if "%CONFIG_PREEMPT_DYNAMIC" == "y"
6a054f
Provides:       kernel-preempt = %version-%release
6a054f
Provides:       kernel-preempt_%_target_cpu = %version-%source_rel
6a054f
%endif
6a054f
%endif
6a054f
6a054f
%{lua:	fd, err = io.open(rpm.expand('%_sourcedir') .. '/obsolete-kmps')
6a054f
	if not fd then io.stderr:write(err) end
6a054f
	unpack = table.unpack or unpack
6a054f
	for l in fd:lines() do
6a054f
		if #l > 0 and l:sub(1,1) ~= '#' then
6a054f
			words = {} ; for w in l:gmatch("([^%s]+)%s*") do table.insert(words, w) end
6a054f
			package, version = unpack(words)
6a054f
			print('Obsoletes: ' .. package .. '-kmp-' .. rpm.expand('%build_flavor') .. ' <= '.. version .. '\n')
6a054f
			print('Provides: ' .. package .. '-kmp = ' .. version .. '.1\n')
6a054f
			print('Provides: ' .. package .. '-kmp-' .. rpm.expand('%build_flavor') .. ' = '.. version .. '.1\n')
6a054f
		end
6a054f
	end
6a054f
	fd:close()
6a054f
}
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
%description
Bernhard M. Wiedemann 6ebc4a
@DESCRIPTION@
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
%source_timestamp
Bernhard M. Wiedemann 6ebc4a
7a1991
%pre
7a1991
%if "%build_flavor" != "zfcpdump"
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/rpm-pre --name "%name" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
%endif
7a1991
%post
7a1991
%if "%build_flavor" != "zfcpdump"
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/rpm-post --name "%name" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
bd7477
%endif
7a1991
%preun
7a1991
%if "%build_flavor" != "zfcpdump"
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/rpm-preun --name "%name" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
%endif
7a1991
%postun
7a1991
%if "%build_flavor" != "zfcpdump"
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/rpm-postun --name "%name" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
7a1991
%endif
7a1991
%posttrans
7a1991
%if "%build_flavor" != "zfcpdump"
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/rpm-posttrans --name "%name" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
7a1991
%endif
7a1991
%files -f kernel-main.files
Bernhard M. Wiedemann 6ebc4a
7a1991
%if "%CONFIG_MODULES" == "y" && %split_base
7a1991
%package base
7a1991
Summary:        @SUMMARY@ - base modules
7a1991
Group:          System/Kernel
7a1991
Url:            http://www.kernel.org/
7a1991
Provides:       kernel-base = %version-%source_rel
7a1991
Provides:       multiversion(kernel)
7a1991
Conflicts:      %name = %version-%source_rel
7a1991
@COMMON_DEPS@
7a1991
@PROVIDES_OBSOLETES_BASE@
7a1991
%obsolete_rebuilds %name-base
7a1991
%ifarch %ix86
7a1991
Conflicts:      libc.so.6()(64bit)
7a1991
%endif
Bernhard M. Wiedemann 6ebc4a
7a1991
%description base
7a1991
@DESCRIPTION@
Bernhard M. Wiedemann 6ebc4a
7a1991
This package contains only the base modules, required in all installs.
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
7a1991
%source_timestamp
7a1991
%pre base
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/rpm-pre --name "%name-base" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
7a1991
%post base
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/rpm-post --name "%name-base" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
2f5b95
7a1991
%preun base
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/rpm-preun --name "%name-base" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
7a1991
%postun base
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/rpm-postun --name "%name-base" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
735e77
7a1991
%posttrans base
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/rpm-posttrans --name "%name-base" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
735e77
7a1991
%files base -f kernel-base.files
7a1991
%endif
00af90
7a1991
%package extra
7a1991
Summary:        @SUMMARY@ - Unsupported kernel modules
7a1991
Group:          System/Kernel
7a1991
URL:            https://www.kernel.org/
7a1991
Provides:       %name-extra_%_target_cpu = %version-%source_rel
7a1991
Provides:       kernel-extra = %version-%source_rel
7a1991
Provides:       multiversion(kernel)
7a1991
Requires:       %{name}_%_target_cpu = %version-%source_rel
7a1991
Requires(pre):  coreutils awk
7a1991
Requires(post): modutils
7a1991
Requires(post): perl-Bootloader
7a1991
Requires(post): dracut
7a1991
@PROVIDES_OBSOLETES_EXTRA@
7a1991
%obsolete_rebuilds %name-extra
7a1991
Supplements:    packageand(product(SLED):%{name}_%_target_cpu)
7a1991
Supplements:    packageand(product(sle-we):%{name}_%_target_cpu)
7a1991
Supplements:    packageand(product(Leap):%{name}_%_target_cpu)
7a1991
%ifarch %ix86
7a1991
Conflicts:      libc.so.6()(64bit)
7a1991
%endif
7a1991
%if %build_default
7a1991
%if "%CONFIG_PREEMPT_DYNAMIC" == "y"
7a1991
Provides:       kernel-preempt-extra = %version-%release
7a1991
Provides:       kernel-preempt-extra_%_target_cpu = %version-%source_rel
7a1991
%endif
7a1991
%endif
Bernhard M. Wiedemann 6ebc4a
7a1991
%description extra
7a1991
@DESCRIPTION@
Bernhard M. Wiedemann 6ebc4a
7a1991
This package contains additional modules not supported by SUSE.
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
7a1991
%source_timestamp
Bernhard M. Wiedemann 6ebc4a
7a1991
%pre extra
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-pre --name "%name-extra" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
7a1991
%post extra
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-post --name "%name-extra" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
7a1991
%preun extra
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-preun --name "%name-extra" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
7a1991
%postun extra
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-postun --name "%name-extra" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
7a1991
%posttrans extra
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-posttrans --name "%name-extra" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
7a1991
7a1991
%if %split_extra
7a1991
7a1991
%files extra -f kernel-extra.files
Bernhard M. Wiedemann 6ebc4a
%endif
Bernhard M. Wiedemann 6ebc4a
7a1991
%if %split_extra && %split_optional
7a1991
%package optional
7a1991
Summary:        @SUMMARY@ - Optional kernel modules
7a1991
Group:          System/Kernel
7a1991
URL:            https://www.kernel.org/
7a1991
Provides:       %name-optional_%_target_cpu = %version-%source_rel
7a1991
Provides:       kernel-optional = %version-%source_rel
7a1991
Provides:       multiversion(kernel)
7a1991
Requires:       %name-extra_%_target_cpu = %version-%source_rel
7a1991
Requires(pre):  coreutils awk
7a1991
Requires(post): modutils
7a1991
Requires(post): perl-Bootloader
7a1991
Requires(post): dracut
7a1991
@PROVIDES_OBSOLETES_OPTIONAL@
7a1991
%obsolete_rebuilds %name-optional
7a1991
Supplements:    packageand(product(Leap):%{name}_%_target_cpu)
7a1991
%ifarch %ix86
7a1991
Conflicts:      libc.so.6()(64bit)
7a1991
%endif
7a1991
%if %build_default
7a1991
%if "%CONFIG_PREEMPT_DYNAMIC" == "y"
7a1991
Provides:       kernel-preempt-optional = %version-%release
7a1991
Provides:       kernel-preempt-optional_%_target_cpu = %version-%source_rel
7a1991
%endif
Bernhard M. Wiedemann 6ebc4a
%endif
Bernhard M. Wiedemann 6ebc4a
7a1991
%description optional
7a1991
@DESCRIPTION@
Bernhard M. Wiedemann 6ebc4a
7a1991
This package contains optional modules only for openSUSE Leap.
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
7a1991
%source_timestamp
Bernhard M. Wiedemann 6ebc4a
7a1991
%pre optional
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-pre --name "%name-optional" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
7a1991
%post optional
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-post --name "%name-optional" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
7a1991
%preun optional
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-preun --name "%name-optional" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
7a1991
%postun optional
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-postun --name "%name-optional" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
7a1991
7a1991
%posttrans optional
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-posttrans --name "%name-optional" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
7a1991
7a1991
%files optional -f kernel-optional.files
Bernhard M. Wiedemann 6ebc4a
%endif
7a1991
5c5b33
%if "%CONFIG_KMSG_IDS" == "y"
Bernhard M. Wiedemann 6ebc4a
7a1991
%package man
7a1991
Summary:        The collection of man pages generated by the kmsg script
7a1991
Group:          System/Kernel
7a1991
7a1991
%description man
7a1991
This package includes the man pages that have been generated from the
7a1991
kmsg message documentation comments.
7a1991
7a1991
7a1991
%source_timestamp
7a1991
%files man
7a1991
/usr/share/man/man9/*
Bernhard M. Wiedemann 6ebc4a
%endif
7a1991
7a1991
%if 0%{?separate_vdso}
7a1991
%package vdso
7a1991
Summary:        vdso binaries for debugging purposes
7a1991
Group:          System/Kernel
7a1991
7a1991
%description vdso
7a1991
This package includes the vdso binaries. They can be used for debugging. The
7a1991
actual binary linked to the programs is loaded from the in-memory image, not
7a1991
from this package.
7a1991
7a1991
7a1991
%source_timestamp
7a1991
%files vdso
7a1991
%modules_dir/vdso/
32c425
%endif
7a1991
7a1991
%package devel
7a1991
Summary:        Development files necessary for building kernel modules
7a1991
Group:          Development/Sources
7a1991
Provides:       %name-devel = %version-%source_rel
7a1991
Provides:       multiversion(kernel)
7a1991
%if ! %build_vanilla && ! %vanilla_only
7a1991
Requires:       kernel-devel%variant = %version-%source_rel
7a1991
Recommends:     make
7a1991
Recommends:     gcc
7a1991
Recommends:     perl
7a1991
# for objtool
7a1991
Requires:	libelf-devel
7a1991
Supplements:    packageand(%name:kernel-devel%variant)
32c425
%else
7a1991
Requires:       kernel-source-vanilla = %version-%source_rel
7a1991
Supplements:    packageand(%name:kernel-source-vanilla)
Bernhard M. Wiedemann 6ebc4a
%endif
7a1991
%if "%CONFIG_DEBUG_INFO_BTF_MODULES" == "y"
7a1991
Requires:       dwarves >= 1.22
Bernhard M. Wiedemann 6ebc4a
%endif
7a1991
%if %build_default
7a1991
%if "%CONFIG_PREEMPT_DYNAMIC" == "y"
7a1991
Provides:       kernel-preempt-devel = %version-%release
Bernhard M. Wiedemann 6ebc4a
%endif
9b9006
%endif
7a1991
@PROVIDES_OBSOLETES_DEVEL@
7a1991
%obsolete_rebuilds %name-devel
7a1991
PreReq:         coreutils
Bernhard M. Wiedemann 6ebc4a
7a1991
%description devel
7a1991
This package contains files necessary for building kernel modules (and
7a1991
kernel module packages) against the %build_flavor flavor of the kernel.
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
7a1991
%source_timestamp
7a1991
7a1991
%if "%CONFIG_MODULES" == "y"
7a1991
7a1991
%pre devel
7a1991
7a1991
# handle update from an older kernel-source with linux-obj as symlink
7a1991
if [ -h /usr/src/linux-obj ]; then
7a1991
    rm -vf /usr/src/linux-obj
Bernhard M. Wiedemann 6ebc4a
fi
Bernhard M. Wiedemann 6ebc4a
7a1991
%post devel
7a1991
%relink_function
Bernhard M. Wiedemann 6ebc4a
7a1991
relink ../../linux-%{kernelrelease}%{variant}-obj/"%cpu_arch_flavor" /usr/src/linux-obj/"%cpu_arch_flavor"
Bernhard M. Wiedemann 6ebc4a
7a1991
%files devel -f kernel-devel.files
7a1991
%dir /usr/src/linux-obj
7a1991
%dir /usr/src/linux-obj/%cpu_arch
7a1991
%ghost /usr/src/linux-obj/%cpu_arch_flavor
7a1991
%exclude %obj_install_dir/%cpu_arch_flavor/Symbols.list
7a1991
%if "%kmp_target_cpu" != "%cpu_arch"
7a1991
%obj_install_dir/%kmp_target_cpu
7a1991
/usr/src/linux-obj/%kmp_target_cpu
Bernhard M. Wiedemann 6ebc4a
%endif
Bernhard M. Wiedemann 6ebc4a
7a1991
%if "%livepatch" != "" && "%CONFIG_SUSE_KERNEL_SUPPORTED" == "y" && (("%variant" == "" && %build_default) || ("%variant" == "-rt" && 0%livepatch_rt))
7a1991
%if "%livepatch" == "kgraft"
7a1991
%define patch_package %{livepatch}-patch
7a1991
%else
7a1991
%define patch_package kernel-%{livepatch}
7a1991
%endif
7a1991
%package %{livepatch}
7a1991
Summary:        Metapackage to pull in matching %patch_package package
7a1991
Group:          System/Kernel
7a1991
Requires:       %{patch_package}-%(echo %{version}-%{source_rel} | sed 'y/\./_/')-%{build_flavor}
7a1991
Provides:       multiversion(kernel)
7a1991
%if "%variant" != "-rt"
7a1991
Provides:	kernel-default-kgraft = %version
7a1991
Provides:	kernel-xen-kgraft = %version
7a1991
%if "%livepatch" != "kgraft"
7a1991
Obsoletes:	kernel-default-kgraft < %version
7a1991
Obsoletes:	kernel-xen-kgraft < %version
7a1991
%endif
7a1991
%endif
Bernhard M. Wiedemann 6ebc4a
7a1991
%description %{livepatch}
7a1991
This is a metapackage that pulls in the matching %patch_package package for a
7a1991
given kernel version. The advantage of the metapackage is that its name is
7a1991
static, unlike the %{patch_package}-<kernel-version>-flavor package names.
Bernhard M. Wiedemann 4b7a24
7a1991
%files %{livepatch}
7a1991
# rpmlint complains about empty packages, so lets own something
7a1991
%dir %modules_dir
6a054f
%endif
Bernhard M. Wiedemann 6ebc4a
7a1991
%if 0%{?klp_symbols} && "%livepatch" != ""
7a1991
%package %{livepatch}-devel
7a1991
Summary:	Kernel symbols file used during kGraft patch development
7a1991
Group:		System/Kernel
7a1991
Provides:	klp-symbols = %version
Bernhard M. Wiedemann 6ebc4a
7a1991
%description %{livepatch}-devel
7a1991
This package brings a file named Symbols.list, which contains a list of all
7a1991
kernel symbols and its respective kernel object . This list is to be used by
7a1991
the klp-convert tool, which helps livepatch developers by enabling automatic
7a1991
symbol resolution.
Bernhard M. Wiedemann 6ebc4a
7a1991
%files %{livepatch}-devel -f livepatch-files
7a1991
%endif
Bernhard M. Wiedemann 6ebc4a
5c5b33
%if "%CONFIG_SUSE_KERNEL_SUPPORTED" == "y"
7a1991
# BEGIN KMP
7a1991
%package -n @KMP_NAME@-%build_flavor
7a1991
Summary:        @KMP_SUMMARY@
7a1991
Group:          System/Kernel
7a1991
Requires:       %name = %version-%source_rel
7a1991
Provides:       @KMP_NAME@ = %version-%source_rel
7a1991
Provides:       multiversion(kernel)
7a1991
# tell weak-modules2 to ignore this package
7a1991
Provides:       kmp_in_kernel
7a1991
Requires(post): suse-module-tools >= 12.4
7a1991
%if %build_default
7a1991
%if "%CONFIG_PREEMPT_DYNAMIC" == "y"
7a1991
Provides:       @KMP_NAME@-preempt = %version-%release
Bernhard M. Wiedemann 6ebc4a
%endif
Bernhard M. Wiedemann 6ebc4a
%endif
7a1991
Enhances:	%name
7a1991
Supplements:	packageand(%name:@KMP_NAME@-%build_flavor)
7a1991
@KMP_DEPS@
Bernhard M. Wiedemann 6ebc4a
7a1991
%description -n @KMP_NAME@-%build_flavor
7a1991
@KMP_DESCRIPTION@
Bernhard M. Wiedemann 6ebc4a
7a1991
%pre -n @KMP_NAME@-%build_flavor
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-pre --name "@KMP_NAME@-%build_flavor" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
7a1991
%post -n @KMP_NAME@-%build_flavor
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-post --name "@KMP_NAME@-%build_flavor" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
7a1991
%preun -n @KMP_NAME@-%build_flavor
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-preun --name "@KMP_NAME@-%build_flavor" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
Bernhard M. Wiedemann 6ebc4a
7a1991
%postun -n @KMP_NAME@-%build_flavor
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-postun --name "@KMP_NAME@-%build_flavor" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
dd32e5
7a1991
%posttrans -n @KMP_NAME@-%build_flavor
7a1991
%run_if_exists /usr/lib/module-init-tools/kernel-scriptlets/inkmp-posttrans --name "@KMP_NAME@-%build_flavor" \
7a1991
  --version "%version" --release "%release" --kernelrelease "%kernelrelease" \
7a1991
  --image "%image" --flavor "%build_flavor" --variant "%variant" \
7a1991
  --usrmerged "%{usrmerged}" --certs "%certs" "$@"
7a1991
7a1991
%files -n @KMP_NAME@-%build_flavor -f @KMP_NAME@.files
7a1991
# END KMP
7a1991
%endif # %CONFIG_SUSE_KERNEL_SUPPORTED
7a1991
%endif # %CONFIG_MODULES
7a1991
7a1991
%prep
7a1991
if ! [ -e %{S:0} ]; then
7a1991
    echo "The %name-%version.nosrc.rpm package does not contain the" \
7a1991
	 "complete sources. Please install kernel-source-%version.src.rpm."
7a1991
    exit 1
Bernhard M. Wiedemann 6ebc4a
fi
Bernhard M. Wiedemann 6ebc4a
7a1991
SYMBOLS=
7a1991
if test -e %_sourcedir/extra-symbols; then
7a1991
	SYMBOLS=$(cat %_sourcedir/extra-symbols)
7a1991
	echo "extra symbol(s):" $SYMBOLS
7a1991
fi
786718
7a1991
# Unpack all sources and patches
7a1991
%setup -q -c -T -a 0 @UNPACK_PATCHES@
786718
7a1991
mkdir -p %kernel_build_dir
786718
7a1991
# Generate a list of modules with their support status marking
7a1991
# The first marker is supposed to be either "+external", "-" or "-!optional",
7a1991
# where "+external" is for an externally supported module, "-" is for an
7a1991
# unsuppored module, "-!optional" is for Leap-only unsupported module.
7a1991
# There can be an optional arch-specific second marker with "+arch" (e.g.
7a1991
# +arm64), which enforces the module to be supported on the specific arch.
7a1991
%_sourcedir/guards --list --with-guards <%_sourcedir/supported.conf | \
7a1991
awk '{
7a1991
    t = "";
7a1991
    for (i = 1; i < NF; i++) {
7a1991
	if ($i == "+external") {
7a1991
		t = " external";
7a1991
	} else if ($i == "+'%cpu_arch'") {
7a1991
		t = "";
7a1991
	} else if ($i ~ "^-") {
7a1991
		t = " no";
7a1991
	}
7a1991
    }
7a1991
    print $(NF) t;
7a1991
}' >%kernel_build_dir/Module.supported
7a1991
subpackages=(
7a1991
	base
7a1991
%if "%CONFIG_SUSE_KERNEL_SUPPORTED" == "y"
7a1991
	@KMPS@
7a1991
%endif
7a1991
)
7a1991
for package in "${subpackages[@]}"; do
7a1991
	%_sourcedir/guards --default=0 "$package" \
7a1991
		<%_sourcedir/supported.conf | sed 's,.*/,,; s,\.ko$,,' | \
7a1991
		sort -u >%kernel_build_dir/Module."$package"
7a1991
done
7a1991
%if %split_extra && %split_optional
7a1991
# Module.optional is in a special form, containing guard markers for
7a1991
# both extra and optional modules, which is processed by split-modules
7a1991
%_sourcedir/guards --list --with-guards <%_sourcedir/supported.conf | \
7a1991
awk '{
7a1991
    t = "";
7a1991
    for (i = 1; i < NF; i++) {
7a1991
	if ($i == "+'%cpu_arch'") {
7a1991
		t = "";
7a1991
	} else if ($i ~ "^-") {
7a1991
		t = $i
7a1991
	}
7a1991
    }
7a1991
    if (t != "") {print t,$(NF);}
7a1991
}' >%kernel_build_dir/Module.optional
7a1991
%endif
Bernhard M. Wiedemann 6ebc4a
7a1991
cd linux-%srcversion
Bernhard M. Wiedemann 6ebc4a
7a1991
%_sourcedir/apply-patches \
7a1991
%if %{build_vanilla} && ! %vanilla_only
7a1991
	--vanilla \
7a1991
%endif
7a1991
	%_sourcedir/series.conf .. $SYMBOLS
7a1991
7a1991
cd %kernel_build_dir
7a1991
7a1991
# Override the timestamp 'uname -v' reports with the source timestamp and
7a1991
# the commit hash.
7a1991
date=$(head -n 1 %_sourcedir/source-timestamp)
7a1991
commit=$(sed -n 's/GIT Revision: //p' %_sourcedir/source-timestamp)
7a1991
cat > .kernel-binary.spec.buildenv <
7a1991
export KBUILD_BUILD_TIMESTAMP="$(LANG=C date -d "$date") (${commit:0:7})"
7a1991
export KBUILD_VERBOSE=0
7a1991
export KBUILD_SYMTYPES=1
7a1991
export KBUILD_BUILD_USER=geeko
7a1991
export KBUILD_BUILD_HOST=buildhost
7a1991
export HOST_EXTRACFLAGS="-include %_sourcedir/host-memcpy-hack.h"
7a1991
EOF
7a1991
source .kernel-binary.spec.buildenv
7a1991
7a1991
if [ -f %_sourcedir/localversion ] ; then
7a1991
    cat %_sourcedir/localversion > localversion
Bernhard M. Wiedemann 4b7a24
fi
Bernhard M. Wiedemann 4b7a24
7a1991
config_base="default"
7a1991
%ifarch %ix86
7a1991
config_base="pae"
32c425
%endif
7a1991
if ! [ -f %my_builddir/config/%cpu_arch/$config_base ] ; then
7a1991
    config_base=%variant
7a1991
    config_base=${config_base#-}
7a1991
fi
7a1991
if ! grep -q CONFIG_MMU= "%my_builddir/config/%cpu_arch_flavor"; then
7a1991
cp "%my_builddir/config/%cpu_arch/$config_base" .config
7a1991
../scripts/kconfig/merge_config.sh -m .config \
7a1991
                                   %my_builddir/config/%cpu_arch_flavor
7a1991
else
7a1991
cp %my_builddir/config/%cpu_arch_flavor .config
7a1991
fi
7a1991
if test -e %my_builddir/config.addon/%cpu_arch_flavor; then
7a1991
	# FIXME: config.addon doesn't affect the %CONFIG_ macros defined at
7a1991
	# the top of the specfile
7a1991
	../scripts/kconfig/merge_config.sh -m .config %my_builddir/config.addon/%cpu_arch_flavor
7a1991
fi
Bernhard M. Wiedemann 6ebc4a
7a1991
CONFIG_SUSE_KERNEL_RELEASED="--disable CONFIG_SUSE_KERNEL_RELEASED"
7a1991
%if 0%{?_project:1}
7a1991
if echo %_project | grep -Eqx -f %_sourcedir/release-projects; then
7a1991
	CONFIG_SUSE_KERNEL_RELEASED="--enable CONFIG_SUSE_KERNEL_RELEASED"
7a1991
fi
32c425
%endif
7a1991
7a1991
DEBUG_INFO_TYPE="$(grep "CONFIG_DEBUG_INFO_DWARF.*=y" .config)"
7a1991
DEBUG_INFO_TYPE="${DEBUG_INFO_TYPE%%=y}"
7a1991
DEBUG_INFO_TYPE="${DEBUG_INFO_TYPE##CONFIG_DEBUG_INFO_}"
7a1991
echo "Kernel debuginfo type: ${DEBUG_INFO_TYPE}"
7a1991
7a1991
../scripts/config \
7a1991
	--set-str CONFIG_LOCALVERSION -%source_rel-%build_flavor \
7a1991
	--enable  CONFIG_SUSE_KERNEL \
7a1991
	$CONFIG_SUSE_KERNEL_RELEASED \
7a1991
%if 0%{?__debug_package:1}
7a1991
	--enable  CONFIG_DEBUG_INFO
32c425
%else
7a1991
	--disable CONFIG_DEBUG_INFO \
7a1991
	--disable CONFIG_DEBUG_INFO_"${DEBUG_INFO_TYPE}" \
7a1991
	--enable  CONFIG_DEBUG_INFO_NONE
32c425
%endif
Bernhard M. Wiedemann 6ebc4a
7a1991
if [ %CONFIG_MODULE_SIG = "y" ]; then
7a1991
	if [ -n "%certs" ] ; then
7a1991
		ln -s %_sourcedir/.kernel_signing_key.pem .
7a1991
	else
7a1991
		if ! [ -f .kernel.genkey ] ; then
7a1991
			cat > .kernel.genkey <
7a1991
[ req ]
7a1991
default_bits = 4096
7a1991
distinguished_name = req_distinguished_name
7a1991
prompt = no
7a1991
string_mask = utf8only
7a1991
x509_extensions = myexts
Bernhard M. Wiedemann 6ebc4a
7a1991
[ req_distinguished_name ]
7a1991
CN = Build time autogenerated kernel key
bd7477
7a1991
[ myexts ]
7a1991
basicConstraints=critical,CA:FALSE
7a1991
keyUsage=digitalSignature
7a1991
subjectKeyIdentifier=hash
7a1991
authorityKeyIdentifier=keyid
7a1991
extendedKeyUsage=codeSigning
7a1991
EOF
7a1991
		fi
7a1991
		openssl req -new -nodes -utf8 -%CONFIG_MODULE_SIG_HASH -days 36500 \
7a1991
			-batch -x509 -config .kernel.genkey \
7a1991
			-outform PEM -out .kernel_signing_key.pem \
7a1991
			-keyout .kernel_signing_key.pem
7a1991
	fi
7a1991
	../scripts/config --set-str CONFIG_MODULE_SIG_KEY ".kernel_signing_key.pem"
7a1991
fi
Bernhard M. Wiedemann 6ebc4a
7a1991
case %cpu_arch in
7a1991
    x86_64 | i386)
7a1991
        MAKE_ARGS="$MAKE_ARGS ARCH=x86"
7a1991
        ;;
7a1991
    ppc*)
7a1991
        MAKE_ARGS="$MAKE_ARGS ARCH=powerpc"
7a1991
        ;;
7a1991
    s390x)
7a1991
        MAKE_ARGS="$MAKE_ARGS ARCH=s390"
7a1991
        ;;
7a1991
    arm64)
7a1991
        MAKE_ARGS="$MAKE_ARGS ARCH=arm64"
7a1991
        ;;
7a1991
    armv*)
7a1991
        MAKE_ARGS="$MAKE_ARGS ARCH=arm"
7a1991
        ;;
7a1991
    riscv*)
7a1991
        MAKE_ARGS="$MAKE_ARGS ARCH=riscv"
7a1991
        ;;
7a1991
    *)
7a1991
        MAKE_ARGS="$MAKE_ARGS ARCH=%cpu_arch"
7a1991
        ;;
7a1991
esac
Bernhard M. Wiedemann 6ebc4a
7a1991
makeoutputsync=
7a1991
if make --output-sync --help >/dev/null 2>&1 ; then
7a1991
        makeoutputsync=--output-sync
7a1991
else
7a1991
        echo make does not support --output-sync flag. Build messages may be mangled. 1>&2
7a1991
fi
7a1991
MAKE_ARGS="$MAKE_ARGS $makeoutputsync %{?_smp_mflags}"
7a1991
echo export MAKE_ARGS=\""$MAKE_ARGS"\" >> .kernel-binary.spec.buildenv
022a97
7a1991
KERN_DIRS="-C .. O=$PWD"
7a1991
if test -e %_sourcedir/TOLERATE-UNKNOWN-NEW-CONFIG-OPTIONS; then
7a1991
    yes '' | make oldconfig $MAKE_ARGS $KERN_DIRS
7a1991
else
7a1991
    cp .config .config.orig
7a1991
    if test -f ../scripts/kconfig/Makefile && \
7a1991
       grep -q syncconfig ../scripts/kconfig/Makefile; then
7a1991
        syncconfig="syncconfig"
7a1991
    else
7a1991
        syncconfig="silentoldconfig"
7a1991
    fi
7a1991
    make $syncconfig $MAKE_ARGS $KERN_DIRS < /dev/null
7a1991
    %_sourcedir/check-for-config-changes .config.orig .config
7a1991
    rm .config.orig
7a1991
fi
Bernhard M. Wiedemann 6ebc4a
7a1991
make prepare $MAKE_ARGS
7a1991
make scripts $MAKE_ARGS
7a1991
krel=$(make -s kernelrelease $MAKE_ARGS)
7a1991
7a1991
if [ "$krel" != "%kernelrelease-%build_flavor" ]; then
7a1991
    echo "Kernel release mismatch: $krel != %kernelrelease-%build_flavor" >&2
7a1991
    exit 1
Bernhard M. Wiedemann 6ebc4a
fi
Bernhard M. Wiedemann 6ebc4a
7a1991
make clean $MAKE_ARGS
Bernhard M. Wiedemann 6ebc4a
7a1991
rm -f source
7a1991
find . ! -type d ! -name 'Module.base' ! -name 'Module.*-kmp' ! -name 'Module.optional' -printf '%%P\n' \
7a1991
	> %my_builddir/obj-files
Bernhard M. Wiedemann 6ebc4a
7a1991
%build
7a1991
cd %kernel_build_dir
7a1991
source .kernel-binary.spec.buildenv
7a1991
7a1991
# create *.symref files in the tree
7a1991
if test -e %my_builddir/kabi/%cpu_arch/symtypes-%build_flavor; then
7a1991
    %_sourcedir/modversions --unpack . < $_
7a1991
fi
7a1991
7a1991
%if "%CONFIG_KMSG_IDS" == "y"
7a1991
    chmod +x ../scripts/kmsg-doc
7a1991
    MAKE_ARGS="$MAKE_ARGS D=2"
6a054f
%endif
6a054f
7a1991
mkdir -p %_topdir/OTHER
7a1991
log=%_topdir/OTHER/make-stderr.log
7a1991
while true; do
7a1991
    make all $MAKE_ARGS 2> >(tee "$log")
7a1991
    if test "${PIPESTATUS[0]}" -eq 0; then
7a1991
        break
7a1991
    fi
7a1991
    # In the linux-next and vanilla branches, we try harder to build a
7a1991
    # package.
7a1991
    if test 0%vanilla_only -gt 0 &&
7a1991
			%_sourcedir/try-disable-staging-driver "$log"; then
7a1991
        echo "Retrying make"
7a1991
    else
7a1991
        exit 1
7a1991
    fi
7a1991
done
7a1991
7a1991
# Generate list of symbols that are used to create kernel livepatches
7a1991
%if 0%{?klp_symbols}
7a1991
	%_sourcedir/klp-symbols . Symbols.list
7a1991
%endif
6a054f
7a1991
%install
6a054f
7a1991
# get rid of /usr/lib/rpm/brp-strip-debug
7a1991
# strip removes too much from the vmlinux ELF binary
7a1991
export NO_BRP_STRIP_DEBUG=true
7a1991
export STRIP_KEEP_SYMTAB='*/vmlinux*'
6a054f
7a1991
# %kernel_module_directory/%kernelrelease-%build_flavor/source points to the source
7a1991
# directory installed by kernel-devel. The kernel-%build_flavor-devel package
7a1991
# has a correct dependency on kernel-devel, but the brp check does not see
7a1991
# kernel-devel during build.
7a1991
export NO_BRP_STALE_LINK_ERROR=yes
6a054f
7a1991
cd %kernel_build_dir
7a1991
source .kernel-binary.spec.buildenv
6a054f
7a1991
mkdir -p %buildroot/boot
7a1991
# (Could strip out non-public symbols.)
7a1991
cp -p System.map %buildroot/boot/System.map-%kernelrelease-%build_flavor
6a054f
7a1991
add_vmlinux()
7a1991
{
7a1991
    local vmlinux=boot/vmlinux-%kernelrelease-%build_flavor
6a054f
7a1991
    cp vmlinux %buildroot/$vmlinux
7a1991
    # make sure that find-debuginfo.sh picks it up. In the filelist, we
7a1991
    # mark the file 0644 again
7a1991
    chmod +x %buildroot/$vmlinux
7a1991
    if test $1 == "--compressed"; then
7a1991
        # avoid using the gzip -n option to make kdump happy (bnc#880848#c20)
7a1991
        ts="$(head -n1 %_sourcedir/source-timestamp)"
7a1991
        touch -d "$ts" %buildroot/$vmlinux
7a1991
        touch %buildroot/$vmlinux.%{compress_vmlinux}
7a1991
%if 0%{?__debug_package:1}
7a1991
        # compress the vmlinux image after find-debuginfo.sh has processed it
7a1991
%global __debug_install_post %__debug_install_post \
7a1991
%_sourcedir/compress-vmlinux.sh %buildroot/boot/vmlinux-%kernelrelease-%build_flavor
7a1991
%else
7a1991
        %_sourcedir/compress-vmlinux.sh %buildroot/$vmlinux
7a1991
%endif
7a1991
        ghost_vmlinux=true
7a1991
    else
7a1991
        ghost_vmlinux=false
7a1991
    fi
7a1991
}
6a054f
7a1991
# architecture specifics
7a1991
%ifarch %ix86 x86_64
7a1991
    add_vmlinux --compressed
7a1991
    cp -p arch/x86/boot/bzImage %buildroot/boot/%image-%kernelrelease-%build_flavor
7a1991
%endif
7a1991
%ifarch ppc ppc64 ppc64le
7a1991
    add_vmlinux
7a1991
%endif
7a1991
%ifarch s390 s390x
7a1991
    add_vmlinux --compressed
7a1991
    image=image
7a1991
    if test ! -f arch/s390/boot/$image; then
7a1991
        image=bzImage
7a1991
    fi
7a1991
    cp -p arch/s390/boot/$image %buildroot/boot/%image-%kernelrelease-%build_flavor
7a1991
%if "%CONFIG_KMSG_IDS" == "y"
7a1991
    mkdir -p %buildroot/usr/share/man/man9
7a1991
    find man -name '*.9' -exec install -m 644 -D '{}' %buildroot/usr/share/man/man9/ ';'
7a1991
%endif
7a1991
%if 0%{?suse_version} > 1500 || 0%{?sle_version} >= 150300
7a1991
    s390x_vmlinux=arch/s390/boot/compressed/vmlinux
7a1991
    if [ ! -f "$s390x_vmlinux" ]; then
7a1991
        s390x_vmlinux=arch/s390/boot/vmlinux
7a1991
    fi
7a1991
    objcopy -R .rodata.compressed "$s390x_vmlinux" %buildroot/boot/zdebug-%kernelrelease-%build_flavor
7a1991
%endif
7a1991
%endif
7a1991
%ifarch %arm
7a1991
    add_vmlinux --compressed
7a1991
    cp -p arch/arm/boot/%image %buildroot/boot/%image-%kernelrelease-%build_flavor
7a1991
%endif
7a1991
%ifarch aarch64
7a1991
    add_vmlinux --compressed
7a1991
    cp -p arch/arm64/boot/%image %buildroot/boot/%image-%kernelrelease-%build_flavor
7a1991
%endif
7a1991
%ifarch riscv64
7a1991
    add_vmlinux --compressed
7a1991
    cp -p arch/riscv/boot/%image %buildroot/boot/%image-%kernelrelease-%build_flavor
6a054f
%endif
6a054f
7a1991
# sign the modules, firmware and possibly the kernel in the buildservice
7a1991
BRP_PESIGN_FILES=""
7a1991
%if "%CONFIG_EFI_STUB" == "y"
7a1991
%if %{usrmerged}
7a1991
BRP_PESIGN_FILES="%modules_dir/%image"
7a1991
%else
7a1991
BRP_PESIGN_FILES="/boot/%image-%kernelrelease-%build_flavor"
7a1991
%endif
7a1991
%endif
7a1991
%if ! %sb_efi_only
7a1991
%ifarch s390x ppc64 ppc64le
7a1991
%if %{usrmerged}
7a1991
BRP_PESIGN_FILES="%modules_dir/%image"
7a1991
%else
7a1991
BRP_PESIGN_FILES="/boot/%image-%kernelrelease-%build_flavor"
7a1991
%endif
7a1991
%endif
7a1991
%endif
7a1991
%if "%CONFIG_MODULE_SIG" == "y"
7a1991
BRP_PESIGN_FILES="$BRP_PESIGN_FILES *.ko"
7a1991
%endif
Bernhard M. Wiedemann 6ebc4a
%ifarch %ix86
7a1991
# XXX: do not sign on x86, as the repackaging changes kernel-pae
7a1991
# from i686 to i586
7a1991
BRP_PESIGN_FILES=""
Bernhard M. Wiedemann 6ebc4a
%endif
7a1991
export BRP_PESIGN_FILES
7a1991
%if "%{compress_modules}" != "none"
7a1991
export BRP_PESIGN_COMPRESS_MODULE=%{compress_modules}
df302c
%endif
7a1991
# Do not sign vanilla kernels released in official projects
7a1991
%if %build_vanilla && ! %vanilla_only
7a1991
BRP_PESIGN_FILES=""
df302c
%endif
Bernhard M. Wiedemann 6ebc4a
7a1991
if test -x /usr/lib/rpm/pesign/gen-hmac; then
7a1991
	$_ -r %buildroot /boot/%image-%kernelrelease-%build_flavor
7a1991
fi
7a4f11
7a1991
# Package the compiled-in certificates as DER files in /etc/uefi/certs
7a1991
# and have mokutil enroll them when the kernel is installed
7a1991
echo Signing certificates "%certs"
7a1991
if test %CONFIG_MODULE_SIG = "y" -a -d %_sourcedir/.kernel_signing_certs ; then
7a1991
    for f in %_sourcedir/.kernel_signing_certs/*.crt; do
7a1991
            mkdir -p %buildroot/etc/uefi/certs
7a1991
            cp -v $f %buildroot/etc/uefi/certs
7a1991
    done
7a1991
fi
Bernhard M. Wiedemann 6ebc4a
7a1991
cp -p .config %buildroot/boot/config-%kernelrelease-%build_flavor
7a1991
sysctl_file=%buildroot/boot/sysctl.conf-%kernelrelease-%build_flavor
7a1991
for file in %my_builddir/sysctl/{defaults,%cpu_arch/arch-defaults,%cpu_arch_flavor}; do
7a1991
	if [ -f "$file" ]; then
7a1991
		cat "$file"
7a1991
	fi
7a1991
done | sed '1i # Generated file - do not edit.' >$sysctl_file
7a1991
if [ ! -s $sysctl_file ]; then
7a1991
	rm $sysctl_file
7a1991
fi
Bernhard M. Wiedemann 6ebc4a
7a1991
%if %install_vdso
7a1991
# Install the unstripped vdso's that are linked in the kernel image
7a1991
make vdso_install $MAKE_ARGS INSTALL_MOD_PATH=%buildroot
7a1991
rm -rf %buildroot%kernel_module_directory/%kernelrelease-%build_flavor/vdso/.build-id
Bernhard M. Wiedemann 6ebc4a
%endif
Bernhard M. Wiedemann 6ebc4a
7a1991
# Create a dummy initrd with roughly the size the real one will have.
7a1991
# That way, YaST will know that this package requires some additional
7a1991
# space in /boot.
7a1991
dd if=/dev/zero of=%buildroot/boot/initrd-%kernelrelease-%build_flavor \
7a1991
	bs=1024 seek=2047 count=1
7a1991
# Also reserve some space for the kdump initrd
7a1991
cp %buildroot/boot/initrd-%kernelrelease-%build_flavor{,-kdump}
7a1991
%if 0%{?suse_version} >= 1500
7a1991
# Use same permissions as dracut
7a1991
chmod 0600 %buildroot/boot/initrd-%kernelrelease-%build_flavor{,-kdump}
df302c
%endif
bd7477
7a1991
if [ %CONFIG_MODULES = y ]; then
7a1991
    mkdir -p %rpm_install_dir/%cpu_arch_flavor
7a1991
    mkdir -p %buildroot/usr/src/linux-obj/%cpu_arch
7a1991
    install -m 755 -D -t %rpm_install_dir/%cpu_arch_flavor/scripts/mod/ scripts/mod/ksym-provides
bd7477
7a1991
    gzip -n -c9 < Module.symvers > %buildroot/boot/symvers-%kernelrelease-%build_flavor.gz
ab3bb5
7a1991
    make modules_install $MAKE_ARGS INSTALL_MOD_PATH=%buildroot
2eeb6a
7a1991
%ifarch s390 s390x
7a1991
    expoline=arch/s390/lib/expoline/expoline.o
7a1991
    if test -f arch/s390/lib/expoline/expoline.o ; then
7a1991
	install -m 644 -D -t %rpm_install_dir/%cpu_arch_flavor/$(dirname $expoline) $expoline
7a1991
    fi
7a1991
%endif
2eeb6a
7a1991
    # Also put the resulting file in %rpm_install_dir/%cpu_arch/%build_flavor
7a1991
    # so that kernel-devel + kernel-%build_flavor is sufficient for building
7a1991
    # modules that have modversions as well.
7a1991
    mkdir -p %rpm_install_dir/%cpu_arch/%build_flavor
7a1991
    cp Module.symvers %rpm_install_dir/%cpu_arch/%build_flavor
7a4f11
7a1991
    # List of symbols that are used to generate kernel livepatches
7a1991
    %if 0%{?klp_symbols}
7a1991
        cp Symbols.list %rpm_install_dir/%cpu_arch/%build_flavor
7a1991
        echo %obj_install_dir/%cpu_arch/%build_flavor/Symbols.list > %my_builddir/livepatch-files.no_dir
bd7477
7a1991
        %if "%CONFIG_LIVEPATCH_IPA_CLONES" == "y"
7a1991
            find %kernel_build_dir -name "*.ipa-clones" ! -size 0 | sed -e 's|^%kernel_build_dir/||' | sort > ipa-clones.list
7a1991
            cp ipa-clones.list %rpm_install_dir/%cpu_arch/%build_flavor
7a1991
            echo %obj_install_dir/%cpu_arch/%build_flavor/ipa-clones.list >> %my_builddir/livepatch-files.no_dir
7a1991
            tar -C %kernel_build_dir \
7a1991
%if ! 0%{?suse_version} || 0%{?suse_version} >= 1500
7a1991
		    --verbatim-files-from \
bd7477
%endif
7a1991
		    -T ipa-clones.list -cf- | tar -C %rpm_install_dir/%cpu_arch/%build_flavor -xvf-
7a1991
            cat ipa-clones.list | sed -e 's|^|%obj_install_dir/%cpu_arch/%build_flavor/|' >> %my_builddir/livepatch-files.no_dir
7a1991
        %endif
7a1991
    %endif
bd7477
7a1991
    # Table of types used in exported symbols (for modversion debugging).
7a1991
    %_sourcedir/modversions --pack . > %buildroot/boot/symtypes-%kernelrelease-%build_flavor
7a1991
    if [ -s %buildroot/boot/symtypes-%kernelrelease-%build_flavor ]; then
7a1991
	gzip -n -9 %buildroot/boot/symtypes-%kernelrelease-%build_flavor
7a1991
    else
7a1991
	rm -f %buildroot/boot/symtypes-%kernelrelease-%build_flavor
7a1991
    fi
Bernhard M. Wiedemann 6ebc4a
7a1991
    # Some architecture's $(uname -m) output is different from the ARCH
7a1991
    # parameter that needs to be passed to kbuild. Create symlinks from
7a1991
    # $(uname -m) to the ARCH directory.
7a1991
    if [ ! -e %rpm_install_dir/%kmp_target_cpu ]; then
7a1991
        ln -sf %cpu_arch %rpm_install_dir/%kmp_target_cpu
7a1991
        ln -sf %cpu_arch %buildroot/usr/src/linux-obj/%kmp_target_cpu
7a1991
    fi
Bernhard M. Wiedemann 6ebc4a
7a1991
    # We were building in %my_builddir/linux-%srcversion, but the sources will
7a1991
    # later be installed in /usr/src/linux-%srcversion-%source_rel. Fix up the
7a1991
    # build symlink.
7a1991
    rm -f %buildroot%kernel_module_directory/%kernelrelease-%build_flavor/{source,build}
7a1991
    ln -s %src_install_dir \
7a1991
	%buildroot%kernel_module_directory/%kernelrelease-%build_flavor/source
7a1991
    ln -s %obj_install_dir/%cpu_arch/%build_flavor \
7a1991
	%buildroot%kernel_module_directory/%kernelrelease-%build_flavor/build
Bernhard M. Wiedemann 6ebc4a
7a1991
    # Abort if there are any undefined symbols
7a1991
    msg="$(/sbin/depmod -F %buildroot/boot/System.map-%kernelrelease-%build_flavor \
7a1991
			-b %buildroot -ae %kernelrelease-%build_flavor 2>&1)"
7a1991
    if [ $? -ne 0 ] || echo "$msg" | grep  'needs unknown symbol'; then
7a1991
	exit 1
7a1991
    fi
Bernhard M. Wiedemann 6ebc4a
7a1991
    %_sourcedir/split-modules -d %buildroot \
7a1991
	-o %my_builddir \
7a1991
	-b %kernel_build_dir \
7a1991
%if "%CONFIG_SUSE_KERNEL_SUPPORTED" == "y"
7a1991
	-e \
7a1991
%endif
7a1991
%if ! %supported_modules_check
7a1991
	-i \
7a1991
%endif
7a1991
	%nil
7a1991
%if ! %split_extra
7a1991
    cat %my_builddir/unsupported-modules >>%my_builddir/main-modules
Bernhard M. Wiedemann 6ebc4a
%endif
Bernhard M. Wiedemann 6ebc4a
7a1991
    # The modules.dep file is sorted randomly which produces strange file
7a1991
    # checksums. As the file is not included in the resulting RPM, it's
7a1991
    # pointless to rely on its contents. Replacing by zeros to make the
7a1991
    # checksums always the same for several builds of the same package.
7a1991
    test -s %buildroot%kernel_module_directory/%kernelrelease-%build_flavor/modules.dep && \
7a1991
    dd if=/dev/zero of=%buildroot%kernel_module_directory/%kernelrelease-%build_flavor/modules.dep ibs=$(stat -c%s %buildroot%kernel_module_directory/%kernelrelease-%build_flavor/modules.dep) count=1
3027fd
7a1991
    res=0
7a1991
    if test -e %my_builddir/kabi/%cpu_arch/symvers-%build_flavor; then
7a1991
        # check for kabi changes
7a1991
        %_sourcedir/kabi.pl --rules %my_builddir/kabi/severities \
7a1991
            %my_builddir/kabi/%cpu_arch/symvers-%build_flavor \
7a1991
            Module.symvers || res=$?
7a1991
    fi
7a1991
    if [ $res -ne 0 ]; then
7a1991
	# %ignore_kabi_badness is defined in the Kernel:* projects in the
7a1991
	# OBS to be able to build the KOTD in spite of kabi errors
7a1991
	if [ 0%{?ignore_kabi_badness} -eq 0 -a \
7a1991
	     ! -e %my_builddir/kabi/%cpu_arch/ignore-%build_flavor -a \
7a1991
	     ! -e %_sourcedir/IGNORE-KABI-BADNESS ]; then
7a1991
	    echo "Create a file IGNORE-KABI-BADNESS in the kernel-source" \
7a1991
		 "directory to build this kernel even though its badness is" \
7a1991
		 "higher than allowed for an official kernel."
7a1991
	   exit 1
7a1991
	fi
7a1991
    fi
3027fd
7a1991
    # Check the license in each module
7a1991
    if ! sh %_sourcedir/check-module-license %buildroot; then
7a1991
	echo "Please fix the missing licenses!"
7a1991
%if "%CONFIG_SUSE_KERNEL_SUPPORTED" == "y"
7a1991
	exit 1
3027fd
%endif
7a1991
    fi
3027fd
7a1991
    # These files are required for building external modules
7a1991
    for FILE in arch/powerpc/lib/crtsavres.o arch/arm64/kernel/ftrace-mod.o \
7a1991
		arch/*/kernel/macros.s scripts/module.lds
7a1991
    do
7a1991
	    if [ -f %kernel_build_dir/$FILE ]; then
7a1991
		echo $FILE >> %my_builddir/obj-files
7a1991
	    fi
7a1991
    done
Bernhard M. Wiedemann 6ebc4a
7a1991
    tar --exclude=\*.ipa-clones --exclude=.config.old --exclude=.kernel-binary.spec.buildenv \
7a1991
        --exclude=.kernel_signing_key.pem --exclude=.kernel.genkey \
7a1991
        -cf - -T %my_builddir/obj-files | \
7a1991
	tar -xf - -C %rpm_install_dir/%cpu_arch_flavor
7a1991
    # bnc#507084
7a1991
    find %rpm_install_dir/%cpu_arch_flavor/scripts -type f -perm -111 | \
7a1991
        while read f; do
7a1991
            case "$(file -b "$f")" in
7a1991
            ELF\ *\ executable*)
7a1991
                strip "$f"
7a1991
            esac
7a1991
        done
Bernhard M. Wiedemann 6ebc4a
7a1991
    # Recreate the generated Makefile with correct path
7a1991
    #
7a1991
    # Linux 5.13 no longer has mkmakefile
7a1991
    if [ -f ../scripts/mkmakefile ] ; then
7a1991
        sh ../scripts/mkmakefile ../../../%{basename:%src_install_dir} \
7a1991
            %rpm_install_dir/%cpu_arch_flavor \
7a1991
            $(echo %srcversion | sed -r 's/^([0-9]+)\.([0-9]+).*/\1 \2/')
7a1991
    else
7a1991
       echo include ../../../%{basename:%src_install_dir}/Makefile > %rpm_install_dir/%cpu_arch_flavor/Makefile
7a1991
    fi
7a1991
fi
Bernhard M. Wiedemann 6ebc4a
7a1991
# CONFIG_GDB_SCRIPTS
7a1991
if [ -e vmlinux-gdb.py ]; then
7a1991
    DEST=%rpm_install_dir/%cpu_arch_flavor/
7a1991
    install -m 755 -d "$DEST"
7a1991
    # set sys.path to our devel.rpm scripts
7a1991
    sed 's@\(sys\.path\.insert(0, \).*@\1"%obj_install_dir/%cpu_arch_flavor/scripts/gdb/")@' vmlinux-gdb.py > "$DEST/vmlinux-gdb.py"
Bernhard M. Wiedemann 6ebc4a
7a1991
    DEST=%rpm_install_dir/%cpu_arch_flavor/scripts/gdb/linux
7a1991
    install -m 755 -d "$DEST"
7a1991
    pushd scripts/gdb/linux/
7a1991
    for file in *.py; do
7a1991
	if test -L "$file"; then
7a1991
	    # relink against our devel.rpm sources, not of buildroot's
7a1991
	    ln -s "%src_install_dir/scripts/gdb/linux/$file" "$DEST/$file"
7a1991
	else
7a1991
	    cp -p "$file" "$DEST"
7a1991
	fi
7a1991
    done
7a1991
    popd
Bernhard M. Wiedemann 6ebc4a
7a1991
    DEST=%{buildroot}%{_datadir}/gdb/auto-load%modules_dir
7a1991
    install -m 755 -d "$DEST"
7a1991
    ln -s %obj_install_dir/%cpu_arch_flavor/vmlinux-gdb.py "$DEST/vmlinux-gdb.py"
7a1991
fi
7a1991
7a1991
rm -rf %{buildroot}/lib/firmware
7a1991
7a1991
add_dirs_to_filelist() {
7a1991
    sed -rn '
7a1991
        # print file name
7a1991
        p
7a1991
        # remove filelist macros
7a1991
        s:%%[a-z]+(\([^)]+\))? ?::g
7a1991
        # add %%dir prefix
7a1991
        s:^:%%dir :
7a1991
        # print all parents
7a1991
        :a
7a1991
            # skip directories owned by other packages
7a1991
            s:^%%dir (/boot|/etc|(/usr)?/lib/(modules|firmware)|/usr/share|/usr/src)/[^/]+$::
7a1991
            s:/[^/]+$::p
7a1991
        ta
7a1991
    ' "$@" | sort -u
7a1991
}
2eeb6a
7a1991
# Collect the file lists.
7a1991
if [ -f %my_builddir/livepatch-files.no_dir ] ; then
7a1991
    cat %my_builddir/livepatch-files.no_dir | add_dirs_to_filelist > %my_builddir/livepatch-files
2eeb6a
fi
2eeb6a
7a1991
# does not exist for non-modularized kernels
7a1991
%if %{usrmerged}
7a1991
        mkdir -p %{buildroot}%modules_dir
Bernhard M. Wiedemann 6ebc4a
%endif
7a1991
shopt -s nullglob dotglob
7a1991
> %my_builddir/kernel-devel.files
7a1991
{
7a1991
    echo "%modules_dir/build"
7a1991
    echo "%modules_dir/source"
7a1991
    cd %buildroot
7a1991
    for file in boot/symtypes*; do
7a1991
%if %{usrmerged}
7a1991
        l="${file##*/}"
7a1991
        l="%modules_dir/${l//-%kernelrelease-%build_flavor}"
7a1991
        mv "$file" "%{buildroot}$l"
7a1991
        ln -s "..$l" $file
7a1991
        echo "$l"
7a1991
        echo "%%ghost /$file"
Bernhard M. Wiedemann 6ebc4a
%else
7a1991
        echo "/$file"
c3597e
%endif
7a1991
    done
7a1991
    if test -d .%{_datadir}/gdb/; then
7a1991
	find .%obj_install_dir/%cpu_arch_flavor/scripts/gdb/linux/ -name '*.py' -type l | sed -e 's/^[.]//'
7a1991
	echo "%{_datadir}/gdb/auto-load%modules_dir/vmlinux-gdb.py"
7a1991
    fi
7a1991
} | add_dirs_to_filelist >%my_builddir/kernel-devel.files
7a1991
( cd %buildroot ; find .%obj_install_dir/%cpu_arch_flavor -type f ; ) | \
7a1991
sed -e 's/^[.]//' | grep -v -e '[.]ipa-clones$' -e '/Symbols[.]list$' -e '/ipa-clones[.]list$'| \
7a1991
add_dirs_to_filelist >> %my_builddir/kernel-devel.files
Bernhard M. Wiedemann 6ebc4a
7a1991
{   echo %ghost /boot/%image
7a1991
    echo %ghost /boot/initrd
7a1991
    cd %buildroot
7a1991
    for f in boot/*; do
7a1991
        l="${f##*/}"
7a1991
        l="%modules_dir/${l//-%kernelrelease-%build_flavor}"
7a1991
        if test -L "$f"; then
7a1991
            echo "%%ghost /$f"
7a1991
            continue
7a1991
        elif test ! -f "$f"; then
7a1991
            continue
7a1991
        fi
7a1991
        case "$f" in
7a1991
        boot/initrd-*)
7a1991
            echo "%%ghost /$f"
7a1991
            continue
7a1991
            ;;
7a1991
        boot/vmlinux-*.%{compress_vmlinux})
7a1991
            ;;
7a1991
        boot/vmlinux-*)
7a1991
            if $ghost_vmlinux; then
7a1991
                # fall through to mark next echo as %ghost
7a1991
                echo -n "%%ghost "
7a1991
            fi
7a1991
            ;;
7a1991
%if %{usrmerged}
7a1991
        boot/vmlinuz-*)
7a1991
            echo -n "%%attr(0644, root, root) "
7a1991
            ;;
Bernhard M. Wiedemann 6ebc4a
%endif
7a1991
        boot/symtypes*)
7a1991
%if %{usrmerged}
7a1991
            echo "%exclude $l"
7a1991
%endif
7a1991
            continue
7a1991
            ;;
7a1991
        esac
7a1991
%if %{usrmerged}
7a1991
        mv "$f" "./$l"
7a1991
        ln -s "..$l" $f
7a1991
        # the find in the CONFIG_MODULES condition below also finds the files
7a1991
        # but there's sort -u later, so this is ok
7a1991
        echo "$l" # note: must be first after case statement above
7a1991
        echo "%%ghost /$f"
7a1991
%else
7a1991
        echo "%%attr(0644, root, root) /$f"
Bernhard M. Wiedemann 6ebc4a
%endif
7a1991
    done
Bernhard M. Wiedemann 6ebc4a
7a1991
    if [ %CONFIG_MODULES = y ]; then
7a1991
	MODULES=%{lua: print(rpm.expand('%kernel_module_directory'):sub(2))}/%kernelrelease-%build_flavor
7a1991
	find "$MODULES" \
7a1991
%if 0%{?separate_vdso}
7a1991
	    -path "$MODULES/vdso" -prune -o \
df302c
%endif
7a1991
	    -type d -o \
7a1991
	    \( -path '*/modules.*' ! -path '*/modules.order' \
7a1991
	     ! -path '*/modules.builtin' \
7a1991
	     ! -path '*/modules.builtin.modinfo' \) -printf '%%%%ghost /%%p\n' \
7a1991
	       -o -name '*.ko' -prune \
7a1991
	       -o \( -type f \
7a1991
%if %{usrmerged}
7a1991
		! -path '*/symtypes*' ! -path '*/vmlinu*' \
df302c
%endif
7a1991
		\) -printf '/%%p\n'
7a1991
	cat %my_builddir/base-modules
7a1991
    fi
7a1991
    if test %CONFIG_MODULE_SIG = "y" -a -d etc/uefi/certs; then
7a1991
        find etc/uefi/certs -type f -printf '/%%p\n'
7a1991
    fi
7a1991
    if test -d lib/firmware/%kernelrelease-%build_flavor; then
7a1991
        echo "%%dir /lib/firmware/%kernelrelease-%build_flavor"
7a1991
        cat %my_builddir/base-firmware
7a1991
    fi
7a1991
    if [ -e .%_docdir/%name ]; then
7a1991
	echo "%%doc %_docdir/%name"
7a1991
    fi
7a1991
} | sort -u | add_dirs_to_filelist >%my_builddir/kernel-base.files
Bernhard M. Wiedemann 6ebc4a
7a1991
{
7a1991
    add_dirs_to_filelist %my_builddir/kernel-base.files
7a1991
    if [ %CONFIG_MODULES = y ]; then
7a1991
        add_dirs_to_filelist %my_builddir/main-modules
7a1991
    fi
7a1991
    if test -d %buildroot/lib/firmware/%kernelrelease-%build_flavor; then
7a1991
	echo "/lib/firmware/%kernelrelease-%build_flavor"
7a1991
    fi
7a1991
} > %my_builddir/kernel-main.files
Bernhard M. Wiedemann 6ebc4a
7a1991
%if %split_extra
7a1991
    add_dirs_to_filelist %my_builddir/unsupported-modules > %my_builddir/kernel-extra.files
7a1991
%if %split_extra && %split_optional
7a1991
    add_dirs_to_filelist %my_builddir/optional-modules > %my_builddir/kernel-optional.files
7a1991
%endif
ab3bb5
7a1991
%if 0%{?sle_version} >= 150000
7a1991
    # By default, loading unsupported modules is disabled on SLE through
7a1991
    # /etc/modprobe.d/10-unsupported-modules.conf from the suse-module-tools
7a1991
    # package.
7a1991
    # modules in kernel-$flavor-extra don't have the supported flag set,
7a1991
    # yet loading them should be possible if the package is installed.
7a1991
    # CAUTION PACKAGERS: The file content below must not change between
7a1991
    # kernel versions, otherwise file conflicts might arise with
7a1991
    # multiversion(kernel).
Bernhard M. Wiedemann 6ebc4a
7a1991
    modprobe_d_dir=/etc/modprobe.d
7a1991
    %if 0%{?sle_version} > 150300
7a1991
    modprobe_d_dir=/lib/modprobe.d
7a1991
    %endif
7a1991
    %if %{usrmerged}
7a1991
    modprobe_d_dir=/usr/lib/modprobe.d
7a1991
    %endif
Bernhard M. Wiedemann 6ebc4a
7a1991
    mkdir -p %buildroot$modprobe_d_dir
7a1991
    cat >%buildroot$modprobe_d_dir/20-kernel-%{build_flavor}-extra.conf <
7a1991
# This file overrides the default from 10-unsupported-modules.conf.
7a1991
# This is necessary to load kernel modules from the
7a1991
# kernel-%{build_flavor}-extra package.
7a1991
#
7a1991
# WARNING: loading unsupported modules may compromise SLE support.
7a1991
# Please read the comments in 10-unsupported-modules.conf.
7a1991
allow_unsupported_modules 1
7a1991
EOF
7a1991
    echo "%%dir $modprobe_d_dir" >> %my_builddir/kernel-extra.files
7a1991
    echo "%%config(noreplace) $modprobe_d_dir/20-kernel-%{build_flavor}-extra.conf" >> %my_builddir/kernel-extra.files
7a1991
%endif
7a1991
%endif
7a1991
for f in %my_builddir/*-kmp-modules; do
7a1991
	f2=${f%%-modules}.files
7a1991
	add_dirs_to_filelist "$f" >"$f2"
7a1991
done
7a4f11
7a1991
if [ %CONFIG_MODULES = y ]; then
7a1991
  install -m 644 %_sourcedir/modules.fips %{buildroot}%modules_dir/modules.fips
7a1991
  echo %modules_dir/modules.fips >> %my_builddir/kernel-base.files
7a1991
  echo %modules_dir/modules.fips >> %my_builddir/kernel-main.files
7a1991
fi
Bernhard M. Wiedemann 6ebc4a
7a1991
# Hardlink duplicate files automatically (from package fdupes): It doesn't save
7a1991
# much, but it keeps rpmlint from breaking the package build. Note that we skip
7a1991
# /usr/src/linux-obj intentionally, to not accidentally break timestamps there
7a1991
%fdupes %buildroot%modules_dir
Bernhard M. Wiedemann 6ebc4a
Bernhard M. Wiedemann 6ebc4a
%changelog