DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] build: try to get kernel version from kernel source
@ 2022-02-26 21:40 Ferdinand Thiessen
  2022-02-28 18:11 ` Bruce Richardson
  2022-03-03 13:15 ` [PATCH v2] " Ferdinand Thiessen
  0 siblings, 2 replies; 7+ messages in thread
From: Ferdinand Thiessen @ 2022-02-26 21:40 UTC (permalink / raw)
  To: bruce.richardson; +Cc: dev, Ferdinand Thiessen

When building the kernel modules, try to get the kernel
version from the kernel sources first. This fixes the
kernel modules installation directory if the target kernel
version differs from the host kernel version, like for
CI build or when packaging for linux distributions.

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
---
 kernel/linux/meson.build | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/kernel/linux/meson.build b/kernel/linux/meson.build
index d8fb20c1c3..78f28ffb0c 100644
--- a/kernel/linux/meson.build
+++ b/kernel/linux/meson.build
@@ -10,17 +10,23 @@ install = not meson.is_cross_build()
 cross_args = []
 
 if not meson.is_cross_build()
-    # native build
-    kernel_version = run_command('uname', '-r', check: true).stdout().strip()
+    # native target build
+    kernel_version = run_command('uname', '-r').stdout().strip()
+    if kernel_source_dir != ''
+        # Try kernel release from sources first
+        r = run_command('make', '-s', '-C', kernel_source_dir, 'kernelrelease', check: false)
+        if r.returncode() == 0
+            kernel_version = r.stdout().strip()
+        endif
+    else
+        # use default path for native builds
+        kernel_source_dir = '/lib/modules/' + kernel_version + '/source'
+    endif
     kernel_install_dir = '/lib/modules/' + kernel_version + '/extra/dpdk'
     if kernel_build_dir == ''
         # use default path for native builds
         kernel_build_dir = '/lib/modules/' + kernel_version + '/build'
     endif
