diff mbox series

bitbake-setup: use internal registry if run from git checkout, bitbake repo otherwise

Message ID 20260114080414.2927046-1-alex.kanavin@gmail.com
State New
Headers show
Series bitbake-setup: use internal registry if run from git checkout, bitbake repo otherwise | expand

Commit Message

Alexander Kanavin Jan. 14, 2026, 8:04 a.m. UTC
From: Alexander Kanavin <alex@linutronix.de>

If bitbake-setup is packaged and obtained from pypi, or another package feed
it needs to be able to find standard configurations. It is not impossible
to package configurations into some location inside the package
and add logic to find them, but it is much easier to just fetch the bitbake
repo and use that as a configuration registry. The other benefit is that
such packaged/installed bitbake-setup will not have to be updated in order
to obtain latest configurations: it will simply check the registry and fetch
them as needed, which is the original intent of config registries as repos.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 bin/bitbake-setup | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Richard Purdie Jan. 14, 2026, 10:26 a.m. UTC | #1
On Wed, 2026-01-14 at 09:04 +0100, Alexander Kanavin via lists.openembedded.org wrote:
> From: Alexander Kanavin <alex@linutronix.de>
> 
> If bitbake-setup is packaged and obtained from pypi, or another package feed
> it needs to be able to find standard configurations. It is not impossible
> to package configurations into some location inside the package
> and add logic to find them, but it is much easier to just fetch the bitbake
> repo and use that as a configuration registry. The other benefit is that
> such packaged/installed bitbake-setup will not have to be updated in order
> to obtain latest configurations: it will simply check the registry and fetch
> them as needed, which is the original intent of config registries as repos.
> 
> Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> ---
>  bin/bitbake-setup | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/bin/bitbake-setup b/bin/bitbake-setup
> index 2c2b6d8ec..dc0c4b1c4 100755
> --- a/bin/bitbake-setup
> +++ b/bin/bitbake-setup
> @@ -21,8 +21,6 @@ import signal
>  import functools
>  import string
>  
> -default_registry = os.path.normpath(os.path.dirname(__file__) + "/../default-registry")
> -
>  bindir = os.path.abspath(os.path.dirname(__file__))
>  sys.path[0:0] = [os.path.join(os.path.dirname(bindir), 'lib')]
>  
> @@ -37,6 +35,14 @@ GLOBAL_ONLY_SETTINGS = (
>      "top-dir-name",
>  )
>  
> +def get_default_registry():
> +    internal_registry = os.path.normpath(os.path.dirname(__file__) + "/../default-registry")
> +    git_registry = "git://git.openembedded.org/bitbake;protocol=https;branch=master;rev=master"
> +    if os.path.exists(os.path.dirname(__file__) + "/../.git"):
> +        return internal_registry
> +    else:
> +        return git_registry
> +

Probably a silly question but why not just check if the default
registry exists and if not, fall back to the git url?

i.e. why isn't this just if os.path.exists(internal_registry) ?


Cheers,

Richard
Alexander Kanavin Jan. 14, 2026, 10:46 a.m. UTC | #2
On Wed, 14 Jan 2026 at 11:26, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:

> > +def get_default_registry():
> > +    internal_registry = os.path.normpath(os.path.dirname(__file__) + "/../default-registry")
> > +    git_registry = "git://git.openembedded.org/bitbake;protocol=https;branch=master;rev=master"
> > +    if os.path.exists(os.path.dirname(__file__) + "/../.git"):
> > +        return internal_registry
> > +    else:
> > +        return git_registry
> > +
>
> Probably a silly question but why not just check if the default
> registry exists and if not, fall back to the git url?
>
> i.e. why isn't this just if os.path.exists(internal_registry) ?

The idea is to ensure that internal registry is used only from a
bitbake git checkout. If someone makes a tarball, or otherwise
installs bitbake-setup in a way that replicates the tree structure
including the configs, then bitbake-setup should ignore any such
possible in-tree configurations and get/update them from git.

Alex
Richard Purdie Jan. 14, 2026, 11:14 a.m. UTC | #3
On Wed, 2026-01-14 at 11:46 +0100, Alexander Kanavin wrote:
> On Wed, 14 Jan 2026 at 11:26, Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> 
> > > +def get_default_registry():
> > > +    internal_registry =
> > > os.path.normpath(os.path.dirname(__file__) + "/../default-
> > > registry")
> > > +    git_registry =
> > > "git://git.openembedded.org/bitbake;protocol=https;branch=master;
> > > rev=master"
> > > +    if os.path.exists(os.path.dirname(__file__) + "/../.git"):
> > > +        return internal_registry
> > > +    else:
> > > +        return git_registry
> > > +
> > 
> > Probably a silly question but why not just check if the default
> > registry exists and if not, fall back to the git url?
> > 
> > i.e. why isn't this just if os.path.exists(internal_registry) ?
> 
> The idea is to ensure that internal registry is used only from a
> bitbake git checkout. If someone makes a tarball, or otherwise
> installs bitbake-setup in a way that replicates the tree structure
> including the configs, then bitbake-setup should ignore any such
> possible in-tree configurations and get/update them from git.

It might be worth a comment about the design intent here, something
like:

# If bitbake is from a release tarball or somewhere like pypi where
# updates may not be straightforward, prefer to use the git repo as the
# default registry

?

Cheers,

Richard
Alexander Kanavin Jan. 14, 2026, 11:36 a.m. UTC | #4
On Wed, 14 Jan 2026 at 12:14, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> It might be worth a comment about the design intent here, something
> like:
>
> # If bitbake is from a release tarball or somewhere like pypi where
> # updates may not be straightforward, prefer to use the git repo as the
> # default registry
>
> ?

Yep, I sent a v2.

Alex
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index 2c2b6d8ec..dc0c4b1c4 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -21,8 +21,6 @@  import signal
 import functools
 import string
 
-default_registry = os.path.normpath(os.path.dirname(__file__) + "/../default-registry")
-
 bindir = os.path.abspath(os.path.dirname(__file__))
 sys.path[0:0] = [os.path.join(os.path.dirname(bindir), 'lib')]
 
@@ -37,6 +35,14 @@  GLOBAL_ONLY_SETTINGS = (
     "top-dir-name",
 )
 
+def get_default_registry():
+    internal_registry = os.path.normpath(os.path.dirname(__file__) + "/../default-registry")
+    git_registry = "git://git.openembedded.org/bitbake;protocol=https;branch=master;rev=master"
+    if os.path.exists(os.path.dirname(__file__) + "/../.git"):
+        return internal_registry
+    else:
+        return git_registry
+
 def cache_dir(top_dir):
     return os.path.join(top_dir, '.bitbake-setup-cache')
 
@@ -1084,7 +1090,7 @@  def main():
         builtin_settings['default'] = {
                          'top-dir-prefix':os.getcwd(),
                          'top-dir-name':'bitbake-builds',
-                         'registry':default_registry,
+                         'registry':get_default_registry(),
                          'use-full-setup-dir-name':'no',
                          'common-sstate':'yes',
                          }