Wait, doesn't this mask the real issue? Is it ok that the tarball
unpacking failed 'for any reason'?
Alex
On Thu, 10 Feb 2022 at 14:27, Tomasz Dziendzielski
<tomasz.dziendzielski@gmail.com> wrote:
If shallow tarball clone is used and if tar unpacking fails for any
reason it might end up with empty directory created. Since runfetchcmd
does not check any return code we might not detect the issue and we will
not clone from git. Then due to missing hash it will replace main
repository's git remote with the remote of failing recipe.
To fix this behaviour we'll check if clonedir is not empty and if git
dir is the same as clonedir.
Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com>
Signed-off-by: Jan Brzezanski <jan.brzezanski@gmail.com>
---
lib/bb/fetch2/git.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 30da8e95..ed6ecb64 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -356,8 +356,15 @@ class Git(FetchMethod):
repourl = self._get_repo_url(ud)
- # If the repo still doesn't exist, fallback to cloning it
- if not os.path.exists(ud.clonedir):
+ # Clean repo if git dir is different than ud.clonedir, which means tar unpacking failed
+ if os.path.exists(ud.clonedir):
+ if ud.clonedir != runfetchcmd("%s -C %s rev-parse --git-dir" % (ud.basecmd, ud.clonedir), d):
+ bb.utils.remove(ud.clonedir, recurse=True)
+ bb.utils.mkdirhier(ud.clonedir)
+ os.chdir(ud.clonedir)
+
+ # If the repo still doesn't exist or is empty, fallback to cloning it
+ if not os.path.exists(ud.clonedir) or not os.listdir(ud.clonedir):
# We do this since git will use a "-l" option automatically for local urls where possible
if repourl.startswith("file://"):
repourl = repourl[7:]
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#13328): https://lists.openembedded.org/g/bitbake-devel/message/13328
Mute This Topic: https://lists.openembedded.org/mt/89045076/1686489
Group Owner: bitbake-devel+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alex.kanavin@gmail.com]
-=-=-=-=-=-=-=-=-=-=-=-