-    if kernel_source_dir == ''
-        # use default path for native builds
-        kernel_source_dir = '/lib/modules/' + kernel_version + '/source'
-    endif
 
     # test running make in kernel directory, using "make kernelversion"
     make_returncode = run_command('make', '-sC', kernel_build_dir,
-- 
2.35.1


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

* Re: [PATCH] build: try to get kernel version from kernel source
  2022-02-26 21:40 [PATCH] build: try to get kernel version from kernel source Ferdinand Thiessen
@ 2022-02-28 18:11 ` Bruce Richardson
  2022-03-03 13:15 ` [PATCH v2] " Ferdinand Thiessen
  1 sibling, 0 replies; 7+ messages in thread
From: Bruce Richardson @ 2022-02-28 18:11 UTC (permalink / raw)
  To: Ferdinand Thiessen; +Cc: dev

On Sat, Feb 26, 2022 at 10:40:45PM +0100, Ferdinand Thiessen wrote:
> When building the kernel modules, try to get the kernel
> version from the kernel sources first. This fixes the
> kernel modules installation directory if the target kernel
> version differs from the host kernel version, like for
> CI build or when packaging for linux distributions.
> 
> Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
> ---

On initial review I don't see any problems with the overall approach taken
by this patch, but I think others more familiar with kernel build paths
could do with reviewing it too. One small comment inline below.

/Bruce

>  kernel/linux/meson.build | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/linux/meson.build b/kernel/linux/meson.build
> index d8fb20c1c3..78f28ffb0c 100644
> --- a/kernel/linux/meson.build
> +++ b/kernel/linux/meson.build
> @@ -10,17 +10,23 @@ install = not meson.is_cross_build()
>  cross_args = []
>  
>  if not meson.is_cross_build()
> -    # native build
> -    kernel_version = run_command('uname', '-r', check: true).stdout().strip()
> +    # native target build
> +    kernel_version = run_command('uname', '-r').stdout().strip()

These two lines can be dropped from the patch, I think. The comment change
doesn't appear significant, and we definitely want to keep the "check:
true" in the run_command call to avoid meson warnings.

> +    if kernel_source_dir != ''
> +        # Try kernel release from sources first
> +        r = run_command('make', '-s', '-C', kernel_source_dir, 'kernelrelease', check: false)
> +        if r.returncode() == 0
> +            kernel_version = r.stdout().strip()
> +        endif
> +    else
> +        # use default path for native builds
> +        kernel_source_dir = '/lib/modules/' + kernel_version + '/source'
> +    endif
>      kernel_install_dir = '/lib/modules/' + kernel_version + '/extra/dpdk'
>      if kernel_build_dir == ''
>          # use default path for native builds
>          kernel_build_dir = '/lib/modules/' + kernel_version + '/build'
>      endif
> -    if kernel_source_dir == ''
> -        # use default path for native builds
> -        kernel_source_dir = '/lib/modules/' + kernel_version + '/source'
> -    endif
>  
>      # test running make in kernel directory, using "make kernelversion"
>      make_returncode = run_command('make', '-sC', kernel_build_dir,
> -- 
> 2.35.1
> 

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

* [PATCH v2] build: try to get kernel version from kernel source
  2022-02-26 21:40 [PATCH] build: try to get kernel version from kernel source Ferdinand Thiessen
  2022-02-28 18:11 ` Bruce Richardson
@ 2022-03-03 13:15 ` Ferdinand Thiessen
  2022-03-08 15:54   ` Ferruh Yigit
  1 sibling, 1 reply; 7+ messages in thread
From: Ferdinand Thiessen @ 2022-03-03 13:15 UTC (permalink / raw)
  To: bruce.richardson; +Cc: dev, Ferdinand Thiessen

When building the kernel modules, try to get the kernel
version from the kernel sources first. This fixes the
kernel modules installation directory if the target kernel
version differs from the host kernel version, like for
CI build or when packaging for linux distributions.

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
---
 kernel/linux/meson.build | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/kernel/linux/meson.build b/kernel/linux/meson.build
index d8fb20c1c3..16a0948994 100644
--- a/kernel/linux/meson.build
+++ b/kernel/linux/meson.build
@@ -12,15 +12,21 @@ cross_args = []
 if not meson.is_cross_build()
     # native build
     kernel_version = run_command('uname', '-r', check: true).stdout().strip()
+    if kernel_source_dir != ''
+        # Try kernel release from sources first
+        r = run_command('make', '-s', '-C', kernel_source_dir, 'kernelrelease', check: false)
+        if r.returncode() == 0
+            kernel_version = r.stdout().strip()
+        endif
+    else
+        # use default path for native builds
+        kernel_source_dir = '/lib/modules/' + kernel_version + '/source'
+    endif
     kernel_install_dir = '/lib/modules/' + kernel_version + '/extra/dpdk'
     if kernel_build_dir == ''
         # use default path for native builds
         kernel_build_dir = '/lib/modules/' + kernel_version + '/build'
     endif
-    if kernel_source_dir == ''
-        # use default path for native builds
-        kernel_source_dir = '/lib/modules/' + kernel_version + '/source'
-    endif
 
     # test running make in kernel directory, using "make kernelversion"
     make_returncode = run_command('make', '-sC', kernel_build_dir,
-- 
2.35.1


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

* Re: [PATCH v2] build: try to get kernel version from kernel source
  2022-03-03 13:15 ` [PATCH v2] " Ferdinand Thiessen
@ 2022-03-08 15:54   ` Ferruh Yigit
  2022-06-08 15:39     ` David Marchand
  0 siblings, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2022-03-08 15:54 UTC (permalink / raw)
  To: Ferdinand Thiessen, bruce.richardson; +Cc: dev

On 3/3/2022 1:15 PM, Ferdinand Thiessen wrote:
> When building the kernel modules, try to get the kernel
> version from the kernel sources first. This fixes the
> kernel modules installation directory if the target kernel
> version differs from the host kernel version, like for
> CI build or when packaging for linux distributions.
> 
> Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>

lgtm

Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>

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

* Re: [PATCH v2] build: try to get kernel version from kernel source
  2022-03-08 15:54   ` Ferruh Yigit
@ 2022-06-08 15:39     ` David Marchand
  0 siblings, 0 replies; 7+ messages in thread
From: David Marchand @ 2022-06-08 15:39 UTC (permalink / raw)
  To: Ferdinand Thiessen; +Cc: Bruce Richardson, dev, Ferruh Yigit

On Tue, Mar 8, 2022 at 4:55 PM Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>
> On 3/3/2022 1:15 PM, Ferdinand Thiessen wrote:
> > When building the kernel modules, try to get the kernel
> > version from the kernel sources first. This fixes the
> > kernel modules installation directory if the target kernel
> > version differs from the host kernel version, like for
> > CI build or when packaging for linux distributions.
> >
> > Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks.


-- 
David Marchand


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

* Re: [PATCH v2] build: try to get kernel version from kernel source
  2022-03-03 13:12 Ferdinand Thiessen
@ 2022-03-03 13:37 ` Bruce Richardson
  0 siblings, 0 replies; 7+ messages in thread
From: Bruce Richardson @ 2022-03-03 13:37 UTC (permalink / raw)
  To: Ferdinand Thiessen; +Cc: dev

On Thu, Mar 03, 2022 at 02:12:30PM +0100, Ferdinand Thiessen wrote:
> When building the kernel modules, try to get the kernel
> version from the kernel sources first. This fixes the
> kernel modules installation directory if the target kernel
> version differs from the host kernel version, like for
> CI build or when packaging for linux distributions.
> 
> Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
> ---
>  kernel/linux/meson.build | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

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

* [PATCH v2] build: try to get kernel version from kernel source
@ 2022-03-03 13:12 Ferdinand Thiessen
  2022-03-03 13:37 ` Bruce Richardson
  0 siblings, 1 reply; 7+ messages in thread
From: Ferdinand Thiessen @ 2022-03-03 13:12 UTC (permalink / raw)
  To: bruce.richardson; +Cc: dev, Ferdinand Thiessen

When building the kernel modules, try to get the kernel
version from the kernel sources first. This fixes the
kernel modules installation directory if the target kernel
version differs from the host kernel version, like for
CI build or when packaging for linux distributions.

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
---
 kernel/linux/meson.build | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/kernel/linux/meson.build b/kernel/linux/meson.build
index d8fb20c1c3..16a0948994 100644
--- a/kernel/linux/meson.build
+++ b/kernel/linux/meson.build
@@ -12,15 +12,21 @@ cross_args = []
 if not meson.is_cross_build()
     # native build
     kernel_version = run_command('uname', '-r', check: true).stdout().strip()
+    if kernel_source_dir != ''
+        # Try kernel release from sources first
+        r = run_command('make', '-s', '-C', kernel_source_dir, 'kernelrelease', check: false)
+        if r.returncode() == 0
+            kernel_version = r.stdout().strip()
+        endif
+    else
+        # use default path for native builds
+        kernel_source_dir = '/lib/modules/' + kernel_version + '/source'
+    endif
     kernel_install_dir = '/lib/modules/' + kernel_version + '/extra/dpdk'
     if kernel_build_dir == ''
         # use default path for native builds
         kernel_build_dir = '/lib/modules/' + kernel_version + '/build'
     endif
-    if kernel_source_dir == ''
-        # use default path for native builds
-        kernel_source_dir = '/lib/modules/' + kernel_version + '/source'
-    endif
 
     # test running make in kernel directory, using "make kernelversion"
     make_returncode = run_command('make', '-sC', kernel_build_dir,
-- 
2.35.1


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

end of thread, other threads:[~2022-06-08 15:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-26 21:40 [PATCH] build: try to get kernel version from kernel source Ferdinand Thiessen
2022-02-28 18:11 ` Bruce Richardson
2022-03-03 13:15 ` [PATCH v2] " Ferdinand Thiessen
2022-03-08 15:54   ` Ferruh Yigit
2022-06-08 15:39     ` David Marchand
2022-03-03 13:12 Ferdinand Thiessen
2022-03-03 13:37 ` Bruce Richardson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).