Skip to content
/ linux Public

Commit 39824c8

Browse files
nathanchanceSasha Levin
authored andcommitted
kernel: rpm-pkg: Restore find-debuginfo.sh approach to -debuginfo package
[ Upstream commit ffe9ac1 ] Commit 62089b8 ("kbuild: rpm-pkg: Generate debuginfo package manually") effectively reverted commit a7c699d ("kbuild: rpm-pkg: build a debuginfo RPM") but the approach it took is not safe for older RPM releases. Restore commit a7c699d ("kbuild: rpm-pkg: build a debuginfo RPM") for the !CONFIG_MODULE_SIG case to allow more environments and configurations to take advantage of the separate debug information package process. Cc: stable@vger.kernel.org Fixes: 62089b8 ("kbuild: rpm-pkg: Generate debuginfo package manually") Tested-by: Stefano Garzarella <sgarzare@redhat.com> Tested-by: Steve French <stfrench@microsoft.com> Tested-by: Juergen Gross <jgross@suse.com> Acked-by: Nicolas Schier <nsc@kernel.org> Link: https://patch.msgid.link/20260210-kbuild-fix-debuginfo-rpm-v1-2-0730b92b14bc@kernel.org Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0ee1887 commit 39824c8

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

scripts/package/kernel.spec

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
%{!?_arch: %define _arch dummy}
33
%{!?make: %define make make}
44
%define makeflags %{?_smp_mflags} ARCH=%{ARCH}
5-
%define __spec_install_post /usr/lib/rpm/brp-compress || :
6-
%define debug_package %{nil}
75

86
Name: kernel
97
Summary: The Linux Kernel
@@ -56,6 +54,38 @@ This package provides debug information for the kernel image and modules from th
5654
%define install_mod_strip 1
5755
%endif
5856

57+
%if %{with_debuginfo_rpm}
58+
# list of debuginfo-related options taken from distribution kernel.spec
59+
# files
60+
%undefine _include_minidebuginfo
61+
%undefine _find_debuginfo_dwz_opts
62+
%undefine _unique_build_ids
63+
%undefine _unique_debug_names
64+
%undefine _unique_debug_srcs
65+
%undefine _debugsource_packages
66+
%undefine _debuginfo_subpackages
67+
%global _find_debuginfo_opts -r
68+
%global _missing_build_ids_terminate_build 1
69+
%global _no_recompute_build_ids 1
70+
%{debug_package}
71+
72+
# later, we make all modules executable so that find-debuginfo.sh strips
73+
# them up. but they don't actually need to be executable, so remove the
74+
# executable bit, taking care to do it _after_ find-debuginfo.sh has run
75+
%define __spec_install_post \
76+
%{?__debug_package:%{__debug_install_post}} \
77+
%{__arch_install_post} \
78+
%{__os_install_post} \
79+
find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \\\
80+
| xargs --no-run-if-empty chmod u-x
81+
%else
82+
%define __spec_install_post /usr/lib/rpm/brp-compress || :
83+
%endif
84+
# some (but not all) versions of rpmbuild emit %%debug_package with
85+
# %%install. since we've already emitted it manually, that would cause
86+
# a package redefinition error. ensure that doesn't happen
87+
%define debug_package %{nil}
88+
5989
%prep
6090
%setup -q -n linux
6191
cp %{SOURCE1} .config
@@ -99,14 +129,22 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA
99129
echo "%exclude /lib/modules/%{KERNELRELEASE}/build"
100130
} > %{buildroot}/kernel.list
101131

102-
%if %{with_debuginfo_manual}
132+
%if 0%{with_debuginfo_manual}%{with_debuginfo_rpm} > 0
103133
# copying vmlinux directly to the debug directory means it will not get
104134
# stripped (but its source paths will still be collected + fixed up)
105135
mkdir -p %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
106136
cp vmlinux %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
137+
%endif
107138

108-
echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginfo.list
139+
%if %{with_debuginfo_rpm}
140+
# make modules executable so that find-debuginfo.sh strips them. this
141+
# will be undone later in %%__spec_install_post
142+
find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \
143+
| xargs --no-run-if-empty chmod u+x
144+
%endif
109145

146+
%if %{with_debuginfo_manual}
147+
echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginfo.list
110148
while read -r mod; do
111149
mod="${mod%.o}.ko"
112150
dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}"
@@ -124,6 +162,10 @@ done < modules.order
124162

125163
%clean
126164
rm -rf %{buildroot}
165+
%if %{with_debuginfo_rpm}
166+
rm -f debugfiles.list debuglinks.list debugsourcefiles.list debugsources.list \
167+
elfbins.list
168+
%endif
127169

128170
%post
129171
if [ -x /usr/bin/kernel-install ]; then

scripts/package/mkspec

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ else
2323
echo '%define with_devel 0'
2424
fi
2525

26+
# use %{debug_package} machinery to generate -debuginfo
27+
with_debuginfo_rpm=0
2628
# manually generate -debuginfo package
2729
with_debuginfo_manual=0
2830
# debuginfo package generation uses find-debuginfo.sh under the hood,
@@ -56,9 +58,12 @@ if grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf &&
5658
with_debuginfo_manual='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}'
5759
fi
5860
fi
61+
else
62+
with_debuginfo_rpm='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}'
5963
fi
6064
fi
6165
echo "%define with_debuginfo_manual $with_debuginfo_manual"
66+
echo "%define with_debuginfo_rpm $with_debuginfo_rpm"
6267

6368
cat<<EOF
6469
%define ARCH ${ARCH}

0 commit comments

Comments
 (0)