[bitbake-devel] [PATCH] Fix bitbake-layerindex to checkout the requested branch

dl9pf at gmx.de dl9pf at gmx.de
Fri Feb 14 14:47:42 UTC 2020


From: Jan-Simon Moeller <jsmoeller at linuxfoundation.org>

Bitbake-layerindex would not respect the branch given with -b .
This fixes the clone command.

V2: Corrected 'branch' back to 'branches' and added
    a FIXME on multiple LAYERSERIES_CORENAMES.

Signed-off-by: Jan-Simon Moeller <jsmoeller at linuxfoundation.org>
---
 lib/bblayers/layerindex.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/bblayers/layerindex.py b/lib/bblayers/layerindex.py
index 57cd9027..32454c8a 100644
--- a/lib/bblayers/layerindex.py
+++ b/lib/bblayers/layerindex.py
@@ -24,7 +24,7 @@ class LayerIndexPlugin(ActionPlugin):
     This class inherits ActionPlugin to get do_add_layer.
     """

-    def get_fetch_layer(self, fetchdir, url, subdir, fetch_layer):
+    def get_fetch_layer(self, fetchdir, url, subdir, fetch_layer, branch):
         layername = self.get_layer_name(url)
         if os.path.splitext(layername)[1] == '.git':
             layername = os.path.splitext(layername)[0]
@@ -32,7 +32,7 @@ class LayerIndexPlugin(ActionPlugin):
         layerdir = os.path.join(repodir, subdir)
         if not os.path.exists(repodir):
             if fetch_layer:
-                result = subprocess.call(['git', 'clone', url, repodir])
+                result = subprocess.call(['git', 'clone', '-b', branch, url, repodir])
                 if result:
                     logger.error("Failed to download %s" % url)
                     return None, None, None
@@ -71,8 +71,12 @@ class LayerIndexPlugin(ActionPlugin):
         # Set the default...
         if args.branch:
             branches = [args.branch]
+            checkoutbranch = args.branch
         else:
             branches = (self.tinfoil.config_data.getVar('LAYERSERIES_CORENAMES') or 'master').split()
+            # FIXME: multple branches is not deterministic when cloning the repository
+            # for now pull master ...
+            checkoutbranch = 'master'
         logger.debug(1, 'Trying branches: %s' % branches)

         ignore_layers = []
@@ -171,7 +175,7 @@ class LayerIndexPlugin(ActionPlugin):
                 subdir, name, layerdir = self.get_fetch_layer(fetchdir,
                                                       layerBranch.layer.vcs_url,
                                                       layerBranch.vcs_subdir,
-                                                      not args.show_only)
+                                                      not args.show_only, checkoutbranch)
                 if not name:
                     # Error already shown
                     return 1
--
2.11.0



More information about the bitbake-devel mailing list