All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix bitbake-layerindex to checkout the requested branch
@ 2020-02-14 15:01 dl9pf
  2020-02-14 15:32 ` Peter Kjellerstedt
  2020-02-14 18:08 ` Mark Hatle
  0 siblings, 2 replies; 6+ messages in thread
From: dl9pf @ 2020-02-14 15:01 UTC (permalink / raw)
  To: bitbake-devel

From: Jan-Simon Moeller <jsmoeller@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.
V3: After discussion on IRC use branches[-1] as well
    educated guess for now but leave the FIXME in place.

Signed-off-by: Jan-Simon Moeller <jsmoeller@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..096ea4f8 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
@@ -73,6 +73,10 @@ class LayerIndexPlugin(ActionPlugin):
             branches = [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 we pull the last entry
+        checkoutbranch = branches[-1]
         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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix bitbake-layerindex to checkout the requested branch
  2020-02-14 15:01 [PATCH] Fix bitbake-layerindex to checkout the requested branch dl9pf
@ 2020-02-14 15:32 ` Peter Kjellerstedt
  2020-02-14 18:08 ` Mark Hatle
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Kjellerstedt @ 2020-02-14 15:32 UTC (permalink / raw)
  To: dl9pf, bitbake-devel

> -----Original Message-----
> From: bitbake-devel-bounces@lists.openembedded.org <bitbake-devel-
> bounces@lists.openembedded.org> On Behalf Of dl9pf@gmx.de
> Sent: den 14 februari 2020 16:01
> To: bitbake-devel@lists.openembedded.org
> Subject: [bitbake-devel] [PATCH] Fix bitbake-layerindex to checkout the
> requested branch
> 
> From: Jan-Simon Moeller <jsmoeller@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.
> V3: After discussion on IRC use branches[-1] as well
>     educated guess for now but leave the FIXME in place.

Information about the various patch revisions should go below the "---" 
below as they relate to the patch process and not the commit that 
eventually ends up in the Git repository.

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

//Peter



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix bitbake-layerindex to checkout the requested branch
  2020-02-14 15:01 [PATCH] Fix bitbake-layerindex to checkout the requested branch dl9pf
  2020-02-14 15:32 ` Peter Kjellerstedt
@ 2020-02-14 18:08 ` Mark Hatle
  2020-02-14 21:07   ` "Jan-Simon Möller"
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Hatle @ 2020-02-14 18:08 UTC (permalink / raw)
  To: bitbake-devel

This issue was already found (and I thought fixed?)  Maybe the submission hadn't
been accepted.  See:

http://lists.openembedded.org/pipermail/bitbake-devel/2019-December/020645.html

Also comments below inline:

On 2/14/20 9:01 AM, dl9pf@gmx.de wrote:
> From: Jan-Simon Moeller <jsmoeller@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.
> V3: After discussion on IRC use branches[-1] as well
>     educated guess for now but leave the FIXME in place.
> 
> Signed-off-by: Jan-Simon Moeller <jsmoeller@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..096ea4f8 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)

There are cases where it might be called if the branch is blank.  So the repo
URL should be called instead.  Thus -b should not be forced to always be there.
 (odd use-case, but it does exist.)

>                      return None, None, None
> @@ -73,6 +73,10 @@ class LayerIndexPlugin(ActionPlugin):
>              branches = [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 we pull the last entry
> +        checkoutbranch = branches[-1]

The branch here is the name of the branch(es) to query the layerindex for.  They
are in order of priority, so the first found would be the one that is to be used.

>          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)

This is incorrect, it must use the branch value from the
layerBranch.actual_branch.  Since the branch in the repository and the branch
(corename) being questioned can and are often different.

--Mark

>                  if not name:
>                      # Error already shown
>                      return 1
> --
> 2.11.0
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix bitbake-layerindex to checkout the requested branch
  2020-02-14 18:08 ` Mark Hatle
@ 2020-02-14 21:07   ` "Jan-Simon Möller"
  0 siblings, 0 replies; 6+ messages in thread
From: "Jan-Simon Möller" @ 2020-02-14 21:07 UTC (permalink / raw)
  To: Mark Hatle; +Cc: bitbake-devel

Hi Mark!

Thanks for reviewing. I had hoped to find the right variables. A pity it did not land earlier.
Can we backport this to zeus, please ?
 
 
> This issue was already found (and I thought fixed?) Maybe the submission hadn't
> been accepted. See:
> 
> http://lists.openembedded.org/pipermail/bitbake-devel/2019-December/020645.html


Please ignore my patchset then.

Best,
JS


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Fix bitbake-layerindex to checkout the requested branch
@ 2020-02-14 14:47 dl9pf
  0 siblings, 0 replies; 6+ messages in thread
From: dl9pf @ 2020-02-14 14:47 UTC (permalink / raw)
  To: bitbake-devel

From: Jan-Simon Moeller <jsmoeller@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@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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] Fix bitbake-layerindex to checkout the requested branch
@ 2020-02-14 14:22 dl9pf
  0 siblings, 0 replies; 6+ messages in thread
From: dl9pf @ 2020-02-14 14:22 UTC (permalink / raw)
  To: bitbake-devel

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

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

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

diff --git a/lib/bblayers/layerindex.py b/lib/bblayers/layerindex.py
index 57cd9027..093434ac 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
@@ -70,9 +70,9 @@ class LayerIndexPlugin(ActionPlugin):

         # Set the default...
         if args.branch:
-            branches = [args.branch]
+            branch = [args.branch]
         else:
-            branches = (self.tinfoil.config_data.getVar('LAYERSERIES_CORENAMES') or 'master').split()
+            branch = (self.tinfoil.config_data.getVar('LAYERSERIES_CORENAMES') or 'master').split()
         logger.debug(1, 'Trying branches: %s' % branches)

         ignore_layers = []
@@ -171,7 +171,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, branch)
                 if not name:
                     # Error already shown
                     return 1
--
2.11.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-02-14 21:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14 15:01 [PATCH] Fix bitbake-layerindex to checkout the requested branch dl9pf
2020-02-14 15:32 ` Peter Kjellerstedt
2020-02-14 18:08 ` Mark Hatle
2020-02-14 21:07   ` "Jan-Simon Möller"
  -- strict thread matches above, loose matches on Subject: below --
2020-02-14 14:47 dl9pf
2020-02-14 14:22 dl9pf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.