diff mbox series

bitbake-setup: make "path" optional

Message ID 20251103214804.2004903-1-yoann.congal@smile.fr
State Accepted, archived
Commit 6727d0852f3f89a8b245a6b1d5cdac6e67220c15
Headers show
Series bitbake-setup: make "path" optional | expand

Commit Message

Yoann Congal Nov. 3, 2025, 9:48 p.m. UTC
From: Yoann Congal <yoann.congal@smile.fr>

Layer names and path are often redundant. Allow users to omit the path
key when it is equal to the layer name by using the layer name as a
default value for its path.

For example, from poky-master.conf.json:
  "bitbake": {
    ...
    "path": "bitbake"
  },
  "openembedded-core": {
    ...
    "path": "openembedded-core"
  },
  "meta-yocto": {
    ...
    "path": "meta-yocto"
  },
  "yocto-docs": {
    ...
    "path": "yocto-docs"
  }

Remove redundant "path" keys from default-registry and tests.

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
Note: Now that all "path" keys are removed (because they were all redundant),
we need to ensure the "path" code path is tested by adding a test for
it.
---
 bin/bitbake-setup                                    |  2 +-
 .../configurations/oe-nodistro.conf.json             |  9 +++------
 .../configurations/poky-master.conf.json             | 12 ++++--------
 lib/bb/tests/setup.py                                |  3 +--
 4 files changed, 9 insertions(+), 17 deletions(-)

Comments

Alexander Kanavin Nov. 4, 2025, 9:11 a.m. UTC | #1
Thanks, lgtm.

Alex

On Mon, 3 Nov 2025 at 22:48, Yoann Congal via lists.openembedded.org
<yoann.congal=smile.fr@lists.openembedded.org> wrote:
>
> From: Yoann Congal <yoann.congal@smile.fr>
>
> Layer names and path are often redundant. Allow users to omit the path
> key when it is equal to the layer name by using the layer name as a
> default value for its path.
>
> For example, from poky-master.conf.json:
>   "bitbake": {
>     ...
>     "path": "bitbake"
>   },
>   "openembedded-core": {
>     ...
>     "path": "openembedded-core"
>   },
>   "meta-yocto": {
>     ...
>     "path": "meta-yocto"
>   },
>   "yocto-docs": {
>     ...
>     "path": "yocto-docs"
>   }
>
> Remove redundant "path" keys from default-registry and tests.
>
> Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
> ---
> Note: Now that all "path" keys are removed (because they were all redundant),
> we need to ensure the "path" code path is tested by adding a test for
> it.
> ---
>  bin/bitbake-setup                                    |  2 +-
>  .../configurations/oe-nodistro.conf.json             |  9 +++------
>  .../configurations/poky-master.conf.json             | 12 ++++--------
>  lib/bb/tests/setup.py                                |  3 +--
>  4 files changed, 9 insertions(+), 17 deletions(-)
>
> diff --git a/bin/bitbake-setup b/bin/bitbake-setup
> index a0426005f..57375e450 100755
> --- a/bin/bitbake-setup
> +++ b/bin/bitbake-setup
> @@ -81,7 +81,7 @@ def checkout_layers(layers, layerdir, d):
>      print("Fetching layer/tool repositories into {}".format(layerdir))
>      for r_name in layers:
>          r_data = layers[r_name]
> -        repodir = r_data["path"]
> +        repodir = r_data.get("path", r_name)
>          repodirs.append(repodir)
>
>          r_remote = r_data['git-remote']
> diff --git a/default-registry/configurations/oe-nodistro.conf.json b/default-registry/configurations/oe-nodistro.conf.json
> index 7619738b1..9cd11a218 100644
> --- a/default-registry/configurations/oe-nodistro.conf.json
> +++ b/default-registry/configurations/oe-nodistro.conf.json
> @@ -10,8 +10,7 @@
>                  },
>                  "branch": "master",
>                  "rev": "master"
> -            },
> -            "path": "bitbake"
> +            }
>          },
>          "openembedded-core": {
>              "git-remote": {
> @@ -22,8 +21,7 @@
>                  },
>                  "branch": "master",
>                  "rev": "master"
> -            },
> -            "path": "openembedded-core"
> +            }
>          },
>          "yocto-docs": {
>              "git-remote": {
> @@ -34,8 +32,7 @@
>                  },
>                  "branch": "master",
>                  "rev": "master"
> -            },
> -            "path": "yocto-docs"
> +            }
>          }
>      },
>      "bitbake-setup": {
> diff --git a/default-registry/configurations/poky-master.conf.json b/default-registry/configurations/poky-master.conf.json
> index 60531ba02..9b63ea5f0 100644
> --- a/default-registry/configurations/poky-master.conf.json
> +++ b/default-registry/configurations/poky-master.conf.json
> @@ -10,8 +10,7 @@
>                  },
>                  "branch": "master",
>                  "rev": "master"
> -            },
> -            "path": "bitbake"
> +            }
>          },
>          "openembedded-core": {
>              "git-remote": {
> @@ -22,8 +21,7 @@
>                  },
>                  "branch": "master",
>                  "rev": "master"
> -            },
> -            "path": "openembedded-core"
> +            }
>          },
>          "meta-yocto": {
>              "git-remote": {
> @@ -34,8 +32,7 @@
>                  },
>                  "branch": "master",
>                  "rev": "master"
> -            },
> -            "path": "meta-yocto"
> +            }
>          },
>          "yocto-docs": {
>              "git-remote": {
> @@ -46,8 +43,7 @@
>                  },
>                  "branch": "master",
>                  "rev": "master"
> -            },
> -            "path": "yocto-docs"
> +            }
>          }
>      },
>      "bitbake-setup": {
> diff --git a/lib/bb/tests/setup.py b/lib/bb/tests/setup.py
> index e320cdf56..85fc24f88 100644
> --- a/lib/bb/tests/setup.py
> +++ b/lib/bb/tests/setup.py
> @@ -100,8 +100,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
>                  },
>                  "branch": "%s",
>                  "rev": "%s"
> -            },
> -            "path": "test-repo"
> +            }
>          }
>      },
>      "description": "Test configuration",
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#18245): https://lists.openembedded.org/g/bitbake-devel/message/18245
> Mute This Topic: https://lists.openembedded.org/mt/116107021/1686489
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Mathieu Dubois-Briand Nov. 4, 2025, 11:23 a.m. UTC | #2
On Mon Nov 3, 2025 at 10:48 PM CET, Yoann Congal via lists.openembedded.org wrote:
> From: Yoann Congal <yoann.congal@smile.fr>
>
> Layer names and path are often redundant. Allow users to omit the path
> key when it is equal to the layer name by using the layer name as a
> default value for its path.
>
> For example, from poky-master.conf.json:
>   "bitbake": {
>     ...
>     "path": "bitbake"
>   },
>   "openembedded-core": {
>     ...
>     "path": "openembedded-core"
>   },
>   "meta-yocto": {
>     ...
>     "path": "meta-yocto"
>   },
>   "yocto-docs": {
>     ...
>     "path": "yocto-docs"
>   }
>
> Remove redundant "path" keys from default-registry and tests.
>
> Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
> ---
> Note: Now that all "path" keys are removed (because they were all redundant),
> we need to ensure the "path" code path is tested by adding a test for
> it.
> ---

