Re: [PATCH 2/2] kbuild: rpm-pkg: build debuginfo and debugsource RPMs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry for the long delay.


On Tue, Feb 11, 2025 at 10:12 AM Uday Shankar <ushankar@xxxxxxxxxxxxxxx> wrote:
> Note that this feature is incompatible with CONFIG_MODULE_COMPRESS -
> if it is turned on, the module .ko files are compressed before
> find-debuginfo.sh sees them, and it will not be able to extract
> debuginfo from them. There are two potential paths forward here:
> - teach find-debuginfo.sh to extract debuginfo from compressed kernel
>   modules
> - teach the kernel build process to produce split debuginfo and then
>   package that directly, bypassing find-debuginfo.sh


'make bindeb-pkg'  (Debian package) is able to build the debug package with
CONFIG_MODULE_COMPRESS enabled.
(see scripts/package/builddeb if you are interested)
I have not checked if this works for 'make binrpm-pkg' or not.
If this is a tricky case, I am OK with giving up CONFIG_MODULE_COMPRESS.



> But leaving CONFIG_MODULE_COMPRESS off seems common, so taking this
> patch as is still feels useful.
>
> Signed-off-by: Uday Shankar <ushankar@xxxxxxxxxxxxxxx>
> ---
>  scripts/package/kernel.spec | 31 +++++++++++++++++++++++++++++--
>  scripts/package/mkspec      |  3 +++
>  2 files changed, 32 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index ac3e5ac01d8a4daa031bc9e70b792a68f74c388b..efd7b1f43c64c8324bb0a6e540f2ba5f77f9de1e 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -2,8 +2,6 @@
>  %{!?_arch: %define _arch dummy}
>  %{!?make: %define make make}
>  %define makeflags %{?_smp_mflags} ARCH=%{ARCH}
> -%define __spec_install_post /usr/lib/rpm/brp-compress || :
> -%define debug_package %{nil}
>
>  Name: kernel
>  Summary: The Linux Kernel
> @@ -46,6 +44,24 @@ This package provides kernel headers and makefiles sufficient to build modules
>  against the %{version} kernel package.
>  %endif
>
> +%if %{with_debuginfo}
> +# list of debuginfo-related options taken from distribution spec files
> +%undefine _include_minidebuginfo
> +%undefine _find_debuginfo_dwz_opts
> +%undefine _unique_build_ids
> +%undefine _unique_debug_names
> +%undefine _unique_debug_srcs
> +%undefine _debuginfo_subpackages
> +%global _find_debuginfo_opts -r
> +%global _missing_build_ids_terminate_build 1
> +%global _no_recompute_build_ids 1
> +%{debug_package}
> +%endif
> +# some (but not all) versions of rpmbuild emit %%debug_package with
> +# %%install. since we've already emitted it manually, that would cause
> +# a package redefinition error. ensure that doesn't happen
> +%define debug_package %{nil}
> +
>  %prep
>  %setup -q -n linux
>  cp %{SOURCE1} .config
> @@ -89,8 +105,19 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA
>         echo "%exclude /lib/modules/%{KERNELRELEASE}/build"
>  } > %{buildroot}/kernel.list
>
> +# make modules executable so that find-debuginfo.sh strips them
> +find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \
> +       | xargs --no-run-if-empty chmod u+x

This seems necessary and correct.

One side-effect I noticed is that *.ko under /lib/modules/$(uname -r)/
now have +x permissions. (Previously, they were non-executables).

I checked Fedora. Modules under /lib/modules/$(uname -r)/
do not have +x permissions.

Do you know how Fedora's kernel.spec handles this?



> +
> +%if %{with_debuginfo}
> +mkdir -p %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
> +cp vmlinux %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
> +%endif
> +
>  %clean
>  rm -rf %{buildroot}
> +rm -f debugfiles.list debuglinks.list debugsourcefiles.list debugsources.list \
> +       elfbins.list
>
>  %post
>  if [ -x /usr/bin/kernel-install ]; then
> diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> index 4dc1466dfc815c110eb7206f83dd874b17f5170f..4c96bdca381a2fb4cc57415ca914d14e37e16caa 100755
> --- a/scripts/package/mkspec
> +++ b/scripts/package/mkspec
> @@ -23,6 +23,9 @@ else
>  echo '%define with_devel 0'
>  fi
>
> +WITH_DEBUGINFO=$(grep -c CONFIG_DEBUG_INFO=y include/config/auto.conf)
> +echo "%define with_debuginfo ${WITH_DEBUGINFO}"
> +

How about this code?

if grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf; then
echo '%define with_debuginfo %{?_without_debuginfo: 0}
%{?!_without_debuginfo: 1}'
else
echo '%define with_debuginfo 0'
fi

This allows users to skip the debuginfo package
and aligns with the existing code a few lines above.

Also, it is compatible with Fedora's kernel.spec.
https://src.fedoraproject.org/rpms/kernel/blob/rawhide/f/kernel.spec#_236


If you do not support CONFIG_MODULE_COMPRESS,
you can check it here.


>  cat<<EOF
>  %define ARCH ${ARCH}
>  %define KERNELRELEASE ${KERNELRELEASE}
>
> --
> 2.34.1
>
>


-- 
Best Regards
Masahiro Yamada





[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux