bitbake-devel.lists.openembedded.org archive mirror
 help / color / mirror / Atom feed
* [bitbake][kirkstone][2.0][PATCH] fetch/git: Fix local clone url to make it work with repo
@ 2023-03-29 16:00 preeti.sachan
  2023-03-29 19:30 ` [bitbake-devel] " Steve Sakoman
  0 siblings, 1 reply; 2+ messages in thread
From: preeti.sachan @ 2023-03-29 16:00 UTC (permalink / raw)
  To: bitbake-devel

From: Robert Yang <liezhi.yang@windriver.com>

The "git clone /path/to/git/objects_symlink" couldn't work after the following
change:

https://github.com/git/git/commit/6f054f9fb3a501c35b55c65e547a244f14c38d56

But repo command manages the git repo as symlinks, so check whether the objects
is an symlink to fix the problem:

* Nothing is changed if git/objects is not a symlink
* Use "git clone file://" when git/objects is a symlink

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/fetch2/git.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 4e286ca9..4d6e57ad 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -359,9 +359,13 @@ class Git(FetchMethod):
 
         # If the repo still doesn't exist, fallback to cloning it
         if not os.path.exists(ud.clonedir):
-            # We do this since git will use a "-l" option automatically for local urls where possible
+            # We do this since git will use a "-l" option automatically for local urls where possible,
+            # but it doesn't work when git/objects is a symlink, only works when it is a directory.
             if repourl.startswith("file://"):
-                repourl = repourl[7:]
+                repourl_path = repourl[7:]
+                objects = os.path.join(repourl_path, 'objects')
+                if os.path.isdir(objects) and not os.path.islink(objects):
+                    repourl = repourl_path
             clone_cmd = "LANG=C %s clone --bare --mirror %s %s --progress" % (ud.basecmd, shlex.quote(repourl), ud.clonedir)
             if ud.proto.lower() != 'file':
                 bb.fetch2.check_network_access(d, clone_cmd, ud.url)
-- 
2.40.0



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

* Re: [bitbake-devel] [bitbake][kirkstone][2.0][PATCH] fetch/git: Fix local clone url to make it work with repo
  2023-03-29 16:00 [bitbake][kirkstone][2.0][PATCH] fetch/git: Fix local clone url to make it work with repo preeti.sachan
@ 2023-03-29 19:30 ` Steve Sakoman
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Sakoman @ 2023-03-29 19:30 UTC (permalink / raw)
  To: preeti.sachan; +Cc: bitbake-devel

I can take this once it hits the master branch.

Steve

On Wed, Mar 29, 2023 at 6:02 AM <preeti.sachan@intel.com> wrote:
>
> From: Robert Yang <liezhi.yang@windriver.com>
>
> The "git clone /path/to/git/objects_symlink" couldn't work after the following
> change:
>
> https://github.com/git/git/commit/6f054f9fb3a501c35b55c65e547a244f14c38d56
>
> But repo command manages the git repo as symlinks, so check whether the objects
> is an symlink to fix the problem:
>
> * Nothing is changed if git/objects is not a symlink
> * Use "git clone file://" when git/objects is a symlink
>
> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  lib/bb/fetch2/git.py | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
> index 4e286ca9..4d6e57ad 100644
> --- a/lib/bb/fetch2/git.py
> +++ b/lib/bb/fetch2/git.py
> @@ -359,9 +359,13 @@ class Git(FetchMethod):
>
>          # If the repo still doesn't exist, fallback to cloning it
>          if not os.path.exists(ud.clonedir):
> -            # We do this since git will use a "-l" option automatically for local urls where possible
> +            # We do this since git will use a "-l" option automatically for local urls where possible,
> +            # but it doesn't work when git/objects is a symlink, only works when it is a directory.
>              if repourl.startswith("file://"):
> -                repourl = repourl[7:]
> +                repourl_path = repourl[7:]
> +                objects = os.path.join(repourl_path, 'objects')
> +                if os.path.isdir(objects) and not os.path.islink(objects):
> +                    repourl = repourl_path
>              clone_cmd = "LANG=C %s clone --bare --mirror %s %s --progress" % (ud.basecmd, shlex.quote(repourl), ud.clonedir)
>              if ud.proto.lower() != 'file':
>                  bb.fetch2.check_network_access(d, clone_cmd, ud.url)
> --
> 2.40.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#14627): https://lists.openembedded.org/g/bitbake-devel/message/14627
> Mute This Topic: https://lists.openembedded.org/mt/97931812/3620601
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [steve@sakoman.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


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

end of thread, other threads:[~2023-03-29 19:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 16:00 [bitbake][kirkstone][2.0][PATCH] fetch/git: Fix local clone url to make it work with repo preeti.sachan
2023-03-29 19:30 ` [bitbake-devel] " Steve Sakoman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).