Hi Yoann,

Thanks for your patch.

It looks like this is breaking a selftest:

ERROR: test_setup (bb.tests.setup.BitbakeSetupTest.test_setup)
...
bb.process.ExecutionError: Execution of '/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup --global-settings /tmp/bitbake-fetch-l9mrbqbo/global-config status' failed with exit code 1:
Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup", line 860, in <module>
    main()
  File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup", line 854, in main
    args.func(top_dir, all_settings, args, d)
  File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup", line 541, in build_status
    if are_layers_changed(current_upstream_config["data"]["sources"], layerdir, d):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup", line 492, in are_layers_changed
    repodir = r_data["path"]
              ~~~~~~^^^^^^^^
KeyError: 'path'

https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/2787
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/2652
https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/2787

Can you have a look?

Thanks,
Mathieu
Yoann Congal Nov. 4, 2025, 1:28 p.m. UTC | #3
Le mar. 4 nov. 2025 à 12:23, Mathieu Dubois-Briand <
mathieu.dubois-briand@bootlin.com> a écrit :

> On Mon Nov 3, 2025 at 10:48 PM CET, Yoann Congal via
> lists.openembedded.org wrote:
> > From: Yoann Congal <yoann.congal@smile.fr>
> >
> > Layer names and path are often redundant. Allow users to omit the path
> > key when it is equal to the layer name by using the layer name as a
> > default value for its path.
> >
> > For example, from poky-master.conf.json:
> >   "bitbake": {
> >     ...
> >     "path": "bitbake"
> >   },
> >   "openembedded-core": {
> >     ...
> >     "path": "openembedded-core"
> >   },
> >   "meta-yocto": {
> >     ...
> >     "path": "meta-yocto"
> >   },
> >   "yocto-docs": {
> >     ...
> >     "path": "yocto-docs"
> >   }
> >
> > Remove redundant "path" keys from default-registry and tests.
> >
> > Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
> > ---
> > Note: Now that all "path" keys are removed (because they were all
> redundant),
> > we need to ensure the "path" code path is tested by adding a test for
> > it.
> > ---
>
> Hi Yoann,
>
> Thanks for your patch.
>
> It looks like this is breaking a selftest:
>
> ERROR: test_setup (bb.tests.setup.BitbakeSetupTest.test_setup)
> ...
> bb.process.ExecutionError: Execution of
> '/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup
> --global-settings /tmp/bitbake-fetch-l9mrbqbo/global-config status' failed
> with exit code 1:
> Traceback (most recent call last):
>   File
> "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup",
> line 860, in <module>
>     main()
>   File
> "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup",
> line 854, in main
>     args.func(top_dir, all_settings, args, d)
>   File
> "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup",
> line 541, in build_status
>     if are_layers_changed(current_upstream_config["data"]["sources"],
> layerdir, d):
>
>  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File
> "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup",
> line 492, in are_layers_changed
>     repodir = r_data["path"]
>               ~~~~~~^^^^^^^^
> KeyError: 'path'
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/2787
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/2652
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/2787
>
> Can you have a look?
>

