The Git fetcher currently hardwires the git command to "git". Allow the path and any additional wrappers to the Git command to be provided via FETCHCMD functionality, as with some of the other fetchers.
If FETCHCMD_git is not define in bitbake.conf, the fetcher defaults to "git". Signed-off-by: Malcolm Crossley <[email protected]> Signed-off-by: Martyn Welch <[email protected]> --- v3: Sorry for the noise - I just noticed a bit of debugging that was accidentally left in. v2: Following Richards suggestion, default added and ud.basecmd set in localpath. We have been sitting on this patch for a while, I forward ported it, but in my haste failed to check if all calls to "git" we changed, the fetcher seems to have changed a bit and there are now more calls to the git command. This is now done in the patch below. This does mean that "FETCHCMD_git" must be read in "_contains_ref" as well (it doesn't seem to have "ud" in it it's context) but I feel it pays to be consistent. v1: This patch is against the "1.8" branch. lib/bb/fetch/git.py | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/bb/fetch/git.py b/lib/bb/fetch/git.py index 5cdf656..6ea2a30 100644 --- a/lib/bb/fetch/git.py +++ b/lib/bb/fetch/git.py @@ -57,6 +57,8 @@ class Git(Fetch): ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.tag), d) + ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git" + return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) def go(self, loc, ud, d): @@ -86,16 +88,16 @@ class Git(Fetch): os.chdir(repodir) runfetchcmd("tar -xzf %s" % (repofile), d) else: - runfetchcmd("git clone -n %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, repodir), d) + runfetchcmd("%s clone -n %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, repodir), d) os.chdir(repodir) # Remove all but the .git directory if not self._contains_ref(ud.tag, d): runfetchcmd("rm * -Rf", d) - runfetchcmd("git fetch %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.branch), d) - runfetchcmd("git fetch --tags %s://%s%s%s" % (ud.proto, username, ud.host, ud.path), d) - runfetchcmd("git prune-packed", d) - runfetchcmd("git pack-redundant --all | xargs -r rm", d) + runfetchcmd("%s fetch %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.branch), d) + runfetchcmd("%s fetch --tags %s://%s%s%s" % (ud.basecmd, ud.proto, username, ud.host, ud.path), d) + runfetchcmd("%s prune-packed" % (ud.basecmd), d) + runfetchcmd("%s pack-redundant --all | xargs -r rm" % (ud.basecmd), d) os.chdir(repodir) mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) @@ -108,8 +110,8 @@ class Git(Fetch): bb.mkdirhier(codir) os.chdir(repodir) - runfetchcmd("git read-tree %s" % (ud.tag), d) - runfetchcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")), d) + runfetchcmd("%s read-tree %s" % (ud.basecmd, ud.tag), d) + runfetchcmd("%s checkout-index -q -f --prefix=%s -a" % (ud.basecmd, os.path.join(codir, "git", "")), d) os.chdir(codir) bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout") @@ -122,7 +124,8 @@ class Git(Fetch): return True def _contains_ref(self, tag, d): - output = runfetchcmd("git log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % tag, d, quiet=True) + basecmd = data.getVar("FETCHCMD_git", d, True) or "git" + output = runfetchcmd("%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % (basecmd, tag), d, quiet=True) return output.split()[0] != "0" def _revision_key(self, url, ud, d): @@ -140,7 +143,7 @@ class Git(Fetch): else: username = "" - output = runfetchcmd("git ls-remote %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.branch), d, True) + output = runfetchcmd("%s ls-remote %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.branch), d, True) return output.split()[0] def _build_revision(self, url, ud, d): @@ -179,7 +182,7 @@ class Git(Fetch): if not self._contains_ref(ud.tag, d): self.go(None, ud, d) - output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % ud.tag, d, quiet=True) + output = runfetchcmd("%s rev-list %s -- 2> /dev/null | wc -l" % ud.basecmd, ud.tag, d, quiet=True) os.chdir(cwd) sortable_revision = "%s+%s" % (output.split()[0], ud.tag) -- Martyn Welch MEng MPhil MIET (Principal Software Engineer) T:+44(0)1327322748 GE Fanuc Intelligent Platforms Ltd, |Registered in England and Wales Tove Valley Business Park, Towcester, |(3828642) at 100 Barbirolli Square, Northants, NN12 6PF, UK T:+44(0)1327359444 |Manchester,M2 3AB VAT:GB 927559189 _______________________________________________ Bitbake-dev mailing list [email protected] https://lists.berlios.de/mailman/listinfo/bitbake-dev
