diff options
Diffstat (limited to 'bitbake/lib/bb/fetch')
-rw-r--r-- | bitbake/lib/bb/fetch/__init__.py | 42 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/cvs.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/git.py | 73 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/local.py | 4 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/svk.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/wget.py | 2 |
6 files changed, 87 insertions, 38 deletions
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py index 7326ed0f46..ab4658bc3b 100644 --- a/bitbake/lib/bb/fetch/__init__.py +++ b/bitbake/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") |
@@ -467,6 +472,23 @@ class Fetch(object): | |||
467 | 472 | ||
468 | srcrev_internal_helper = staticmethod(srcrev_internal_helper) | 473 | srcrev_internal_helper = staticmethod(srcrev_internal_helper) |
469 | 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 | |||
470 | def try_mirror(d, tarfn): | 492 | def try_mirror(d, tarfn): |
471 | """ | 493 | """ |
472 | 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 |
@@ -555,12 +577,7 @@ class Fetch(object): | |||
555 | """ | 577 | """ |
556 | 578 | ||
557 | """ | 579 | """ |
558 | has_sortable_valid = hasattr(self, "_sortable_revision_valid") | 580 | if hasattr(self, "_sortable_revision"): |
559 | has_sortable = hasattr(self, "_sortable_revision") | ||
560 | |||
561 | if has_sortable and not has_sortable_valid: | ||
562 | return self._sortable_revision(url, ud, d) | ||
563 | elif has_sortable and self._sortable_revision_valid(url, ud, d): | ||
564 | return self._sortable_revision(url, ud, d) | 581 | return self._sortable_revision(url, ud, d) |
565 | 582 | ||
566 | pd = persist_data.PersistData(d) | 583 | pd = persist_data.PersistData(d) |
@@ -568,13 +585,24 @@ class Fetch(object): | |||
568 | 585 | ||
569 | latest_rev = self._build_revision(url, ud, d) | 586 | latest_rev = self._build_revision(url, ud, d) |
570 | last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev") | 587 | last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev") |
571 | 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") | ||
572 | 594 | ||
573 | if last_rev == latest_rev: | 595 | if last_rev == latest_rev: |
574 | return str(count + "+" + latest_rev) | 596 | return str(count + "+" + latest_rev) |
575 | 597 | ||
598 | buildindex_provided = hasattr(self, "_sortable_buildindex") | ||
599 | if buildindex_provided: | ||
600 | count = self._sortable_buildindex(url, ud, d, latest_rev) | ||
601 | |||
576 | if count is None: | 602 | if count is None: |
577 | count = "0" | 603 | count = "0" |
604 | elif uselocalcount or buildindex_provided: | ||
605 | count = str(count) | ||
578 | else: | 606 | else: |
579 | count = str(int(count) + 1) | 607 | count = str(int(count) + 1) |
580 | 608 | ||
diff --git a/bitbake/lib/bb/fetch/cvs.py b/bitbake/lib/bb/fetch/cvs.py index d8bd4eaf75..90a006500e 100644 --- a/bitbake/lib/bb/fetch/cvs.py +++ b/bitbake/lib/bb/fetch/cvs.py | |||
@@ -41,7 +41,7 @@ class Cvs(Fetch): | |||
41 | """ | 41 | """ |
42 | Check to see if a given url can be fetched with cvs. | 42 | Check to see if a given url can be fetched with cvs. |
43 | """ | 43 | """ |
44 | return ud.type in ['cvs', 'pserver'] | 44 | return ud.type in ['cvs'] |
45 | 45 | ||
46 | def localpath(self, url, ud, d): | 46 | def localpath(self, url, ud, d): |
47 | if not "module" in ud.parm: | 47 | if not "module" in ud.parm: |
diff --git a/bitbake/lib/bb/fetch/git.py b/bitbake/lib/bb/fetch/git.py index 3016f0f00d..0e68325db9 100644 --- a/bitbake/lib/bb/fetch/git.py +++ b/bitbake/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. |
@@ -58,10 +64,18 @@ class Git(Fetch): | |||
58 | if not ud.tag or ud.tag == "master": | 64 | if not ud.tag or ud.tag == "master": |
59 | ud.tag = self.latest_revision(url, ud, d) | 65 | ud.tag = self.latest_revision(url, ud, d) |
60 | 66 | ||
67 | subdir = ud.parm.get("subpath", "") | ||
68 | if subdir != "": | ||
69 | if subdir.endswith("/"): | ||
70 | subdir = subdir[:-1] | ||
71 | subdirpath = os.path.join(ud.path, subdir); | ||
72 | else: | ||
73 | subdirpath = ud.path; | ||
74 | |||
61 | if 'fullclone' in ud.parm: | 75 | if 'fullclone' in ud.parm: |
62 | ud.localfile = ud.mirrortarball | 76 | ud.localfile = ud.mirrortarball |
63 | else: | 77 | else: |
64 | ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.tag), d) | 78 | ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, subdirpath.replace('/', '.'), ud.tag), d) |
65 | 79 | ||
66 | return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) | 80 | return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) |
67 | 81 | ||
@@ -111,10 +125,27 @@ class Git(Fetch): | |||
111 | if os.path.exists(codir): | 125 | if os.path.exists(codir): |
112 | bb.utils.prunedir(codir) | 126 | bb.utils.prunedir(codir) |
113 | 127 | ||
128 | subdir = ud.parm.get("subpath", "") | ||
129 | if subdir != "": | ||
130 | if subdir.endswith("/"): | ||
131 | subdirbase = os.path.basename(subdir[:-1]) | ||
132 | else: | ||
133 | subdirbase = os.path.basename(subdir) | ||
134 | else: | ||
135 | subdirbase = "" | ||
136 | |||
137 | if subdir != "": | ||
138 | readpathspec = ":%s" % (subdir) | ||
139 | codir = os.path.join(codir, "git") | ||
140 | coprefix = os.path.join(codir, subdirbase, "") | ||
141 | else: | ||
142 | readpathspec = "" | ||
143 | coprefix = os.path.join(codir, "git", "") | ||
144 | |||
114 | bb.mkdirhier(codir) | 145 | bb.mkdirhier(codir) |
115 | os.chdir(ud.clonedir) | 146 | os.chdir(ud.clonedir) |
116 | runfetchcmd("git read-tree %s" % (ud.tag), d) | 147 | runfetchcmd("git read-tree %s%s" % (ud.tag, readpathspec), d) |
117 | runfetchcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")), d) | 148 | runfetchcmd("git checkout-index -q -f --prefix=%s -a" % (coprefix), d) |
118 | 149 | ||
119 | os.chdir(codir) | 150 | os.chdir(codir) |
120 | bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout") | 151 | bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout") |
@@ -154,42 +185,32 @@ class Git(Fetch): | |||
154 | def _build_revision(self, url, ud, d): | 185 | def _build_revision(self, url, ud, d): |
155 | return ud.tag | 186 | return ud.tag |
156 | 187 | ||
157 | def _sortable_revision_valid(self, url, ud, d): | 188 | def _sortable_buildindex_disabled(self, url, ud, d, rev): |
158 | return bb.data.getVar("BB_GIT_CLONE_FOR_SRCREV", d, True) or False | ||
159 | |||
160 | def _sortable_revision(self, url, ud, d): | ||
161 | """ | 189 | """ |
162 | This is only called when _sortable_revision_valid called true | 190 | Return a suitable buildindex for the revision specified. This is done by counting revisions |
163 | 191 | using "git rev-list" which may or may not work in different circumstances. | |
164 | We will have to get the updated revision. | ||
165 | """ | 192 | """ |
166 | 193 | ||
167 | key = "GIT_CACHED_REVISION-%s-%s" % (gitsrcname, ud.tag) | ||
168 | if bb.data.getVar(key, d): | ||
169 | return bb.data.getVar(key, d) | ||
170 | |||
171 | |||
172 | # Runtime warning on wrongly configured sources | ||
173 | if ud.tag == "1": | ||
174 | bb.msg.error(1, bb.msg.domain.Fetcher, "SRCREV is '1'. This indicates a configuration error of %s" % url) | ||
175 | return "0+1" | ||
176 | |||
177 | cwd = os.getcwd() | 194 | cwd = os.getcwd() |
178 | 195 | ||
179 | # Check if we have the rev already | 196 | # Check if we have the rev already |
197 | |||
180 | if not os.path.exists(ud.clonedir): | 198 | if not os.path.exists(ud.clonedir): |
181 | print "no repo" | 199 | print "no repo" |
182 | self.go(None, ud, d) | 200 | self.go(None, ud, d) |
201 | if not os.path.exists(ud.clonedir): | ||
202 | bb.msg.error(bb.msg.domain.Fetcher, "GIT repository for %s doesn't exist in %s, cannot get sortable buildnumber, using old value" % (url, ud.clonedir)) | ||
203 | return None | ||
204 | |||
183 | 205 | ||
184 | os.chdir(ud.clonedir) | 206 | os.chdir(ud.clonedir) |
185 | if not self._contains_ref(ud.tag, d): | 207 | if not self._contains_ref(rev, d): |
186 | self.go(None, ud, d) | 208 | self.go(None, ud, d) |
187 | 209 | ||
188 | output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % ud.tag, d, quiet=True) | 210 | output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True) |
189 | os.chdir(cwd) | 211 | os.chdir(cwd) |
190 | 212 | ||
191 | sortable_revision = "%s+%s" % (output.split()[0], ud.tag) | 213 | buildindex = "%s" % output.split()[0] |
192 | bb.data.setVar(key, sortable_revision, d) | 214 | 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)) |
193 | return sortable_revision | 215 | return buildindex |
194 | |||
195 | 216 | ||
diff --git a/bitbake/lib/bb/fetch/local.py b/bitbake/lib/bb/fetch/local.py index 577774e597..f9bdf589cb 100644 --- a/bitbake/lib/bb/fetch/local.py +++ b/bitbake/lib/bb/fetch/local.py | |||
@@ -33,9 +33,9 @@ from bb.fetch import Fetch | |||
33 | class Local(Fetch): | 33 | class Local(Fetch): |
34 | def supports(self, url, urldata, d): | 34 | def supports(self, url, urldata, d): |
35 | """ | 35 | """ |
36 | Check to see if a given url can be fetched with cvs. | 36 | Check to see if a given url represents a local fetch. |
37 | """ | 37 | """ |
38 | return urldata.type in ['file','patch'] | 38 | return urldata.type in ['file'] |
39 | 39 | ||
40 | def localpath(self, url, urldata, d): | 40 | def localpath(self, url, urldata, d): |
41 | """ | 41 | """ |
diff --git a/bitbake/lib/bb/fetch/svk.py b/bitbake/lib/bb/fetch/svk.py index 442f85804f..120dad9d4e 100644 --- a/bitbake/lib/bb/fetch/svk.py +++ b/bitbake/lib/bb/fetch/svk.py | |||
@@ -36,7 +36,7 @@ class Svk(Fetch): | |||
36 | """Class to fetch a module or modules from svk repositories""" | 36 | """Class to fetch a module or modules from svk repositories""" |
37 | def supports(self, url, ud, d): | 37 | def supports(self, url, ud, d): |
38 | """ | 38 | """ |
39 | Check to see if a given url can be fetched with cvs. | 39 | Check to see if a given url can be fetched with svk. |
40 | """ | 40 | """ |
41 | return ud.type in ['svk'] | 41 | return ud.type in ['svk'] |
42 | 42 | ||
diff --git a/bitbake/lib/bb/fetch/wget.py b/bitbake/lib/bb/fetch/wget.py index a0dca94040..fd93c7ec46 100644 --- a/bitbake/lib/bb/fetch/wget.py +++ b/bitbake/lib/bb/fetch/wget.py | |||
@@ -36,7 +36,7 @@ class Wget(Fetch): | |||
36 | """Class to fetch urls via 'wget'""" | 36 | """Class to fetch urls via 'wget'""" |
37 | def supports(self, url, ud, d): | 37 | def supports(self, url, ud, d): |
38 | """ | 38 | """ |
39 | Check to see if a given url can be fetched with cvs. | 39 | Check to see if a given url can be fetched with wget. |
40 | """ | 40 | """ |
41 | return ud.type in ['http','https','ftp'] | 41 | return ud.type in ['http','https','ftp'] |
42 | 42 | ||