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>
This commit is contained in:
parent
d7490ffefa
commit
711c0be6ea
20
brp-kmod-restore-perms
Executable file
20
brp-kmod-restore-perms
Executable file
@ -0,0 +1,20 @@
|
||||
#! /bin/bash -efu
|
||||
|
||||
## A counterpart of brp-kmod-set-exec-bits that restores original kmod
|
||||
## file permissions
|
||||
|
||||
# If using normal root, avoid changing anything.
|
||||
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" ] || exit 0
|
||||
|
||||
# Checking for required programs
|
||||
which chmod >/dev/null || exit 0
|
||||
|
||||
[ -r "$RPM_BUILD_ROOT/kmod-permissions.list" ] || exit 0
|
||||
|
||||
while read perm path; do
|
||||
[ -n "$perm" ] || continue
|
||||
|
||||
chmod "$perm" "$RPM_BUILD_ROOT/$path"
|
||||
done < "$RPM_BUILD_ROOT/kmod-permissions.list"
|
||||
|
||||
rm -f "$RPM_BUILD_ROOT/kmod-permissions.list"
|
14
brp-kmod-set-exec-bit
Executable file
14
brp-kmod-set-exec-bit
Executable file
@ -0,0 +1,14 @@
|
||||
#! /bin/bash -efux
|
||||
|
||||
## A hack for making brp-strip taking into account kmod files
|
||||
|
||||
# If using normal root, avoid changing anything.
|
||||
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" ] || exit 0
|
||||
|
||||
# Checking for required programs
|
||||
which find chmod >/dev/null || exit 0
|
||||
|
||||
find "$RPM_BUILD_ROOT" \
|
||||
-name '*.ko' \
|
||||
-printf '%#m %P\n' \
|
||||
-exec chmod u+x '{}' \; > "$RPM_BUILD_ROOT/kmod-permissions.list"
|
@ -34,6 +34,10 @@ Source302: symset-table
|
||||
Source400: kabi.attr
|
||||
Source401: kabi.sh
|
||||
|
||||
# BRPs
|
||||
Source500: brp-kmod-set-exec-bit
|
||||
Source501: brp-kmod-restore-perms
|
||||
|
||||
%global rrcdir /usr/lib/rpm/redhat
|
||||
|
||||
|
||||
@ -48,6 +52,9 @@ Release: %{release}%{?dist}.1
|
||||
Summary: Macros and scripts for building kernel module packages
|
||||
Requires: redhat-rpm-config >= 13
|
||||
|
||||
# for brp-kmod-set-exec-bit
|
||||
Requires: %{_bindir}/find
|
||||
|
||||
%description -n kernel-rpm-macros
|
||||
Macros and scripts for building kernel module packages.
|
||||
|
||||
@ -75,6 +82,7 @@ mkdir -p %{buildroot}%{_fileattrsdir}
|
||||
install -p -m 755 -t %{buildroot}%{rrcdir} kmodtool rpmsort symset-table
|
||||
install -p -m 755 -t %{buildroot}%{rrcdir} find-provides.ksyms find-requires.ksyms
|
||||
install -p -m 644 -t %{buildroot}%{rrcdir}/find-provides.d firmware.prov modalias.prov
|
||||
install -p -m 755 -t %{buildroot}%{rrcdir} brp-kmod-restore-perms brp-kmod-set-exec-bit
|
||||
install -p -m 644 -t %{buildroot}%{_rpmconfigdir}/macros.d macros.kmp
|
||||
install -p -m 644 -t %{buildroot}%{_fileattrsdir} kmod.attr
|
||||
|
||||
@ -90,6 +98,8 @@ install -p -m 755 -t "%{buildroot}%{_rpmconfigdir}" kabi.sh
|
||||
%{_rpmconfigdir}/macros.d/macros.kmp
|
||||
%{_fileattrsdir}/kabi.attr
|
||||
%dir %{rrcdir}/find-provides.d
|
||||
%{rrcdir}/brp-kmod-restore-perms
|
||||
%{rrcdir}/brp-kmod-set-exec-bit
|
||||
%{rrcdir}/kmodtool
|
||||
%{rrcdir}/rpmsort
|
||||
%{rrcdir}/symset-table
|
||||
|
40
macros.kmp
40
macros.kmp
@ -2,6 +2,11 @@
|
||||
redhat_kernel_module_package 1
|
||||
kernel_module_package_release 1
|
||||
|
||||
%__brp_kmod_set_exec_bit /usr/lib/rpm/redhat/brp-kmod-set-exec-bit
|
||||
%__brp_kmod_restore_perms /usr/lib/rpm/redhat/brp-kmod-restore-perms
|
||||
|
||||
%__kmod_brps_added 0
|
||||
|
||||
%__find_provides /usr/lib/rpm/redhat/find-provides
|
||||
%__find_requires /usr/lib/rpm/redhat/find-requires
|
||||
|
||||
@ -12,6 +17,41 @@ kernel_module_package_release 1
|
||||
kernel-devel kernel-abi-stablelists redhat-rpm-config kernel-rpm-macros elfutils-libelf-devel kmod
|
||||
|
||||
%kernel_module_package(n:v:r:s:f:xp:) %{expand:%( \
|
||||
## An ugly hack: we want kmods to be processed by find-debuginfo,
|
||||
## but it processes only files with executable permission set.
|
||||
## It is important now since, as of now, if debuginfo package
|
||||
## is enabled (and it is enabled), there's an RPM build error
|
||||
## as a result of lack of ether absence or emptiness of
|
||||
## debugsourcefiles.list (which is likely a bug in RPM, but it looks
|
||||
## like that there's no obvious fix and apparently no one have
|
||||
## any issues with this).
|
||||
## In order to minimise intrusiveness, usually (in Red Hat-built kmod
|
||||
## RPMs) *.ko files just have executable permission being set as a part
|
||||
## of %build section. There are two caveats with kmp, however:
|
||||
## * We have no control over %build section itself (and it wasn't
|
||||
## required previously)
|
||||
## * Changing the criteria used in find-debuginfo.sh/brp-strip
|
||||
## for selecting files that have to undergo debug section separation
|
||||
## may introduce regression.
|
||||
## As a result, we insert additional hooks in __spec_install_post
|
||||
## (__brp_kmod_set_exec_bit in the beginning and
|
||||
## __brp_kmod_restore_perms in the end) that (temporarily) set
|
||||
## executable permission for *.ko files so find-debuginfo.sh will pick
|
||||
## them up.
|
||||
## Unfortunately, __spec_install_post's body is copied here since
|
||||
## we want that __debug_package macro expansion has been performed
|
||||
## lazily and it looks like RPM has no ability to provide a body
|
||||
## of a macro verbatim.
|
||||
if [ 0 = "%{__kmod_brps_added}" ]; then \
|
||||
echo "%%global __spec_install_post \\\\" \
|
||||
echo " %%{?__brp_kmod_set_exec_bit} \\\\" \
|
||||
echo " %%%%{?__debug_package:%%%%{__debug_install_post}} \\\\" \
|
||||
echo " %%{__arch_install_post} \\\\" \
|
||||
echo " %%{__os_install_post} \\\\" \
|
||||
echo " %%{?__brp_kmod_restore_perms} \\\\" \
|
||||
echo "%%{nil}" \
|
||||
fi \
|
||||
%global __kmod_brps_added 1 \
|
||||
%global kmodtool %{-s*}%{!-s:/usr/lib/rpm/redhat/kmodtool} \
|
||||
%global kmod_version %{-v*}%{!-v:%{version}} \
|
||||
%global kmod_release %{-r*}%{!-r:%{release}} \
|
||||
|
Loading…
Reference in New Issue
Block a user