summaryrefslogtreecommitdiffstats
path: root/bitbake-dev/lib/bb/fetch
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-01-14 17:36:31 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2010-01-14 23:29:31 +0000
commitf00e5cf964d0ea48d517f0b8f9ca2aba646ea807 (patch)
treec2bc884ee3192895549745326c2752fe7200a206 /bitbake-dev/lib/bb/fetch
parenta7740492afa04d9a1bdcb907df91900d251fa29f (diff)
downloadpoky-f00e5cf964d0ea48d517f0b8f9ca2aba646ea807.tar.gz
bitbake-dev: Sync with upstream
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake-dev/lib/bb/fetch')
-rw-r--r--bitbake-dev/lib/bb/fetch/__init__.py50
-rw-r--r--bitbake-dev/lib/bb/fetch/git.py42
2 files changed, 58 insertions, 34 deletions
diff --git a/bitbake-dev/lib/bb/fetch/__init__.py b/bitbake-dev/lib/bb/fetch/__init__.py
index b8a00107e2..ab4658bc3b 100644
--- a/bitbake-dev/lib/bb/fetch/__init__.py
+++ b/bitbake-dev/lib/bb/fetch/__init__.py
@@ -99,6 +99,11 @@ def fetcher_init(d):
99 pd.delDomain("BB_URI_HEADREVS") 99 pd.delDomain("BB_URI_HEADREVS")
100 else: 100 else:
101 bb.msg.fatal(bb.msg.domain.Fetcher, "Invalid SRCREV cache policy of: %s" % srcrev_policy) 101 bb.msg.fatal(bb.msg.domain.Fetcher, "Invalid SRCREV cache policy of: %s" % srcrev_policy)
102
103 for m in methods:
104 if hasattr(m, "init"):
105 m.init(d)
106
102 # Make sure our domains exist 107 # Make sure our domains exist
103 pd.addDomain("BB_URI_HEADREVS") 108 pd.addDomain("BB_URI_HEADREVS")
104 pd.addDomain("BB_URI_LOCALCOUNT") 109 pd.addDomain("BB_URI_LOCALCOUNT")
@@ -147,14 +152,16 @@ def init(urls, d, setup = True):
147 urldata_cache[fn] = urldata 152 urldata_cache[fn] = urldata
148 return urldata 153 return urldata
149 154
150def go(d): 155def go(d, urls = None):
151 """ 156 """
152 Fetch all urls 157 Fetch all urls
153 init must have previously been called 158 init must have previously been called
154 """ 159 """
155 urldata = init([], d, True) 160 if not urls:
161 urls = d.getVar("SRC_URI", 1).split()
162 urldata = init(urls, d, True)
156 163
157 for u in urldata: 164 for u in urls:
158 ud = urldata[u] 165 ud = urldata[u]
159 m = ud.method 166 m = ud.method
160 if ud.localfile: 167 if ud.localfile:
@@ -465,6 +472,23 @@ class Fetch(object):
465 472
466 srcrev_internal_helper = staticmethod(srcrev_internal_helper) 473 srcrev_internal_helper = staticmethod(srcrev_internal_helper)
467 474
475 def localcount_internal_helper(ud, d):
476 """
477 Return:
478 a) a locked localcount if specified
479 b) None otherwise
480 """
481
482 localcount= None
483 if 'name' in ud.parm:
484 pn = data.getVar("PN", d, 1)
485 localcount = data.getVar("LOCALCOUNT_" + ud.parm['name'], d, 1)
486 if not localcount:
487 localcount = data.getVar("LOCALCOUNT", d, 1)
488 return localcount
489
490 localcount_internal_helper = staticmethod(localcount_internal_helper)
491
468 def try_mirror(d, tarfn): 492 def try_mirror(d, tarfn):
469 """ 493 """
470 Try to use a mirrored version of the sources. We do this 494 Try to use a mirrored version of the sources. We do this
@@ -553,12 +577,7 @@ class Fetch(object):
553 """ 577 """
554 578
555 """ 579 """
556 has_sortable_valid = hasattr(self, "_sortable_revision_valid") 580 if hasattr(self, "_sortable_revision"):
557 has_sortable = hasattr(self, "_sortable_revision")
558
559 if has_sortable and not has_sortable_valid:
560 return self._sortable_revision(url, ud, d)
561 elif has_sortable and self._sortable_revision_valid(url, ud, d):
562 return self._sortable_revision(url, ud, d) 581 return self._sortable_revision(url, ud, d)
563 582
564 pd = persist_data.PersistData(d) 583 pd = persist_data.PersistData(d)
@@ -566,13 +585,24 @@ class Fetch(object):
566 585
567 latest_rev = self._build_revision(url, ud, d) 586 latest_rev = self._build_revision(url, ud, d)
568 last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev") 587 last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev")
569 count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count") 588 uselocalcount = bb.data.getVar("BB_LOCALCOUNT_OVERRIDE", d, True) or False
589 count = None
590 if uselocalcount:
591 count = Fetch.localcount_internal_helper(ud, d)
592 if count is None:
593 count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count")
570 594
571 if last_rev == latest_rev: 595 if last_rev == latest_rev:
572 return str(count + "+" + latest_rev) 596 return str(count + "+" + latest_rev)
573 597
598 buildindex_provided = hasattr(self, "_sortable_buildindex")
599 if buildindex_provided:
600 count = self._sortable_buildindex(url, ud, d, latest_rev)
601
574 if count is None: 602 if count is None:
575 count = "0" 603 count = "0"
604 elif uselocalcount or buildindex_provided:
605 count = str(count)
576 else: 606 else:
577 count = str(int(count) + 1) 607 count = str(int(count) + 1)
578 608
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
29class Git(Fetch): 29class 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