aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViswanath Kraleti <quic_vkraleti@quicinc.com>2024-03-08 05:33:55 -0800
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2024-04-21 22:08:59 +0200
commit5fa6f3e761ca2cf97324c1b705f3e5c8e85bdbe3 (patch)
treefff06c8d0f063e6fd2e8746eea441fefc3b26913
parent5c1b7e27b0dc0ef1c456a82cff93055177e6a5f8 (diff)
downloadbitbake-contrib-5fa6f3e761ca2cf97324c1b705f3e5c8e85bdbe3.tar.gz
fetch2/git: Add verbose logging support
Currently when git fetches fail, hardly any log is generated that figures out what went wrong. To ease debugging introduced a flag, BB_GIT_VERBOSE_FETCH, when enabled git fetch happens with verbose logging support, thus user can share required logs at one shot. Signed-off-by: Viswanath Kraleti <quic_vkraleti@quicinc.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
-rw-r--r--lib/bb/fetch2/git.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index c7ff769fd..27c9ab95d 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -201,11 +201,15 @@ class Git(FetchMethod):
ud.noshared = d.getVar("BB_GIT_NOSHARED") == "1"
+ verbose = d.getVar("BB_GIT_VERBOSE_FETCH") == "1"
+
ud.cloneflags = "-n"
if not ud.noshared:
ud.cloneflags += " -s"
if ud.bareclone:
ud.cloneflags += " --mirror"
+ if verbose:
+ ud.cloneflags += " --verbose"
ud.shallow = d.getVar("BB_GIT_SHALLOW") == "1"
ud.shallow_extra_refs = (d.getVar("BB_GIT_SHALLOW_EXTRA_REFS") or "").split()
@@ -433,6 +437,7 @@ class Git(FetchMethod):
else:
needs_clone = True
+ verbose = d.getVar("BB_GIT_VERBOSE_FETCH") == "1"
# If the repo still doesn't exist, fallback to cloning it
if needs_clone:
# We do this since git will use a "-l" option automatically for local urls where possible,
@@ -443,6 +448,8 @@ class Git(FetchMethod):
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 verbose:
+ clone_cmd = "GIT_TRACE_PACKET=1 GIT_TRACE=2 GIT_CURL_VERBOSE=1 " + clone_cmd + " --verbose"
if ud.proto.lower() != 'file':
bb.fetch2.check_network_access(d, clone_cmd, ud.url)
progresshandler = GitProgressHandler(d)
@@ -460,6 +467,8 @@ class Git(FetchMethod):
fetch_cmd = "LANG=C %s fetch -f --progress %s refs/*:refs/*" % (ud.basecmd, shlex.quote(repourl))
else:
fetch_cmd = "LANG=C %s fetch -f --progress %s refs/heads/*:refs/heads/* refs/tags/*:refs/tags/*" % (ud.basecmd, shlex.quote(repourl))
+ if verbose:
+ fetch_cmd = "GIT_TRACE_PACKET=1 GIT_TRACE=2 GIT_CURL_VERBOSE=1 " + fetch_cmd + " --verbose"
if ud.proto.lower() != 'file':
bb.fetch2.check_network_access(d, fetch_cmd, ud.url)
progresshandler = GitProgressHandler(d)
@@ -555,7 +564,11 @@ class Git(FetchMethod):
The upstream url of the new clone isn't set at this time, as it'll be
set correctly when unpacked."""
- runfetchcmd("%s clone %s %s %s" % (ud.basecmd, ud.cloneflags, ud.clonedir, dest), d)
+ verbose = d.getVar("BB_GIT_VERBOSE_FETCH") == "1"
+ verbose_env_vars = ""
+ if verbose:
+ verbose_env_vars = " GIT_TRACE_PACKET=1 GIT_TRACE=2 GIT_CURL_VERBOSE=1"
+ runfetchcmd("%s%s clone %s %s %s" % (verbose_env_vars, ud.basecmd, ud.cloneflags, ud.clonedir, dest), d)
to_parse, shallow_branches = [], []
for name in ud.names:
@@ -645,7 +658,11 @@ class Git(FetchMethod):
clonedir_is_up_to_date = not self.clonedir_need_update(ud, d)
if clonedir_is_up_to_date:
- runfetchcmd("%s clone %s %s/ %s" % (ud.basecmd, ud.cloneflags, ud.clonedir, destdir), d)
+ verbose_env_vars = ""
+ verbose = d.getVar("BB_GIT_VERBOSE_FETCH") == "1"
+ if verbose:
+ verbose_env_vars = " GIT_TRACE_PACKET=1 GIT_TRACE=2 GIT_CURL_VERBOSE=1"
+ runfetchcmd("%s%s clone %s %s/ %s" % (verbose_env_vars, ud.basecmd, ud.cloneflags, ud.clonedir, destdir), d)
source_found = True
else:
source_error.append("clone directory not available or not up to date: " + ud.clonedir)