All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] fetch2/gitsm.py: Change the URI construction logic
@ 2019-01-08  7:47 Krystian Garliński
  2019-01-08 16:35 ` Linus Ziegert
  0 siblings, 1 reply; 5+ messages in thread
From: Krystian Garliński @ 2019-01-08  7:47 UTC (permalink / raw)
  To: bitbake-devel

Git allows to use both the proper URI's and SCP-like short style syntax
for the SSH protocol. This commit changes construction logic to detect which
one of the two is used in the submodule specification and to build a correct
URI out of it.

Signed-off-by: Krystian Garliński <krystian.garlinski@comarch.pl>
---
 lib/bb/fetch2/gitsm.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/bb/fetch2/gitsm.py b/lib/bb/fetch2/gitsm.py
index 35729dbc..95d5f652 100644
--- a/lib/bb/fetch2/gitsm.py
+++ b/lib/bb/fetch2/gitsm.py
@@ -32,6 +32,7 @@ NOTE: Switching a SRC_URI from "git://" to "gitsm://" requires a clean of your r
 import os
 import bb
 import copy
+import re
 from   bb.fetch2.git import Git
 from   bb.fetch2 import runfetchcmd
 from   bb.fetch2 import logger
@@ -39,6 +40,8 @@ from   bb.fetch2 import Fetch
 from   bb.fetch2 import BBFetchException
 
 class GitSM(Git):
+    scp_regex = re.compile(r'^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.+)$')
+
     def supports(self, ud, d):
         """
         Check to see if a given url can be fetched with git.
@@ -88,8 +91,17 @@ class GitSM(Git):
             module_hash = module_hash.split()[2]
 
             # Build new SRC_URI
-            proto = uris[module].split(':', 1)[0]
-            url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
+            uri = uris[module]
+            match = GitSM.scp_regex.match(uri)
+
+            if match:
+                # this URI follows the short SCP-like syntax
+                url = 'gitsm://{}@{}/{}'.format(match.group(1), match.group(2), match.group(3))
+                proto = 'ssh'
+            else:
+                proto = uri.split(':', 1)[0]
+                url = 'gitsm' + uri[len(proto):]
+
             url += ';protocol=%s' % proto
             url += ";name=%s" % module
             url += ";bareclone=1;nocheckout=1;nobranch=1"
-- 
2.19.1



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

* Re: [PATCH v2] fetch2/gitsm.py: Change the URI construction logic
  2019-01-08  7:47 [PATCH v2] fetch2/gitsm.py: Change the URI construction logic Krystian Garliński
@ 2019-01-08 16:35 ` Linus Ziegert
  2019-01-08 19:05   ` Mark Hatle
  2019-01-08 21:19   ` Mark Hatle
  0 siblings, 2 replies; 5+ messages in thread
From: Linus Ziegert @ 2019-01-08 16:35 UTC (permalink / raw)
  To: Krystian Garliński; +Cc: bitbake-devel


