Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* [PATCH] kbuild: rpm-pkg: Include symvers in kernel package
@ 2025-03-16  9:11 Tzafrir Cohen
  0 siblings, 0 replies; 4+ messages in thread
From: Tzafrir Cohen @ 2025-03-16  9:11 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Tzafrir Cohen

This change adds an extra file to the generated kernel rpm package:
symvers.gz under the modules directory.

With that extra file, rpm-build on some systems (specifically many
systems based on Centos >= 8) can create better dependencies when
it builds binary modules packages using weak-modules.

Normally it creates dependencies of type:

  kmod(foo.ko)

but with the symver information available, it will create extra
dependencies of the sort of:

  kernel(foo_sym_bol) = 0x112233445566

And therefore if a binary kernel module was built with that specific
kernel, the package manager can check if another kernel provides
foo_sym_bol and of the same version. This is similar to the tests
that The weak-modules script runs at run time.

Using gzip explicitly as with Centos 8 only symvers.gz is tested for.
See /usr/lib/rpm/fileattrs/kabi.attr . Centos 9 and 10 also tests for
symvers.xz .

Signed-off-by: Tzafrir Cohen <nvidia@cohens.org.il>
---
 scripts/package/kernel.spec | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index ac3e5ac01d8a..06a792731282 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -62,6 +62,7 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEAS
 %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
 cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
 cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
+%{__gzip} -n -9 <Module.symvers > %{buildroot}/lib/modules/%{KERNELRELEASE}/symvers.gz
 if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d ${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then
 	%{make} %{makeflags} INSTALL_DTBS_PATH=%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb dtbs_install
 fi
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] kbuild: rpm-pkg: Include symvers in kernel package
@ 2025-04-07 10:58 Tzafrir Cohen
  2025-05-07 12:20 ` Masahiro Yamada
  0 siblings, 1 reply; 4+ messages in thread
From: Tzafrir Cohen @ 2025-04-07 10:58 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Tzafrir Cohen

This change adds an extra file to the generated kernel rpm package:
symvers.gz under the modules directory.

With that extra file, rpm-build on some systems (specifically many
systems based on Centos >= 8) can create better dependencies when
it builds binary modules packages using weak-modules.

Normally it creates dependencies of type:

  kmod(foo.ko)

but with the symver information available, it will create extra
dependencies of the sort of:

  kernel(foo_sym_bol) = 0x112233445566

And therefore if a binary kernel module was built with that specific
kernel, the package manager can check if another kernel provides
foo_sym_bol and of the same version. This is similar to the tests
that The weak-modules script runs at run time.

Using gzip explicitly as with Centos 8 only symvers.gz is tested for.
See /usr/lib/rpm/fileattrs/kabi.attr . Centos 9 and 10 also tests for
symvers.xz .

Signed-off-by: Tzafrir Cohen <nvidia@cohens.org.il>
---
 scripts/package/kernel.spec | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index 726f34e11960..2a2de5df83ed 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -90,6 +90,7 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEAS
 %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
 cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
 cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
+%{__gzip} -n -9 <Module.symvers > %{buildroot}/lib/modules/%{KERNELRELEASE}/symvers.gz
 if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d ${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then
 	%{make} %{makeflags} INSTALL_DTBS_PATH=%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb dtbs_install
 fi
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: rpm-pkg: Include symvers in kernel package
  2025-04-07 10:58 [PATCH] kbuild: rpm-pkg: Include symvers in kernel package Tzafrir Cohen
@ 2025-05-07 12:20 ` Masahiro Yamada
  2025-05-09  8:16   ` Tzafrir Cohen
  0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2025-05-07 12:20 UTC (permalink / raw)
  To: Tzafrir Cohen; +Cc: linux-kbuild

Sorry for the late reply.

To align with Fedora's kernel.spec file,
is it better to use 'compression' macro etc. ?





--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -45,6 +45,10 @@ This package provides kernel headers and makefiles
sufficient to build modules
 against the %{version} kernel package.
 %endif

+%global compression xz
+%global compression_flags --compress
+%global compext xz
+
 %if %{with_debuginfo}
 # list of debuginfo-related options taken from distribution kernel.spec
 # files
@@ -91,7 +95,7 @@ cp $(%{make} %{makeflags} -s image_name)
%{buildroot}/lib/modules/%{KERNELRELEAS
 %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
 cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
 cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
-%{__gzip} -n -9 <Module.symvers >
%{buildroot}/lib/modules/%{KERNELRELEASE}/symvers.gz
+%{compression} --stdout %{compression_flags} < Module.symvers >
%{buildroot}/lib/modules/%{KERNELRELEASE}/symvers.%{compext}
 if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d
${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then
        %{make} %{makeflags}
INSTALL_DTBS_PATH=%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb
dtbs_install
 fi




On Mon, Apr 7, 2025 at 7:59 PM Tzafrir Cohen <nvidia@cohens.org.il> wrote:
>
> This change adds an extra file to the generated kernel rpm package:
> symvers.gz under the modules directory.
>
> With that extra file, rpm-build on some systems (specifically many
> systems based on Centos >= 8) can create better dependencies when
> it builds binary modules packages using weak-modules.
>
> Normally it creates dependencies of type:
>
>   kmod(foo.ko)
>
> but with the symver information available, it will create extra
> dependencies of the sort of:
>
>   kernel(foo_sym_bol) = 0x112233445566
>
> And therefore if a binary kernel module was built with that specific
> kernel, the package manager can check if another kernel provides
> foo_sym_bol and of the same version. This is similar to the tests
> that The weak-modules script runs at run time.
>
> Using gzip explicitly as with Centos 8 only symvers.gz is tested for.
> See /usr/lib/rpm/fileattrs/kabi.attr . Centos 9 and 10 also tests for
> symvers.xz .
>
> Signed-off-by: Tzafrir Cohen <nvidia@cohens.org.il>
> ---
>  scripts/package/kernel.spec | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index 726f34e11960..2a2de5df83ed 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -90,6 +90,7 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEAS
>  %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
>  cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
>  cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
> +%{__gzip} -n -9 <Module.symvers > %{buildroot}/lib/modules/%{KERNELRELEASE}/symvers.gz
>  if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d ${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then
>         %{make} %{makeflags} INSTALL_DTBS_PATH=%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb dtbs_install
>  fi
> --
> 2.47.2
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: rpm-pkg: Include symvers in kernel package
  2025-05-07 12:20 ` Masahiro Yamada
@ 2025-05-09  8:16   ` Tzafrir Cohen
  0 siblings, 0 replies; 4+ messages in thread
From: Tzafrir Cohen @ 2025-05-09  8:16 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: linux-kbuild

Hi,

On Wed, May 07, 2025 at 09:20:05PM +0900, Masahiro Yamada wrote:
>Sorry for the late reply.
>
>To align with Fedora's kernel.spec file,
>is it better to use 'compression' macro etc. ?

Yes, looks like a better idea. I guess we may maintain our own change for
Centos8 compatibility (overriding just those macros).

-- 
mail / xmpp / matrix: tzafrir@cohens.org.il

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-09  8:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-07 10:58 [PATCH] kbuild: rpm-pkg: Include symvers in kernel package Tzafrir Cohen
2025-05-07 12:20 ` Masahiro Yamada
2025-05-09  8:16   ` Tzafrir Cohen
  -- strict thread matches above, loose matches on Subject: below --
2025-03-16  9:11 Tzafrir Cohen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox