Commit Graph

8 Commits

Author SHA1 Message Date
Eugene Syromiatnikov
cfaf1a56f7 macros.kmp: add post-install kmod processing hooks
The enablement of debuginfo generation broke custom %install scripts
that perform module signing, and in an attempt to address that,
additional hooks are added that can be used for module compression,
signing, and other means of kmod processing.

* macros.kmp (redhat_kmp_has_post_hooks): New macro, set to 1.
(kernel_module_package_release): Add __brp_kmod_pre_sign_process,
__brp_kmod_sign, __brp_kmod_post_sign_process, __brp_kmod_compress,
and __brp_kmod_post_compress_process to the generated
__spec_install_post.

Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:38:10 +01:00
Eugene Syromiatnikov
2571351ab3 Enable extraction of debug information for kmods
This hack temporary adds executable permission for the *.ko files
during post-install stage so they are picked up by find-debuginfo.sh.
Since the intention is to avoid changing of behaviour in non-kmod
workloads, it's done by adding two additional brp-* scripts to the
__spec_install_post macro when kernel_module_package is instantiated.

* brp-kmod-restore-perms: New file.
* brp-kmod-set-exec-bit: Likewise.
* macros.kmp (%__brp_kmod_set_exec_bit, %__brp_kmod_restore_perms,
%__kmod_brps_added): New macros.
(%kernel_module_package): Rewrite __spec_install_post macro.
* redhat-rpm-config.spec (Source701, Source702): Add
brp-kmod-restore-perms and brp-kmod-set-exec-bit.
(Requires): Add find requirement for brp-kmod-set-exec-bit.
(%files): Explicitly list brp-* scripts for redhat-rpm-config and
kernel-rpm-macros packages.

Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:38:10 +01:00
Eugene Syromiatnikov
ff35c47e25 macros.kmp: avoid error in latest_kernel when no kernel is installed
If no kernel-devel packages are installed (this is possible, for example,
during SRPM generation in an isolated environment), no output would be
generated for latest_kernel macro, which would lead to an error (since
an RPM macro can't have an empty definition).  Append %nil to the input
of the "head" command to avoid this situation.

* macros.kmp (kernel_module_package): Feed additional line with %nil
to the input of head command in the latest_kernel macro definition.

Resolves: #1971748
Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:33:11 +01:00
Eugene Syromiatnikov
6a73d7992a kmodtool, macros.kmp: support "+" for the kernel variant in uname
A patch[1] to the kernel spec file changed the separator that is used
for kernel flavor designation from "." to "+", which broke kmodtool and
%kernel_module_package in multiple places.  Try to accomodate it by
accepting both "+" and "." during parsing, and guessing which one should
be used for kernel osurce path generation.

PS. It looks like the analogous breakage was before, when it was changed
from "-" to ".". May be we should start support it back again as well.

[1] https://lists.fedoraproject.org/pipermail/kernel/2013-June/004262.html

* kmodtool (get_verrel, get_variant): Accept both "." and "+" as separators.
(get_variant_char, print_variant_char, print_kernel_source): New functions.
(get_filelist): Convert "+%1" in file list to $dotvariant, in addition
to ".%1" and "-%1".
(get_rpmtemplate): Determine a char that is used as a variant separator.
Use it in $dotvariant.
(usage): Mention "veriant_char" and "kernel_source" commands.
* macros.kmp (%kernel_module_package): Use "kernel_source" command in
"%kernel_source" definition when non-default variant is used; fall back
to ls-based heuristics when it is not available (for example, when a
version of kmodtool that doesn't support this command is used).

Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:33:11 +01:00
Eugene Syromiatnikov
a4aed2feef kmodtool, macros.kmp: update list of build requirements
The following packages are added:
 - kernel-abi-stablelists is used by find-requires.ksym in order to
   provide information regarding kABI symbol usage. It's purely
   informational and optional, however.
 - redhat-rpm-config and kernel-rpm-macros are added since the generted
   spec files use macros from these packages.
 - elfutils-libelf-devel is used during kmod build for ORC metadata
   generation (used by kernel for stack unwinding).
 - kmod programs are used by find-requires.ksyms and find-proivides.ksyms
   for parsing *.ko files during dependency generation.

* kmodtool (get_rpm_template): Update the list of generated
BuildRequires.
* macros.kmp (%kernel_module_package_buildreqs): Update the list of
default BuildRequires.

Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:33:11 +01:00
Eugene Syromiatnikov
97ccf1649f Re-add redhat-rpm-config-9.0.3-latest-kernel.patch to RHEL 9
Apply contents of redhat-rpm-config-9.0.3-latest-kernel.patch
from RHEL 7 branch.

Commit message from the original commit:

    commit 5523411675de5be36f6a2adc0f99c2c5021c87ca
    Author: Florian Festi <ffesti@redhat.com>
    Date:   Wed May 11 17:09:31 2016 +0200

        - Fix latest_kernel macro
        - Resolves: #1323087

Resolves: #1971748
Resolves: #1999607
Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:33:11 +01:00
Eugene Syromiatnikov
581680855a Re-add contents of redhat-rpm-config-9.1.0-kmod-kabi.patch to RHEL 9
Apply redhat-rpm-config-9.1.0-kmod-kabi.patch from RHEL 7 branch.

Applied only changes to kmodtool and macros (now macros.kmp), as all
others are applied already. macros.kmp also had a merge conflict due to
commits f41a8a73aa6f ("Fix kernel_source macro to match the directory
that kernel sources are installed in") and d95e9bc7b618 ("Fix directory
name mismatch in kernel_source macro (#648996)") being applied already.

Commit message from the original commit:

    commit 29b4b765391b8f11ae64708e86ac3f7475c62661
    Author: Panu Matilainen <pmatilai@redhat.com>
    Date:   Tue Jul 9 09:57:29 2013 +0300

        - Re-add various kABI-related bits (Jon Masters)
        - Allow kmod building against z-stream kernels (Jiri Benc)

Resolves: #1971748
Resolves: #2002887
Resolves: #2015909
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:33:11 +01:00
Michal Domonkos
33b5f1bcf4 Adopt kernel-rpm-macros subpackage from redhat-rpm-config
This has been done in CentOS Stream already:
https://gitlab.com/redhat/centos-stream/rpms/kernel-srpm-macros/-/merge_requests/1
2021-06-03 17:21:53 +02:00