Skip to contentSkip to conversation

bitbake: layerindex: use branch when specified

PATCH In review Jon Mason 2 participants 4 messages Dec 18, 2019 – Dec 19, 2019

lore
Share & tools
lore

Jon Mason

author
#0 lore raw

PATCH 1/1 bitbake: layerindex: use branch when specified

When currently specified, the branch is used to verify the versioning of the meta layer, but the master branch is checked out. This change allows for the branch to be specified. Now it is easy to specify all of the meta layers being added are of the same version, without having to do it in each individual git tree. Also, it will error if there are branches without a matching version. Finally, this allows for meta layer git trees without a master branch.

---
 bitbake/lib/bblayers/layerindex.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
bitbake/lib/bblayers/layerindex.py +6 -3
index 57cd9027f6..55029e0482 100644
@@ -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,9 @@ 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])
+                if not branch:
+                    branch = "master"
+                result = subprocess.call(['git', 'clone', '-b' , branch, url, repodir])
                 if result:
                     logger.error("Failed to download %s" % url)
                     return None, None, None
@@ -171,7 +173,8 @@ 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,
+                                                      args.branch)
                 if not name:
                     # Error already shown
                     return 1
Signature · 1 line
2.20.1
#1 lore raw

I just found this same issue and was working on a fix. What you have below is almsot correct, however the value of the branch is NOT args.branch.

args.branch specifies the branch of the layerindex, but the layerindex internally knows the name of the branch corresponding the release branch.

You actually need to get the 'actual_branch' value from the layerBranch item.

See below:

Quoted 38 lines · Jon Mason

When currently specified, the branch is used to verify the versioning of the meta layer, but the master branch is checked out. This change allows for the branch to be specified. Now it is easy to specify all of the meta layers being added are of the same version, without having to do it in each individual git tree. Also, it will error if there are branches without a matching version. Finally, this allows for meta layer git trees without a master branch.

---
 bitbake/lib/bblayers/layerindex.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
bitbake/lib/bblayers/layerindex.py +4 -2
index 57cd9027f6..55029e0482 100644
@@ -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,9 @@ 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])
+                if not branch:
+                    branch = "master"
+                result = subprocess.call(['git', 'clone', '-b' , branch, url, repodir])
                 if result:
                     logger.error("Failed to download %s" % url)
                     return None, None, None

bitbake/lib/bblayers/layerindex.py class LayerIndexPlugin(ActionPlugin): · line 177

Quoted 6 lines
bitbake/lib/bblayers/layerindex.py +2 -1
@@ -171,7 +173,8 @@ 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,
+                                                      args.branch)

The above should be 'layerBranch.actual_branch', instead of args.branch.

For example, in master -- "meta-gumstix" in master is set to the branch 'dora'.

--Mark

Quoted 4 lines
bitbake/lib/bblayers/layerindex.py +0 -0
                 if not name:
                     # Error already shown
                     return 1
#2 lore raw

I just realized I wasn't clear with my reply yesterday. I will start with Jon's patch, and make the change and test it and then send up a V2. (Since I was already working on that code.)

--Mark

Quoted 66 lines · Mark Hatle

I just found this same issue and was working on a fix. What you have below is almsot correct, however the value of the branch is NOT args.branch.

args.branch specifies the branch of the layerindex, but the layerindex internally knows the name of the branch corresponding the release branch.

You actually need to get the 'actual_branch' value from the layerBranch item.

See below:

Quoted 38 lines · Jon Mason

When currently specified, the branch is used to verify the versioning of the meta layer, but the master branch is checked out. This change allows for the branch to be specified. Now it is easy to specify all of the meta layers being added are of the same version, without having to do it in each individual git tree. Also, it will error if there are branches without a matching version. Finally, this allows for meta layer git trees without a master branch.

---
 bitbake/lib/bblayers/layerindex.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
bitbake/lib/bblayers/layerindex.py +4 -2
index 57cd9027f6..55029e0482 100644
@@ -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,9 @@ 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])
+                if not branch:
+                    branch = "master"
+                result = subprocess.call(['git', 'clone', '-b' , branch, url, repodir])
                 if result:
                     logger.error("Failed to download %s" % url)
                     return None, None, None

bitbake/lib/bblayers/layerindex.py class LayerIndexPlugin(ActionPlugin): · line 177

Quoted 6 lines
bitbake/lib/bblayers/layerindex.py +2 -1
@@ -171,7 +173,8 @@ 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,
+                                                      args.branch)

The above should be 'layerBranch.actual_branch', instead of args.branch.

For example, in master -- "meta-gumstix" in master is set to the branch 'dora'.

--Mark

Quoted 4 lines
bitbake/lib/bblayers/layerindex.py +0 -0
                 if not name:
                     # Error already shown
                     return 1
author
#3 lore raw
Quoted 4 lines · Mark Hatle

I just realized I wasn't clear with my reply yesterday. I will start with Jon's patch, and make the change and test it and then send up a V2. (Since I was already working on that code.)

Oh, I was literally about to send out v2 with your fixup (sanity testing it now). I'll nix that now.

Thanks,
Jon

Quoted 75 lines

--Mark

Quoted 58 lines · Mark Hatle

I just found this same issue and was working on a fix. What you have below is almsot correct, however the value of the branch is NOT args.branch.

args.branch specifies the branch of the layerindex, but the layerindex internally knows the name of the branch corresponding the release branch.

You actually need to get the 'actual_branch' value from the layerBranch item.

See below:

Quoted 38 lines · Jon Mason

When currently specified, the branch is used to verify the versioning of the meta layer, but the master branch is checked out. This change allows for the branch to be specified. Now it is easy to specify all of the meta layers being added are of the same version, without having to do it in each individual git tree. Also, it will error if there are branches without a matching version. Finally, this allows for meta layer git trees without a master branch.

---
 bitbake/lib/bblayers/layerindex.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
bitbake/lib/bblayers/layerindex.py +4 -2
index 57cd9027f6..55029e0482 100644
@@ -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,9 @@ 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])
+                if not branch:
+                    branch = "master"
+                result = subprocess.call(['git', 'clone', '-b' , branch, url, repodir])
                 if result:
                     logger.error("Failed to download %s" % url)
                     return None, None, None

bitbake/lib/bblayers/layerindex.py class LayerIndexPlugin(ActionPlugin): · line 177

Quoted 6 lines
bitbake/lib/bblayers/layerindex.py +2 -1
@@ -171,7 +173,8 @@ 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,
+                                                      args.branch)

The above should be 'layerBranch.actual_branch', instead of args.branch.

Quoted 8 lines

For example, in master -- "meta-gumstix" in master is set to the branch 'dora'.

--Mark

Quoted 4 lines
bitbake/lib/bblayers/layerindex.py +0 -0
                 if not name:
                     # Error already shown
                     return 1

--
_______________________________________________
bitbake-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/bitbake-devel