[yocto] [layerindex-web] [PATCH 2/3] update.py: Allow bitbake to live in a subdirectory of a repository

Mark Hatle mark.hatle at kernel.crashing.org
Sat Oct 12 18:56:32 PDT 2019


Add a new BITBAKE_PATH to the settings file to specify the path within the
BITBAKE_REPO_URL where bitbake lives.  This is useful when using a combined
repository, such as poky, that contains bitbake, openembedded-core and other
layers.

This change also changes the default path, in the fetch directory, for the
bitbake checkout.  It no longer uses the path 'bitbake', but instead uses the
same URL processing as the layer fetching.

There is a side effect that, when using a shared fetch, the branch of the
layer will be used instead of the specified bitbake branch.  Generally this
is a reasonable compromise, since in a combined repository bitbake and
openembedded-core component should already match.

Signed-off-by: Mark Hatle <mark.hatle at kernel.crashing.org>
---
 docker/settings.py           |  3 +++
 layerindex/bulkchange.py     |  8 +++++++-
 layerindex/layerconfparse.py |  8 +++++++-
 layerindex/update.py         | 14 +++++++++++---
 layerindex/update_layer.py   |  6 +++++-
 settings.py                  |  3 +++
 6 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/docker/settings.py b/docker/settings.py
index 616b67b..2821d82 100644
--- a/docker/settings.py
+++ b/docker/settings.py
@@ -244,6 +244,9 @@ TEMP_BASE_DIR = "/tmp"
 # Fetch URL of the BitBake repository for the update script
 BITBAKE_REPO_URL = "git://git.openembedded.org/bitbake"
 
+# Path within the BITBAKE_REPO_URL, usually empty
+BITBAKE_PATH = ""
+
 # Core layer to be used by the update script for basic BitBake configuration
 CORE_LAYER_NAME = "openembedded-core"
 
diff --git a/layerindex/bulkchange.py b/layerindex/bulkchange.py
index f6506ef..ea1f85c 100644
--- a/layerindex/bulkchange.py
+++ b/layerindex/bulkchange.py
@@ -98,7 +98,13 @@ def main():
 
     branch = utils.get_branch('master')
     fetchdir = settings.LAYER_FETCH_DIR
-    bitbakepath = os.path.join(fetchdir, 'bitbake')
+
+    import layerindex.models import LayerItem
+    bitbakeitem = LayerItem()
+    bitbakeitem.vcs_url = settings.BITBAKE_REPO_URL
+    bitbakepath = os.path.join(fetchdir, bitbakeitem.get_fetch_dir())
+    if settings.BITBAKE_PATH:
+        bitbakepath = os.path.join(bitbakepath, settings.BITBAKE_PATH)
 
     if not os.path.exists(bitbakepath):
         sys.stderr.write("Unable to find bitbake checkout at %s" % bitbakepath)
diff --git a/layerindex/layerconfparse.py b/layerindex/layerconfparse.py
index 526d2c2..a0b7e1c 100644
--- a/layerindex/layerconfparse.py
+++ b/layerindex/layerconfparse.py
@@ -20,7 +20,13 @@ class LayerConfParse:
 
         if not bitbakepath:
             fetchdir = settings.LAYER_FETCH_DIR
-            bitbakepath = os.path.join(fetchdir, 'bitbake')
+
+            from layerindex.models import LayerItem
+            bitbakeitem = LayerItem()
+            bitbakeitem.vcs_url = settings.BITBAKE_REPO_URL
+            bitbakepath = os.path.join(fetchdir, bitbakeitem.get_fetch_dir())
+            if settings.BITBAKE_PATH:
+                bitbakepath = os.path.join(bitbakepath, settings.BITBAKE_PATH)
         self.bbpath = bitbakepath
 
         # Set up BBPATH.
diff --git a/layerindex/update.py b/layerindex/update.py
index 7faf6b5..57dd830 100755
--- a/layerindex/update.py
+++ b/layerindex/update.py
@@ -268,8 +268,6 @@ def main():
             logger.error("Layer index lock timeout expired")
             sys.exit(1)
         try:
-            bitbakepath = os.path.join(fetchdir, 'bitbake')
-
             if not options.nofetch:
                 # Make sure oe-core is fetched since recipe parsing requires it
                 layerquery_core = LayerItem.objects.filter(comparison=False).filter(name=settings.CORE_LAYER_NAME)
@@ -285,7 +283,17 @@ def main():
                     if layer.vcs_url not in allrepos:
                         allrepos[layer.vcs_url] = (repodir, urldir, fetchdir, layer.name)
                 # Add bitbake
-                allrepos[settings.BITBAKE_REPO_URL] = (bitbakepath, "bitbake", fetchdir, "bitbake")
+                if settings.BITBAKE_REPO_URL not in allrepos:
+                    bitbakeitem = LayerItem()
+                    bitbakeitem.vcs_url = settings.BITBAKE_REPO_URL
+                    bitbakeurldir = bitbakeitem.get_fetch_dir()
+                    bitbakepath = os.path.join(fetchdir, bitbakeurldir)
+                    allrepos[settings.BITBAKE_REPO_URL] = (bitbakepath, bitbakeurldir, fetchdir, "bitbake")
+
+                (bitbakepath, _, _, _) = allrepos[settings.BITBAKE_REPO_URL]
+                if settings.BITBAKE_PATH:
+                    bitbakepath = os.path.join(bitbakepath, settings.BITBAKE_PATH)
+
                 # Parallel fetching
                 pool = multiprocessing.Pool(int(settings.PARALLEL_JOBS))
                 for url in allrepos:
diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py
index 7131d70..f4111bd 100644
--- a/layerindex/update_layer.py
+++ b/layerindex/update_layer.py
@@ -300,7 +300,11 @@ def main():
         logger.error("Please set LAYER_FETCH_DIR in settings.py")
         sys.exit(1)
 
-    bitbakepath = os.path.join(fetchdir, 'bitbake')
+    bitbakeitem = LayerItem()
+    bitbakeitem.vcs_url = settings.BITBAKE_REPO_URL
+    bitbakepath = os.path.join(fetchdir, bitbakeitem.get_fetch_dir())
+    if settings.BITBAKE_PATH:
+        bitbakepath = os.path.join(bitbakepath, settings.BITBAKE_PATH)
 
     layer = utils.get_layer(options.layer)
     urldir = layer.get_fetch_dir()
diff --git a/settings.py b/settings.py
index e0f5984..e9bf6cc 100644
--- a/settings.py
+++ b/settings.py
@@ -239,6 +239,9 @@ TEMP_BASE_DIR = "/tmp"
 # Fetch URL of the BitBake repository for the update script
 BITBAKE_REPO_URL = "git://git.openembedded.org/bitbake"
 
+# Path within the BITBAKE_REPO_URL, usually empty
+BITBAKE_PATH = ""
+
 # Core layer to be used by the update script for basic BitBake configuration
 CORE_LAYER_NAME = "openembedded-core"
 
-- 
2.17.1



More information about the yocto mailing list