summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartyn Welch <martyn.welch@ge.com>2010-01-26 14:35:51 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2010-03-22 14:53:26 +0000
commit9a0da388cefb71fa7e9b015772c66625fdb70c1d (patch)
tree1d4212b62329b545f2e3196e95ff0bf94ca656e9
parente17a0bd6c0b1bfba24229166904297eab073a688 (diff)
downloadpoky-9a0da388cefb71fa7e9b015772c66625fdb70c1d.tar.gz
Add FETCHCMD parameter for git
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". (Bitbake rev: f3afb79ecac30d973a3c62ff6baf28d8b7388a24) Signed-off-by: Malcolm Crossley <malcolm.crossley@ge.com> Signed-off-by: Martyn Welch <martyn.welch@ge.com> Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
-rw-r--r--bitbake/lib/bb/fetch/git.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/bitbake/lib/bb/fetch/git.py b/bitbake/lib/bb/fetch/git.py
index 10b396bb00..f983ccf277 100644
--- a/bitbake/lib/bb/fetch/git.py
+++ b/bitbake/lib/bb/fetch/git.py
@@ -77,6 +77,8 @@ class Git(Fetch):
77 else: 77 else:
78 ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, subdirpath.replace('/', '.'), ud.tag), d) 78 ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, subdirpath.replace('/', '.'), ud.tag), d)
79 79
80 ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
81
80 return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) 82 return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
81 83
82 def go(self, loc, ud, d): 84 def go(self, loc, ud, d):
@@ -99,16 +101,16 @@ class Git(Fetch):
99 os.chdir(ud.clonedir) 101 os.chdir(ud.clonedir)
100 runfetchcmd("tar -xzf %s" % (repofile), d) 102 runfetchcmd("tar -xzf %s" % (repofile), d)
101 except: 103 except:
102 runfetchcmd("git clone -n %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.clonedir), d) 104 runfetchcmd("%s clone -n %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.clonedir), d)
103 105
104 os.chdir(ud.clonedir) 106 os.chdir(ud.clonedir)
105 # Remove all but the .git directory 107 # Remove all but the .git directory
106 if not self._contains_ref(ud.tag, d): 108 if not self._contains_ref(ud.tag, d):
107 runfetchcmd("rm * -Rf", d) 109 runfetchcmd("rm * -Rf", d)
108 runfetchcmd("git fetch %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.branch), d) 110 runfetchcmd("%s fetch %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.branch), d)
109 runfetchcmd("git fetch --tags %s://%s%s%s" % (ud.proto, username, ud.host, ud.path), d) 111 runfetchcmd("%s fetch --tags %s://%s%s%s" % (ud.basecmd, ud.proto, username, ud.host, ud.path), d)
110 runfetchcmd("git prune-packed", d) 112 runfetchcmd("%s prune-packed" % ud.basecmd, d)
111 runfetchcmd("git pack-redundant --all | xargs -r rm", d) 113 runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d)
112 114
113 os.chdir(ud.clonedir) 115 os.chdir(ud.clonedir)
114 mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) 116 mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True)
@@ -141,8 +143,8 @@ class Git(Fetch):
141 143
142 bb.mkdirhier(codir) 144 bb.mkdirhier(codir)
143 os.chdir(ud.clonedir) 145 os.chdir(ud.clonedir)
144 runfetchcmd("git read-tree %s%s" % (ud.tag, readpathspec), d) 146 runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.tag, readpathspec), d)
145 runfetchcmd("git checkout-index -q -f --prefix=%s -a" % (coprefix), d) 147 runfetchcmd("%s checkout-index -q -f --prefix=%s -a" % (ud.basecmd, coprefix), d)
146 148
147 os.chdir(codir) 149 os.chdir(codir)
148 bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout") 150 bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout")
@@ -155,7 +157,8 @@ class Git(Fetch):
155 return True 157 return True
156 158
157 def _contains_ref(self, tag, d): 159 def _contains_ref(self, tag, d):
158 output = runfetchcmd("git log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % tag, d, quiet=True) 160 basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
161 output = runfetchcmd("%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % (basecmd, tag), d, quiet=True)
159 return output.split()[0] != "0" 162 return output.split()[0] != "0"
160 163
161 def _revision_key(self, url, ud, d): 164 def _revision_key(self, url, ud, d):
@@ -173,7 +176,7 @@ class Git(Fetch):
173 else: 176 else:
174 username = "" 177 username = ""
175 178
176 cmd = "git ls-remote %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.branch) 179 cmd = "%s ls-remote %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.branch)
177 output = runfetchcmd(cmd, d, True) 180 output = runfetchcmd(cmd, d, True)
178 if not output: 181 if not output:
179 raise bb.fetch.FetchError("Fetch command %s gave empty output\n" % (cmd)) 182 raise bb.fetch.FetchError("Fetch command %s gave empty output\n" % (cmd))
@@ -204,7 +207,7 @@ class Git(Fetch):
204 if not self._contains_ref(rev, d): 207 if not self._contains_ref(rev, d):
205 self.go(None, ud, d) 208 self.go(None, ud, d)
206 209
207 output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True) 210 output = runfetchcmd("%s rev-list %s -- 2> /dev/null | wc -l" % (ud.basecmd, rev), d, quiet=True)
208 os.chdir(cwd) 211 os.chdir(cwd)
209 212
210 buildindex = "%s" % output.split()[0] 213 buildindex = "%s" % output.split()[0]