diff options
Diffstat (limited to 'bitbake-dev/lib/bb/fetch/git.py')
-rw-r--r-- | bitbake-dev/lib/bb/fetch/git.py | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/bitbake-dev/lib/bb/fetch/git.py b/bitbake-dev/lib/bb/fetch/git.py index 911c5e437f..43053d6c46 100644 --- a/bitbake-dev/lib/bb/fetch/git.py +++ b/bitbake-dev/lib/bb/fetch/git.py | |||
@@ -28,6 +28,12 @@ from bb.fetch import runfetchcmd | |||
28 | 28 | ||
29 | class Git(Fetch): | 29 | class Git(Fetch): |
30 | """Class to fetch a module or modules from git repositories""" | 30 | """Class to fetch a module or modules from git repositories""" |
31 | def init(self, d): | ||
32 | # | ||
33 | # Only enable _sortable revision if the key is set | ||
34 | # | ||
35 | if bb.data.getVar("BB_GIT_CLONE_FOR_SRCREV", d, True): | ||
36 | self._sortable_buildindex = self._sortable_buildindex_disabled | ||
31 | def supports(self, url, ud, d): | 37 | def supports(self, url, ud, d): |
32 | """ | 38 | """ |
33 | Check to see if a given url can be fetched with git. | 39 | Check to see if a given url can be fetched with git. |
@@ -145,44 +151,32 @@ class Git(Fetch): | |||
145 | def _build_revision(self, url, ud, d): | 151 | def _build_revision(self, url, ud, d): |
146 | return ud.tag | 152 | return ud.tag |
147 | 153 | ||
148 | def _sortable_revision_valid(self, url, ud, d): | 154 | def _sortable_buildindex_disabled(self, url, ud, d, rev): |
149 | return bb.data.getVar("BB_GIT_CLONE_FOR_SRCREV", d, True) or False | ||
150 | |||
151 | def _sortable_revision(self, url, ud, d): | ||
152 | """ | 155 | """ |
153 | This is only called when _sortable_revision_valid called true | 156 | Return a suitable buildindex for the revision specified. This is done by counting revisions |
154 | 157 | using "git rev-list" which may or may not work in different circumstances. | |
155 | We will have to get the updated revision. | ||
156 | """ | 158 | """ |
157 | gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.')) | 159 | gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.')) |
158 | repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) | 160 | repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) |
159 | 161 | ||
160 | key = "GIT_CACHED_REVISION-%s-%s" % (gitsrcname, ud.tag) | ||
161 | if bb.data.getVar(key, d): | ||
162 | return bb.data.getVar(key, d) | ||
163 | |||
164 | |||
165 | # Runtime warning on wrongly configured sources | ||
166 | if ud.tag == "1": | ||
167 | bb.msg.error(1, bb.msg.domain.Fetcher, "SRCREV is '1'. This indicates a configuration error of %s" % url) | ||
168 | return "0+1" | ||
169 | |||
170 | cwd = os.getcwd() | 162 | cwd = os.getcwd() |
171 | 163 | ||
172 | # Check if we have the rev already | 164 | # Check if we have the rev already |
173 | if not os.path.exists(repodir): | 165 | if not os.path.exists(repodir): |
174 | print "no repo" | ||
175 | self.go(None, ud, d) | 166 | self.go(None, ud, d) |
167 | if not os.path.exists(repodir): | ||
168 | bb.msg.error(bb.msg.domain.Fetcher, "GIT repository for %s doesn't exist in %s, cannot get sortable buildnumber, using old value" % (url, repodir)) | ||
169 | return None | ||
170 | |||
176 | 171 | ||
177 | os.chdir(repodir) | 172 | os.chdir(repodir) |
178 | if not self._contains_ref(ud.tag, d): | 173 | if not self._contains_ref(rev, d): |
179 | self.go(None, ud, d) | 174 | self.go(None, ud, d) |
180 | 175 | ||
181 | output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % ud.tag, d, quiet=True) | 176 | output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True) |
182 | os.chdir(cwd) | 177 | os.chdir(cwd) |
183 | 178 | ||
184 | sortable_revision = "%s+%s" % (output.split()[0], ud.tag) | 179 | buildindex = "%s" % output.split()[0] |
185 | bb.data.setVar(key, sortable_revision, d) | 180 | bb.msg.debug(1, bb.msg.domain.Fetcher, "GIT repository for %s in %s is returning %s revisions in rev-list before %s" % (url, repodir, buildindex, rev)) |
186 | return sortable_revision | 181 | return buildindex |
187 | |||
188 | 182 | ||