Yup, definitely a bug I missed. Will send a v2 with a fix.


>
> Thanks,
> Mathieu
>
> --
> Mathieu Dubois-Briand, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
>
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index a0426005f..57375e450 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -81,7 +81,7 @@  def checkout_layers(layers, layerdir, d):
     print("Fetching layer/tool repositories into {}".format(layerdir))
     for r_name in layers:
         r_data = layers[r_name]
-        repodir = r_data["path"]
+        repodir = r_data.get("path", r_name)
         repodirs.append(repodir)
 
         r_remote = r_data['git-remote']
diff --git a/default-registry/configurations/oe-nodistro.conf.json b/default-registry/configurations/oe-nodistro.conf.json
index 7619738b1..9cd11a218 100644
--- a/default-registry/configurations/oe-nodistro.conf.json
+++ b/default-registry/configurations/oe-nodistro.conf.json
@@ -10,8 +10,7 @@ 
                 },
                 "branch": "master",
                 "rev": "master"
-            },
-            "path": "bitbake"
+            }
         },
         "openembedded-core": {
             "git-remote": {
@@ -22,8 +21,7 @@ 
                 },
                 "branch": "master",
                 "rev": "master"
-            },
-            "path": "openembedded-core"
+            }
         },
         "yocto-docs": {
             "git-remote": {
@@ -34,8 +32,7 @@ 
                 },
                 "branch": "master",
                 "rev": "master"
-            },
-            "path": "yocto-docs"
+            }
         }
     },
     "bitbake-setup": {
diff --git a/default-registry/configurations/poky-master.conf.json b/default-registry/configurations/poky-master.conf.json
index 60531ba02..9b63ea5f0 100644
--- a/default-registry/configurations/poky-master.conf.json
+++ b/default-registry/configurations/poky-master.conf.json
@@ -10,8 +10,7 @@ 
                 },
                 "branch": "master",
                 "rev": "master"
-            },
-            "path": "bitbake"
+            }
         },
         "openembedded-core": {
             "git-remote": {
@@ -22,8 +21,7 @@ 
                 },
                 "branch": "master",
                 "rev": "master"
-            },
-            "path": "openembedded-core"
+            }
         },
         "meta-yocto": {
             "git-remote": {
@@ -34,8 +32,7 @@ 
                 },
                 "branch": "master",
                 "rev": "master"
-            },
-            "path": "meta-yocto"
+            }
         },
         "yocto-docs": {
             "git-remote": {
@@ -46,8 +43,7 @@ 
                 },
                 "branch": "master",
                 "rev": "master"
-            },
-            "path": "yocto-docs"
+            }
         }
     },
     "bitbake-setup": {
diff --git a/lib/bb/tests/setup.py b/lib/bb/tests/setup.py
index e320cdf56..85fc24f88 100644
--- a/lib/bb/tests/setup.py
+++ b/lib/bb/tests/setup.py
@@ -100,8 +100,7 @@  print("BBPATH is {{}}".format(os.environ["BBPATH"]))
                 },
                 "branch": "%s",
                 "rev": "%s"
-            },
-            "path": "test-repo"
+            }
         }
     },
     "description": "Test configuration",