Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kernel: rpm-pkg: Restore find-debuginfo.sh approach to -debuginfo package

Commit 62089b804895 ("kbuild: rpm-pkg: Generate debuginfo package
manually") effectively reverted commit a7c699d090a1 ("kbuild: rpm-pkg:
build a debuginfo RPM") but the approach it took is not safe for older
RPM releases. Restore commit a7c699d090a1 ("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: 62089b804895 ("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>

+51 -4
+46 -4
scripts/package/kernel.spec
··· 2 2 %{!?_arch: %define _arch dummy} 3 3 %{!?make: %define make make} 4 4 %define makeflags %{?_smp_mflags} ARCH=%{ARCH} 5 - %define __spec_install_post /usr/lib/rpm/brp-compress || : 6 - %define debug_package %{nil} 7 5 8 6 Name: kernel 9 7 Summary: The Linux Kernel ··· 54 56 %define install_mod_strip 1 55 57 %endif 56 58 59 + %if %{with_debuginfo_rpm} 60 + # list of debuginfo-related options taken from distribution kernel.spec 61 + # files 62 + %undefine _include_minidebuginfo 63 + %undefine _find_debuginfo_dwz_opts 64 + %undefine _unique_build_ids 65 + %undefine _unique_debug_names 66 + %undefine _unique_debug_srcs 67 + %undefine _debugsource_packages 68 + %undefine _debuginfo_subpackages 69 + %global _find_debuginfo_opts -r 70 + %global _missing_build_ids_terminate_build 1 71 + %global _no_recompute_build_ids 1 72 + %{debug_package} 73 + 74 + # later, we make all modules executable so that find-debuginfo.sh strips 75 + # them up. but they don't actually need to be executable, so remove the 76 + # executable bit, taking care to do it _after_ find-debuginfo.sh has run 77 + %define __spec_install_post \ 78 + %{?__debug_package:%{__debug_install_post}} \ 79 + %{__arch_install_post} \ 80 + %{__os_install_post} \ 81 + find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \\\ 82 + | xargs --no-run-if-empty chmod u-x 83 + %else 84 + %define __spec_install_post /usr/lib/rpm/brp-compress || : 85 + %endif 86 + # some (but not all) versions of rpmbuild emit %%debug_package with 87 + # %%install. since we've already emitted it manually, that would cause 88 + # a package redefinition error. ensure that doesn't happen 89 + %define debug_package %{nil} 90 + 57 91 %prep 58 92 %setup -q -n linux 59 93 cp %{SOURCE1} .config ··· 129 99 echo "%exclude /lib/modules/%{KERNELRELEASE}/build" 130 100 } > %{buildroot}/kernel.list 131 101 132 - %if %{with_debuginfo_manual} 102 + %if 0%{with_debuginfo_manual}%{with_debuginfo_rpm} > 0 133 103 # copying vmlinux directly to the debug directory means it will not get 134 104 # stripped (but its source paths will still be collected + fixed up) 135 105 mkdir -p %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE} 136 106 cp vmlinux %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE} 107 + %endif 137 108 109 + %if %{with_debuginfo_rpm} 110 + # make modules executable so that find-debuginfo.sh strips them. this 111 + # will be undone later in %%__spec_install_post 112 + find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \ 113 + | xargs --no-run-if-empty chmod u+x 114 + %endif 115 + 116 + %if %{with_debuginfo_manual} 138 117 echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginfo.list 139 - 140 118 while read -r mod; do 141 119 mod="${mod%.o}.ko" 142 120 dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}" ··· 162 124 163 125 %clean 164 126 rm -rf %{buildroot} 127 + %if %{with_debuginfo_rpm} 128 + rm -f debugfiles.list debuglinks.list debugsourcefiles.list debugsources.list \ 129 + elfbins.list 130 + %endif 165 131 166 132 %post 167 133 if [ -x /usr/bin/kernel-install ]; then
+5
scripts/package/mkspec
··· 23 23 echo '%define with_devel 0' 24 24 fi 25 25 26 + # use %{debug_package} machinery to generate -debuginfo 27 + with_debuginfo_rpm=0 26 28 # manually generate -debuginfo package 27 29 with_debuginfo_manual=0 28 30 # debuginfo package generation uses find-debuginfo.sh under the hood, ··· 58 56 with_debuginfo_manual='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}' 59 57 fi 60 58 fi 59 + else 60 + with_debuginfo_rpm='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}' 61 61 fi 62 62 fi 63 63 echo "%define with_debuginfo_manual $with_debuginfo_manual" 64 + echo "%define with_debuginfo_rpm $with_debuginfo_rpm" 64 65 65 66 cat<<EOF 66 67 %define ARCH ${ARCH}