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]>
---

 lib/bb/fetch/git.py |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/lib/bb/fetch/git.py b/lib/bb/fetch/git.py
index 5cdf656..b6cd598 100644
--- a/lib/bb/fetch/git.py
+++ b/lib/bb/fetch/git.py
@@ -57,6 +57,10 @@ 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"
+
+        print "BASECMD:%s" % (ud.basecmd)
+
         return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
 
     def go(self, loc, ud, d):
@@ -86,16 +90,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 +112,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 +126,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 +145,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 +184,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

Reply via email to