kernel-yocto.bbclass: Fixup do_kernel_configcheck usage of KMETA

Message ID 20220421035819.3741349-1-russ.dill@nikolamotor.com
State Accepted, archived
Commit f4a3e80a4a6f4f709d09940dcaf45b2b00654496
Headers show
Series kernel-yocto.bbclass: Fixup do_kernel_configcheck usage of KMETA | expand

Commit Message

Russ Dill April 21, 2022, 3:58 a.m. UTC
The do_kernel_configcheck task requires a meta directory, normally
set by ${KMETA}. The meta directory is taken as a relative path
from ${S}:

        outfile = "{}/{}/cfg/mismatch.txt".format( s, kmeta )

However, when checking for the presence of ${KMETA} the current
working directory is searched. This will almost always fail and
"kgit --meta" is used instead. If the user does have a path in
their current working directory that matches the ${KMETA}
variable but the path is not present within the kernel source
directory, the build will fail if it tries to write config errors/
warnings to that path.

If ${KMETA} is not set, the same problem exists with the hard-coded
"meta" directory.

Fix these issues by checking for ${KMETA} within ${S} rather than
the current working directory. Additionally, drop the hardcoded
backup directory "meta" as it hasn't been functioning and
probably has no users

Signed-off-by: Russ Dill <russ.dill@nikolamotor.com>
---
 meta/classes/kernel-yocto.bbclass | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Bruce Ashfield April 21, 2022, 12:31 p.m. UTC | #1
On Wed, Apr 20, 2022 at 11:58 PM Russ Dill <russ.dill@nikolamotor.com> wrote:
>
> The do_kernel_configcheck task requires a meta directory, normally
> set by ${KMETA}. The meta directory is taken as a relative path
> from ${S}:
>
>         outfile = "{}/{}/cfg/mismatch.txt".format( s, kmeta )
>
> However, when checking for the presence of ${KMETA} the current
> working directory is searched. This will almost always fail and
> "kgit --meta" is used instead. If the user does have a path in
> their current working directory that matches the ${KMETA}
> variable but the path is not present within the kernel source
> directory, the build will fail if it tries to write config errors/
> warnings to that path.
>
> If ${KMETA} is not set, the same problem exists with the hard-coded
> "meta" directory.
>
> Fix these issues by checking for ${KMETA} within ${S} rather than
> the current working directory. Additionally, drop the hardcoded
> backup directory "meta" as it hasn't been functioning and
> probably has no users

Looks good to me. I continued to poke at this yesterday, and can't
think of any users this will break .. and if it does, I'll be around to
fix any fallout.

Acked-by: Bruce Ashfield <bruce.ashfield@gmail.com>

>
> Signed-off-by: Russ Dill <russ.dill@nikolamotor.com>
> ---
>  meta/classes/kernel-yocto.bbclass | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass
> index 1d5a8cdf29..4cb638864c 100644
> --- a/meta/classes/kernel-yocto.bbclass
> +++ b/meta/classes/kernel-yocto.bbclass
> @@ -521,15 +521,15 @@ python do_config_analysis() {
>  python do_kernel_configcheck() {
>      import re, string, sys, subprocess
>
> -    # if KMETA isn't set globally by a recipe using this routine, we need to
> -    # set the default to 'meta'. Otherwise, kconf_check is not passed a valid
> -    # meta-series for processing
> -    kmeta = d.getVar("KMETA") or "meta"
> -    if not os.path.exists(kmeta):
> -        kmeta = subprocess.check_output(['kgit', '--meta'], cwd=d.getVar('S')).decode('utf-8').rstrip()
> -
>      s = d.getVar('S')
>
> +    # if KMETA isn't set globally by a recipe using this routine, use kgit to
> +    # locate or create the meta directory. Otherwise, kconf_check is not
> +    # passed a valid meta-series for processing
> +    kmeta = d.getVar("KMETA")
> +    if not kmeta or not os.path.exists('{}/{}'.format(s,kmeta)):
> +        kmeta = subprocess.check_output(['kgit', '--meta'], cwd=d.getVar('S')).decode('utf-8').rstrip()
> +
>      env = os.environ.copy()
>      env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/")
>      env['LD'] = d.getVar('KERNEL_LD')
> --
> 2.25.1
>

Patch

diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass
index 1d5a8cdf29..4cb638864c 100644
--- a/meta/classes/kernel-yocto.bbclass
+++ b/meta/classes/kernel-yocto.bbclass
@@ -521,15 +521,15 @@  python do_config_analysis() {
 python do_kernel_configcheck() {
     import re, string, sys, subprocess
 
-    # if KMETA isn't set globally by a recipe using this routine, we need to
-    # set the default to 'meta'. Otherwise, kconf_check is not passed a valid
-    # meta-series for processing
-    kmeta = d.getVar("KMETA") or "meta"
-    if not os.path.exists(kmeta):
-        kmeta = subprocess.check_output(['kgit', '--meta'], cwd=d.getVar('S')).decode('utf-8').rstrip()
-
     s = d.getVar('S')
 
+    # if KMETA isn't set globally by a recipe using this routine, use kgit to
+    # locate or create the meta directory. Otherwise, kconf_check is not
+    # passed a valid meta-series for processing
+    kmeta = d.getVar("KMETA")
+    if not kmeta or not os.path.exists('{}/{}'.format(s,kmeta)):
+        kmeta = subprocess.check_output(['kgit', '--meta'], cwd=d.getVar('S')).decode('utf-8').rstrip()
+
     env = os.environ.copy()
     env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/")
     env['LD'] = d.getVar('KERNEL_LD')