diff options
-rw-r--r-- | bitbake-dev/lib/bb/fetch/__init__.py | 11 | ||||
-rw-r--r-- | bitbake-dev/lib/bb/fetch/git.py | 41 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/__init__.py | 11 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/git.py | 41 |
4 files changed, 98 insertions, 6 deletions
diff --git a/bitbake-dev/lib/bb/fetch/__init__.py b/bitbake-dev/lib/bb/fetch/__init__.py index 3633584992..39a577b2eb 100644 --- a/bitbake-dev/lib/bb/fetch/__init__.py +++ b/bitbake-dev/lib/bb/fetch/__init__.py | |||
@@ -508,7 +508,7 @@ class Fetch(object): | |||
508 | raise ParameterError | 508 | raise ParameterError |
509 | 509 | ||
510 | pd = persist_data.PersistData(d) | 510 | pd = persist_data.PersistData(d) |
511 | key = self._revision_key(url, ud, d) | 511 | key = self.generate_revision_key(url, ud, d) |
512 | rev = pd.getValue("BB_URI_HEADREVS", key) | 512 | rev = pd.getValue("BB_URI_HEADREVS", key) |
513 | if rev != None: | 513 | if rev != None: |
514 | return str(rev) | 514 | return str(rev) |
@@ -521,11 +521,13 @@ class Fetch(object): | |||
521 | """ | 521 | """ |
522 | 522 | ||
523 | """ | 523 | """ |
524 | if hasattr(self, "_sortable_revision"): | 524 | has_sortable = hasattr(self, "_sortable_revision") |
525 | if has_sortable: | ||
525 | return self._sortable_revision(url, ud, d) | 526 | return self._sortable_revision(url, ud, d) |
526 | 527 | ||
527 | pd = persist_data.PersistData(d) | 528 | pd = persist_data.PersistData(d) |
528 | key = self._revision_key(url, ud, d) | 529 | key = self.generate_revision_key(url, ud, d) |
530 | |||
529 | latest_rev = self._build_revision(url, ud, d) | 531 | latest_rev = self._build_revision(url, ud, d) |
530 | last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev") | 532 | last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev") |
531 | count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count") | 533 | count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count") |
@@ -543,6 +545,9 @@ class Fetch(object): | |||
543 | 545 | ||
544 | return str(count + "+" + latest_rev) | 546 | return str(count + "+" + latest_rev) |
545 | 547 | ||
548 | def generate_revision_key(self, url, ud, d): | ||
549 | key = self._revision_key(url, ud, d) | ||
550 | return "%s-%s" % (key, bb.data.getVar("PN", d, True) or "") | ||
546 | 551 | ||
547 | import cvs | 552 | import cvs |
548 | import git | 553 | import git |
diff --git a/bitbake-dev/lib/bb/fetch/git.py b/bitbake-dev/lib/bb/fetch/git.py index 6456403e14..c97ffde1c3 100644 --- a/bitbake-dev/lib/bb/fetch/git.py +++ b/bitbake-dev/lib/bb/fetch/git.py | |||
@@ -145,3 +145,44 @@ class Git(Fetch): | |||
145 | def _build_revision(self, url, ud, d): | 145 | def _build_revision(self, url, ud, d): |
146 | return ud.tag | 146 | return ud.tag |
147 | 147 | ||
148 | def _want_sortable_revision(self, url, ud, d): | ||
149 | return bb.data.getVar("BB_GIT_CLONE_FOR_SRCREV", d, True) or False | ||
150 | |||
151 | def _sortable_revision(self, url, ud, d): | ||
152 | """ | ||
153 | This is only called when _want_sortable_revision called true | ||
154 | |||
155 | We will have to get the updated revision. | ||
156 | """ | ||
157 | gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.')) | ||
158 | repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) | ||
159 | |||
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() | ||
171 | |||
172 | # Check if we have the rev already | ||
173 | if not os.path.exists(repodir): | ||
174 | print "no repo" | ||
175 | self.go(None, ud, d) | ||
176 | |||
177 | os.chdir(repodir) | ||
178 | if not self._contains_ref(ud.tag, d): | ||
179 | self.go(None, ud, d) | ||
180 | |||
181 | output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % ud.tag, d, quiet=True) | ||
182 | os.chdir(cwd) | ||
183 | |||
184 | sortable_revision = "%s+%s" % (output.split()[0], ud.tag) | ||
185 | bb.data.setVar(key, sortable_revision, d) | ||
186 | return sortable_revision | ||
187 | |||
188 | |||
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py index 3333a278e1..39a8180a89 100644 --- a/bitbake/lib/bb/fetch/__init__.py +++ b/bitbake/lib/bb/fetch/__init__.py | |||
@@ -514,7 +514,7 @@ class Fetch(object): | |||
514 | raise ParameterError | 514 | raise ParameterError |
515 | 515 | ||
516 | pd = persist_data.PersistData(d) | 516 | pd = persist_data.PersistData(d) |
517 | key = self._revision_key(url, ud, d) | 517 | key = self.generate_revision_key(url, ud, d) |
518 | rev = pd.getValue("BB_URI_HEADREVS", key) | 518 | rev = pd.getValue("BB_URI_HEADREVS", key) |
519 | if rev != None: | 519 | if rev != None: |
520 | return str(rev) | 520 | return str(rev) |
@@ -527,11 +527,13 @@ class Fetch(object): | |||
527 | """ | 527 | """ |
528 | 528 | ||
529 | """ | 529 | """ |
530 | if hasattr(self, "_sortable_revision"): | 530 | has_sortable = hasattr(self, "_sortable_revision") |
531 | if has_sortable: | ||
531 | return self._sortable_revision(url, ud, d) | 532 | return self._sortable_revision(url, ud, d) |
532 | 533 | ||
533 | pd = persist_data.PersistData(d) | 534 | pd = persist_data.PersistData(d) |
534 | key = self._revision_key(url, ud, d) | 535 | key = self.generate_revision_key(url, ud, d) |
536 | |||
535 | latest_rev = self._build_revision(url, ud, d) | 537 | latest_rev = self._build_revision(url, ud, d) |
536 | last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev") | 538 | last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev") |
537 | count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count") | 539 | count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count") |
@@ -549,6 +551,9 @@ class Fetch(object): | |||
549 | 551 | ||
550 | return str(count + "+" + latest_rev) | 552 | return str(count + "+" + latest_rev) |
551 | 553 | ||
554 | def generate_revision_key(self, url, ud, d): | ||
555 | key = self._revision_key(url, ud, d) | ||
556 | return "%s-%s" % (key, bb.data.getVar("PN", d, True) or "") | ||
552 | 557 | ||
553 | import cvs | 558 | import cvs |
554 | import git | 559 | import git |
diff --git a/bitbake/lib/bb/fetch/git.py b/bitbake/lib/bb/fetch/git.py index 4cae1c1879..5cdf656a3a 100644 --- a/bitbake/lib/bb/fetch/git.py +++ b/bitbake/lib/bb/fetch/git.py | |||
@@ -146,3 +146,44 @@ class Git(Fetch): | |||
146 | def _build_revision(self, url, ud, d): | 146 | def _build_revision(self, url, ud, d): |
147 | return ud.tag | 147 | return ud.tag |
148 | 148 | ||
149 | def _want_sortable_revision(self, url, ud, d): | ||
150 | return bb.data.getVar("BB_GIT_CLONE_FOR_SRCREV", d, True) or False | ||
151 | |||
152 | def _sortable_revision(self, url, ud, d): | ||
153 | """ | ||
154 | This is only called when _want_sortable_revision called true | ||
155 | |||
156 | We will have to get the updated revision. | ||
157 | """ | ||
158 | gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.')) | ||
159 | repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) | ||
160 | |||
161 | key = "GIT_CACHED_REVISION-%s-%s" % (gitsrcname, ud.tag) | ||
162 | if bb.data.getVar(key, d): | ||
163 | return bb.data.getVar(key, d) | ||
164 | |||
165 | |||
166 | # Runtime warning on wrongly configured sources | ||
167 | if ud.tag == "1": | ||
168 | bb.msg.error(1, bb.msg.domain.Fetcher, "SRCREV is '1'. This indicates a configuration error of %s" % url) | ||
169 | return "0+1" | ||
170 | |||
171 | cwd = os.getcwd() | ||
172 | |||
173 | # Check if we have the rev already | ||
174 | if not os.path.exists(repodir): | ||
175 | print "no repo" | ||
176 | self.go(None, ud, d) | ||
177 | |||
178 | os.chdir(repodir) | ||
179 | if not self._contains_ref(ud.tag, d): | ||
180 | self.go(None, ud, d) | ||
181 | |||
182 | output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % ud.tag, d, quiet=True) | ||
183 | os.chdir(cwd) | ||
184 | |||
185 | sortable_revision = "%s+%s" % (output.split()[0], ud.tag) | ||
186 | bb.data.setVar(key, sortable_revision, d) | ||
187 | return sortable_revision | ||
188 | |||
189 | |||