[-- Attachment #1.1: Type: text/plain, Size: 3151 bytes --]

Hello people,

I am working as well on fetch2/gitsm.py. We have a privat repo with
submodules but the current gitsm.py does not support ssh.

I tested the patch by Krystian but it did not worked for me. I got the
following ERROR:

ERROR: <recipe> do_fetch: The URL: 'gitsm:git@github.com/<user>/<submodule
_name1>.git;protocol=ssh;name=<submodule_name2>;bareclone=1;nocheckout=1;
nobranch=1' is invalid and cannot be interpreted


The .gitmodules file used looks like this:

[submodule "submodule_name1"]
path = submodule_name1
        url = git@github.com/<user>/<submodule_name1>.git
[submodule "submodule_name2"]
path = submodule_name2
        url = git@github.com/<user>/<submodule_name2>.git

Attached you find my proposal.


Am Di., 8. Jan. 2019 um 08:48 Uhr schrieb Krystian Garliński <krystian.
garlinski@comarch.pl>:

> Git allows to use both the proper URI's and SCP-like short style syntax
> for the SSH protocol. This commit changes construction logic to detect
> which
> one of the two is used in the submodule specification and to build a
> correct
> URI out of it.
>
> Signed-off-by: Krystian Garliński <krystian.garlinski@comarch.pl>
> ---
>  lib/bb/fetch2/gitsm.py | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/lib/bb/fetch2/gitsm.py b/lib/bb/fetch2/gitsm.py
> index 35729dbc..95d5f652 100644
> --- a/lib/bb/fetch2/gitsm.py
> +++ b/lib/bb/fetch2/gitsm.py
> @@ -32,6 +32,7 @@ NOTE: Switching a SRC_URI from "git://" to "gitsm://"
> requires a clean of your r
>  import os
>  import bb
>  import copy
> +import re
>  from   bb.fetch2.git import Git
>  from   bb.fetch2 import runfetchcmd
>  from   bb.fetch2 import logger
> @@ -39,6 +40,8 @@ from   bb.fetch2 import Fetch
>  from   bb.fetch2 import BBFetchException
>
>  class GitSM(Git):
> +    scp_regex = re.compile(r'^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.+)$')
> +
>      def supports(self, ud, d):
>          """
>          Check to see if a given url can be fetched with git.
> @@ -88,8 +91,17 @@ class GitSM(Git):
>              module_hash = module_hash.split()[2]
>
>              # Build new SRC_URI
> -            proto = uris[module].split(':', 1)[0]
> -            url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
> +            uri = uris[module]
> +            match = GitSM.scp_regex.match(uri)
> +
> +            if match:
> +                # this URI follows the short SCP-like syntax
> +                url = 'gitsm://{}@{}/{}'.format(match.group(1),
> match.group(2), match.group(3))
> +                proto = 'ssh'
> +            else:
> +                proto = uri.split(':', 1)[0]
> +                url = 'gitsm' + uri[len(proto):]
> +
>              url += ';protocol=%s' % proto
>              url += ";name=%s" % module
>              url += ";bareclone=1;nocheckout=1;nobranch=1"
> --
> 2.19.1
>
> --
> _______________________________________________
> bitbake-devel mailing list
> bitbake-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/bitbake-devel
>


-- 

Cheers,
Linus

[-- Attachment #1.2: Type: text/html, Size: 6711 bytes --]

[-- Attachment #2: 0001-fetch2-gitsm.py-Enable-SSH-protocol-option.patch --]
[-- Type: text/x-patch, Size: 2134 bytes --]

From d742c2956633007aec5894fa78a8a8060692592f Mon Sep 17 00:00:00 2001
From: Linus Ziegert <linus.ziegert@holoplot.com>
Date: Tue, 8 Jan 2019 16:30:22 +0100
Subject: [PATCH] fetch2/gitsm.py: Enable SSH protocol option

While fetching from a private git repo with submodules I encountered following error:

      ERROR: <recipe> do_fetch: The URL: 'git@github.com/<user>/<submodule_name1>.git;
      protocol=git@github.com/<user>/<submodule_name1>.git;name=<submodule_name2>;
      bareclone=1;nocheckout=1;nobranch=1' is invalid and cannot be interpreted

The reason is that gitsm.py cannot handle the syntax of git submodules which use
SSH as protocol type. After a colon in the URI of a submodule is found the string
before the colon is assigned as protocol type.

So the different syntax of git URI's for SSH connections has to be considered.

To fix this we split the URI at a colon. All protocol types that are supported by
fetch2/git.py and use URI's use a colon except SSH. In the case there is a colon
we can use the suffix as protocol type otherwise we assign SSH as protocol.

Signed-off-by: Linus Ziegert <linus.ziegert@holoplot.com>
---
 lib/bb/fetch2/gitsm.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/bb/fetch2/gitsm.py b/lib/bb/fetch2/gitsm.py
index 35729dbc..4d9f603d 100644
--- a/lib/bb/fetch2/gitsm.py
+++ b/lib/bb/fetch2/gitsm.py
@@ -88,7 +88,17 @@ class GitSM(Git):
             module_hash = module_hash.split()[2]
 
             # Build new SRC_URI
-            proto = uris[module].split(':', 1)[0]
+            uri_parts = uris[module].split(':', 1)
+            if len(uri_parts) > 1:
+                proto = uri_parts[0]
+            else:
+            # If there is no colon in uri we get the protocol from the module
+                proto = ud.proto
+
+             url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
+            if "://" not in url:
+                url = "git://%s" % url
+
             url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
             url += ';protocol=%s' % proto
             url += ";name=%s" % module
-- 
2.17.1


[-- Attachment #3: 0001-fetch2-gitsm.py-Enable-SSH-protocol-option.patch --]
[-- Type: text/x-patch, Size: 2134 bytes --]

From d742c2956633007aec5894fa78a8a8060692592f Mon Sep 17 00:00:00 2001
From: Linus Ziegert <linus.ziegert@holoplot.com>
Date: Tue, 8 Jan 2019 16:30:22 +0100
Subject: [PATCH] fetch2/gitsm.py: Enable SSH protocol option

While fetching from a private git repo with submodules I encountered following error:

      ERROR: <recipe> do_fetch: The URL: 'git@github.com/<user>/<submodule_name1>.git;
      protocol=git@github.com/<user>/<submodule_name1>.git;name=<submodule_name2>;
      bareclone=1;nocheckout=1;nobranch=1' is invalid and cannot be interpreted

The reason is that gitsm.py cannot handle the syntax of git submodules which use
SSH as protocol type. After a colon in the URI of a submodule is found the string
before the colon is assigned as protocol type.

So the different syntax of git URI's for SSH connections has to be considered.

To fix this we split the URI at a colon. All protocol types that are supported by
fetch2/git.py and use URI's use a colon except SSH. In the case there is a colon
we can use the suffix as protocol type otherwise we assign SSH as protocol.

Signed-off-by: Linus Ziegert <linus.ziegert@holoplot.com>
---
 lib/bb/fetch2/gitsm.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/bb/fetch2/gitsm.py b/lib/bb/fetch2/gitsm.py
index 35729dbc..4d9f603d 100644
--- a/lib/bb/fetch2/gitsm.py
+++ b/lib/bb/fetch2/gitsm.py
@@ -88,7 +88,17 @@ class GitSM(Git):
             module_hash = module_hash.split()[2]
 
             # Build new SRC_URI
-            proto = uris[module].split(':', 1)[0]
+            uri_parts = uris[module].split(':', 1)
+            if len(uri_parts) > 1:
+                proto = uri_parts[0]
+            else:
+            # If there is no colon in uri we get the protocol from the module
+                proto = ud.proto
+
+             url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
+            if "://" not in url:
+                url = "git://%s" % url
+
             url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
             url += ';protocol=%s' % proto
             url += ";name=%s" % module
-- 
2.17.1


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

* Re: [PATCH v2] fetch2/gitsm.py: Change the URI construction logic
  2019-01-08 16:35 ` Linus Ziegert
@ 2019-01-08 19:05   ` Mark Hatle
  2019-01-08 21:19   ` Mark Hatle
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Hatle @ 2019-01-08 19:05 UTC (permalink / raw)
  To: bitbake-devel

The patch here and the other that didn't quite work either are close but not
completely correct.

There are apparently three (ssh) formats that git supports:

url format - ssh://user:password@host/path
ssh format - user@host:/path
(ssh)? format - user@host/path

Each have a different regex or splitting format required.  I'm working on a
specific reproducer test case for each of these, and then will work to combine
or tailor the various patches that have been submitted.  If anyone is aware of
any other odd formats please let me know and I'll add appropriate test cases for
those as well.

I'm guessing it'll be a couple of days for me to work through this, and then I
ask that people with the problem test this and verify it works in their specific
case.

--Mark

On 1/8/19 10:35 AM, Linus Ziegert wrote:
> Hello people,
> 
> I am working as well on fetch2/gitsm.py. We have a privat repo with submodules
> but the current gitsm.py does not support ssh.
> 
> I tested the patch by Krystian but it did not worked for me. I got the following
> ERROR:
> 
>     ERROR: <recipe> do_fetch: The URL:
>     'gitsm:git@github.com/<user>/<submodule_name1>.git;protocol=ssh;name=<submodule_name2>;bareclone=1;nocheckout=1;nobranch=1'
>     is invalid and cannot be interpreted
> 
> 
> The .gitmodules file used looks like this:
> 
> [submodule "submodule_name1"]
> path = submodule_name1
>         url = git@github.com/<user>/<submodule_name1>.git 
> [submodule "submodule_name2"]
> path = submodule_name2
>         url = git@github.com/<user>/<submodule_name2>.git 
> 
> Attached you find my proposal.
> 
> 
> Am Di., 8. Jan. 2019 um 08:48 Uhr schrieb Krystian Garliński
> <krystian.garlinski@comarch.pl>:
> 
>     Git allows to use both the proper URI's and SCP-like short style syntax
>     for the SSH protocol. This commit changes construction logic to detect which
>     one of the two is used in the submodule specification and to build a correct
>     URI out of it.
> 
>     Signed-off-by: Krystian Garliński <krystian.garlinski@comarch.pl
>     <mailto:krystian.garlinski@comarch.pl>>
>     ---
>      lib/bb/fetch2/gitsm.py | 16 ++++++++++++++--
>      1 file changed, 14 insertions(+), 2 deletions(-)
> 
>     diff --git a/lib/bb/fetch2/gitsm.py b/lib/bb/fetch2/gitsm.py
>     index 35729dbc..95d5f652 100644
>     --- a/lib/bb/fetch2/gitsm.py
>     +++ b/lib/bb/fetch2/gitsm.py
>     @@ -32,6 +32,7 @@ NOTE: Switching a SRC_URI from "git://" to "gitsm://"
>     requires a clean of your r
>      import os
>      import bb
>      import copy
>     +import re
>      from   bb.fetch2.git import Git
>      from   bb.fetch2 import runfetchcmd
>      from   bb.fetch2 import logger
>     @@ -39,6 +40,8 @@ from   bb.fetch2 import Fetch
>      from   bb.fetch2 import BBFetchException
> 
>      class GitSM(Git):
>     +    scp_regex = re.compile(r'^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.+)$')
>     +
>          def supports(self, ud, d):
>              """
>              Check to see if a given url can be fetched with git.
>     @@ -88,8 +91,17 @@ class GitSM(Git):
>                  module_hash = module_hash.split()[2]
> 
>                  # Build new SRC_URI
>     -            proto = uris[module].split(':', 1)[0]
>     -            url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
>     +            uri = uris[module]
>     +            match = GitSM.scp_regex.match(uri)
>     +
>     +            if match:
>     +                # this URI follows the short SCP-like syntax
>     +                url = 'gitsm://{}@{}/{}'.format(match.group(1),
>     match.group(2), match.group(3))
>     +                proto = 'ssh'
>     +            else:
>     +                proto = uri.split(':', 1)[0]
>     +                url = 'gitsm' + uri[len(proto):]
>     +
>                  url += ';protocol=%s' % proto
>                  url += ";name=%s" % module
>                  url += ";bareclone=1;nocheckout=1;nobranch=1"
>     -- 
>     2.19.1
> 
>     -- 
>     _______________________________________________
>     bitbake-devel mailing list
>     bitbake-devel@lists.openembedded.org
>     <mailto:bitbake-devel@lists.openembedded.org>
>     http://lists.openembedded.org/mailman/listinfo/bitbake-devel
> 
> 
> 
> -- 
> 
> Cheers, 
> Linus
> 



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

* Re: [PATCH v2] fetch2/gitsm.py: Change the URI construction logic
  2019-01-08 16:35 ` Linus Ziegert
  2019-01-08 19:05   ` Mark Hatle
@ 2019-01-08 21:19   ` Mark Hatle
  2019-01-08 21:24     ` Mark Hatle
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Hatle @ 2019-01-08 21:19 UTC (permalink / raw)
  To: Linus Ziegert, Krystian Garliński; +Cc: bitbake-devel

Upon further work, I'm getting this:

[git-submodule-test]$ git submodule add git@git.yoctoproject.org/bitbake-gitsm-test3
repo URL: 'git@git.yoctoproject.org/bitbake-gitsm-test3' must be absolute or
begin with ./|../

This tells me that the format mentioned below is not actually valid.

I'm getting the message from git versions:

git version 1.8.3.1
git version 2.16.0.rc2

If I change it to the following, it does work -- and this is the format we're
already expecting...

git submodule add git@git.yoctoproject.org:/bitbake-gitsm-test3

I'll try to manually modify the .gitmodules for this format, but technically
speaking it doesn't appear to be legal.

--Mark

On 1/8/19 10:35 AM, Linus Ziegert wrote:
> Hello people,
> 
> I am working as well on fetch2/gitsm.py. We have a privat repo with submodules
> but the current gitsm.py does not support ssh.
> 
> I tested the patch by Krystian but it did not worked for me. I got the following
> ERROR:
> 
>     ERROR: <recipe> do_fetch: The URL:
>     'gitsm:git@github.com/<user>/<submodule_name1>.git;protocol=ssh;name=<submodule_name2>;bareclone=1;nocheckout=1;nobranch=1'
>     is invalid and cannot be interpreted
> 
> 
> The .gitmodules file used looks like this:
> 
> [submodule "submodule_name1"]
> path = submodule_name1
>         url = git@github.com/<user>/<submodule_name1>.git 
> [submodule "submodule_name2"]
> path = submodule_name2
>         url = git@github.com/<user>/<submodule_name2>.git 
> 
> Attached you find my proposal.
> 
> 
> Am Di., 8. Jan. 2019 um 08:48 Uhr schrieb Krystian Garliński
> <krystian.garlinski@comarch.pl>:
> 
>     Git allows to use both the proper URI's and SCP-like short style syntax
>     for the SSH protocol. This commit changes construction logic to detect which
>     one of the two is used in the submodule specification and to build a correct
>     URI out of it.
> 
>     Signed-off-by: Krystian Garliński <krystian.garlinski@comarch.pl
>     <mailto:krystian.garlinski@comarch.pl>>
>     ---
>      lib/bb/fetch2/gitsm.py | 16 ++++++++++++++--
>      1 file changed, 14 insertions(+), 2 deletions(-)
> 
>     diff --git a/lib/bb/fetch2/gitsm.py b/lib/bb/fetch2/gitsm.py
>     index 35729dbc..95d5f652 100644
>     --- a/lib/bb/fetch2/gitsm.py
>     +++ b/lib/bb/fetch2/gitsm.py
>     @@ -32,6 +32,7 @@ NOTE: Switching a SRC_URI from "git://" to "gitsm://"
>     requires a clean of your r
>      import os
>      import bb
>      import copy
>     +import re
>      from   bb.fetch2.git import Git
>      from   bb.fetch2 import runfetchcmd
>      from   bb.fetch2 import logger
>     @@ -39,6 +40,8 @@ from   bb.fetch2 import Fetch
>      from   bb.fetch2 import BBFetchException
> 
>      class GitSM(Git):
>     +    scp_regex = re.compile(r'^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.+)$')
>     +
>          def supports(self, ud, d):
>              """
>              Check to see if a given url can be fetched with git.
>     @@ -88,8 +91,17 @@ class GitSM(Git):
>                  module_hash = module_hash.split()[2]
> 
>                  # Build new SRC_URI
>     -            proto = uris[module].split(':', 1)[0]
>     -            url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
>     +            uri = uris[module]
>     +            match = GitSM.scp_regex.match(uri)
>     +
>     +            if match:
>     +                # this URI follows the short SCP-like syntax
>     +                url = 'gitsm://{}@{}/{}'.format(match.group(1),
>     match.group(2), match.group(3))
>     +                proto = 'ssh'
>     +            else:
>     +                proto = uri.split(':', 1)[0]
>     +                url = 'gitsm' + uri[len(proto):]
>     +
>                  url += ';protocol=%s' % proto
>                  url += ";name=%s" % module
>                  url += ";bareclone=1;nocheckout=1;nobranch=1"
>     -- 
>     2.19.1
> 
>     -- 
>     _______________________________________________
>     bitbake-devel mailing list
>     bitbake-devel@lists.openembedded.org
>     <mailto:bitbake-devel@lists.openembedded.org>
>     http://lists.openembedded.org/mailman/listinfo/bitbake-devel
> 
> 
> 
> -- 
> 
> Cheers, 
> Linus
> 



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

* Re: [PATCH v2] fetch2/gitsm.py: Change the URI construction logic
  2019-01-08 21:19   ` Mark Hatle
@ 2019-01-08 21:24     ` Mark Hatle
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Hatle @ 2019-01-08 21:24 UTC (permalink / raw)
  To: Linus Ziegert, Krystian Garliński; +Cc: bitbake-devel

On 1/8/19 3:19 PM, Mark Hatle wrote:
> Upon further work, I'm getting this:
> 
> [git-submodule-test]$ git submodule add git@git.yoctoproject.org/bitbake-gitsm-test3
> repo URL: 'git@git.yoctoproject.org/bitbake-gitsm-test3' must be absolute or
> begin with ./|../
> 
> This tells me that the format mentioned below is not actually valid.
> 
> I'm getting the message from git versions:
> 
> git version 1.8.3.1
> git version 2.16.0.rc2
> 
> If I change it to the following, it does work -- and this is the format we're
> already expecting...
> 
> git submodule add git@git.yoctoproject.org:/bitbake-gitsm-test3
> 
> I'll try to manually modify the .gitmodules for this format, but technically
> speaking it doesn't appear to be legal.

I did finally try it.  Without the ':' git is looking at the local hard disk and
assuming that is a path and failing:


fatal: repository 'git@git.yoctoproject.org/bitbake-gitsm-test3' does not exist
Clone of 'git@git.yoctoproject.org/bitbake-gitsm-test3' into submodule path
'bitbake-gitsm-test3' failed

So I'm not sure how the stuff below is even valid.  I need a reproducer to be
able to code for it and test things.  Until then, everything I see says that
it's one of three formats:

proto://user:pass@host/path  (url style)
user@host:path (ssh style)
/path or ./path or ../path  (local path)

--Mark

> --Mark
> 
> On 1/8/19 10:35 AM, Linus Ziegert wrote:
>> Hello people,
>>
>> I am working as well on fetch2/gitsm.py. We have a privat repo with submodules
>> but the current gitsm.py does not support ssh.
>>
>> I tested the patch by Krystian but it did not worked for me. I got the following
>> ERROR:
>>
>>     ERROR: <recipe> do_fetch: The URL:
>>     'gitsm:git@github.com/<user>/<submodule_name1>.git;protocol=ssh;name=<submodule_name2>;bareclone=1;nocheckout=1;nobranch=1'
>>     is invalid and cannot be interpreted
>>
>>
>> The .gitmodules file used looks like this:
>>
>> [submodule "submodule_name1"]
>> path = submodule_name1
>>         url = git@github.com/<user>/<submodule_name1>.git 
>> [submodule "submodule_name2"]
>> path = submodule_name2
>>         url = git@github.com/<user>/<submodule_name2>.git 
>>
>> Attached you find my proposal.
>>
>>
>> Am Di., 8. Jan. 2019 um 08:48 Uhr schrieb Krystian Garliński
>> <krystian.garlinski@comarch.pl>:
>>
>>     Git allows to use both the proper URI's and SCP-like short style syntax
>>     for the SSH protocol. This commit changes construction logic to detect which
>>     one of the two is used in the submodule specification and to build a correct
>>     URI out of it.
>>
>>     Signed-off-by: Krystian Garliński <krystian.garlinski@comarch.pl
>>     <mailto:krystian.garlinski@comarch.pl>>
>>     ---
>>      lib/bb/fetch2/gitsm.py | 16 ++++++++++++++--
>>      1 file changed, 14 insertions(+), 2 deletions(-)
>>
>>     diff --git a/lib/bb/fetch2/gitsm.py b/lib/bb/fetch2/gitsm.py
>>     index 35729dbc..95d5f652 100644
>>     --- a/lib/bb/fetch2/gitsm.py
>>     +++ b/lib/bb/fetch2/gitsm.py
>>     @@ -32,6 +32,7 @@ NOTE: Switching a SRC_URI from "git://" to "gitsm://"
>>     requires a clean of your r
>>      import os
>>      import bb
>>      import copy
>>     +import re
>>      from   bb.fetch2.git import Git
>>      from   bb.fetch2 import runfetchcmd
>>      from   bb.fetch2 import logger
>>     @@ -39,6 +40,8 @@ from   bb.fetch2 import Fetch
>>      from   bb.fetch2 import BBFetchException
>>
>>      class GitSM(Git):
>>     +    scp_regex = re.compile(r'^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.+)$')
>>     +
>>          def supports(self, ud, d):
>>              """
>>              Check to see if a given url can be fetched with git.
>>     @@ -88,8 +91,17 @@ class GitSM(Git):
>>                  module_hash = module_hash.split()[2]
>>
>>                  # Build new SRC_URI
>>     -            proto = uris[module].split(':', 1)[0]
>>     -            url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
>>     +            uri = uris[module]
>>     +            match = GitSM.scp_regex.match(uri)
>>     +
>>     +            if match:
>>     +                # this URI follows the short SCP-like syntax
>>     +                url = 'gitsm://{}@{}/{}'.format(match.group(1),
>>     match.group(2), match.group(3))
>>     +                proto = 'ssh'
>>     +            else:
>>     +                proto = uri.split(':', 1)[0]
>>     +                url = 'gitsm' + uri[len(proto):]
>>     +
>>                  url += ';protocol=%s' % proto
>>                  url += ";name=%s" % module
>>                  url += ";bareclone=1;nocheckout=1;nobranch=1"
>>     -- 
>>     2.19.1
>>
>>     -- 
>>     _______________________________________________
>>     bitbake-devel mailing list
>>     bitbake-devel@lists.openembedded.org
>>     <mailto:bitbake-devel@lists.openembedded.org>
>>     http://lists.openembedded.org/mailman/listinfo/bitbake-devel
>>
>>
>>
>> -- 
>>
>> Cheers, 
>> Linus
>>
> 



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

end of thread, other threads:[~2019-01-08 21:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-08  7:47 [PATCH v2] fetch2/gitsm.py: Change the URI construction logic Krystian Garliński
2019-01-08 16:35 ` Linus Ziegert
2019-01-08 19:05   ` Mark Hatle
2019-01-08 21:19   ` Mark Hatle
2019-01-08 21:24     ` Mark Hatle

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.