diff options
author | Richard Purdie <richard@openedhand.com> | 2007-09-05 07:48:15 +0000 |
---|---|---|
committer | Richard Purdie <richard@openedhand.com> | 2007-09-05 07:48:15 +0000 |
commit | 899c451a73cdb5fc7094626c8331a8a690a50d2c (patch) | |
tree | f419432ea9de0d53705e02626de1f6207156fe9c /bitbake | |
parent | 7d4aa7f04e661d0546569f2f5a581e44e447de84 (diff) | |
download | poky-899c451a73cdb5fc7094626c8331a8a690a50d2c.tar.gz |
bitbake: Sync with 1.8 upstream branch
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@2689 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/ChangeLog | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/__init__.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/bzr.py | 159 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 6 |
4 files changed, 169 insertions, 0 deletions
diff --git a/bitbake/ChangeLog b/bitbake/ChangeLog index b8ab651aa2..0c7e6d8a8e 100644 --- a/bitbake/ChangeLog +++ b/bitbake/ChangeLog | |||
@@ -8,6 +8,8 @@ Changes in BitBake 1.8.x: | |||
8 | - Detect builds of tasks with overlapping providers and warn (will become a fatal error) (#1359) | 8 | - Detect builds of tasks with overlapping providers and warn (will become a fatal error) (#1359) |
9 | - Add MULTI_PROVIDER_WHITELIST variable to allow known safe multiple providers to be listed | 9 | - Add MULTI_PROVIDER_WHITELIST variable to allow known safe multiple providers to be listed |
10 | - Handle paths in svn fetcher module parameter | 10 | - Handle paths in svn fetcher module parameter |
11 | - Support the syntax "export VARIABLE" | ||
12 | - Add bzr fetcher | ||
11 | 13 | ||
12 | Changes in Bitbake 1.8.8: | 14 | Changes in Bitbake 1.8.8: |
13 | - Rewrite svn fetcher to make adding extra operations easier | 15 | - Rewrite svn fetcher to make adding extra operations easier |
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py index c34405738b..da911e242c 100644 --- a/bitbake/lib/bb/fetch/__init__.py +++ b/bitbake/lib/bb/fetch/__init__.py | |||
@@ -460,6 +460,7 @@ import wget | |||
460 | import svk | 460 | import svk |
461 | import ssh | 461 | import ssh |
462 | import perforce | 462 | import perforce |
463 | import bzr | ||
463 | 464 | ||
464 | methods.append(local.Local()) | 465 | methods.append(local.Local()) |
465 | methods.append(wget.Wget()) | 466 | methods.append(wget.Wget()) |
@@ -469,3 +470,4 @@ methods.append(cvs.Cvs()) | |||
469 | methods.append(svk.Svk()) | 470 | methods.append(svk.Svk()) |
470 | methods.append(ssh.SSH()) | 471 | methods.append(ssh.SSH()) |
471 | methods.append(perforce.Perforce()) | 472 | methods.append(perforce.Perforce()) |
473 | methods.append(bzr.Bzr()) | ||
diff --git a/bitbake/lib/bb/fetch/bzr.py b/bitbake/lib/bb/fetch/bzr.py new file mode 100644 index 0000000000..be89a080a0 --- /dev/null +++ b/bitbake/lib/bb/fetch/bzr.py | |||
@@ -0,0 +1,159 @@ | |||
1 | """ | ||
2 | BitBake 'Fetch' implementation for bzr. | ||
3 | |||
4 | """ | ||
5 | |||
6 | # Copyright (C) 2007 Ross Burton | ||
7 | # Copyright (C) 2007 Richard Purdie | ||
8 | # | ||
9 | # Classes for obtaining upstream sources for the | ||
10 | # BitBake build tools. | ||
11 | # Copyright (C) 2003, 2004 Chris Larson | ||
12 | # | ||
13 | # This program is free software; you can redistribute it and/or modify | ||
14 | # it under the terms of the GNU General Public License version 2 as | ||
15 | # published by the Free Software Foundation. | ||
16 | # | ||
17 | # This program is distributed in the hope that it will be useful, | ||
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | # GNU General Public License for more details. | ||
21 | # | ||
22 | # You should have received a copy of the GNU General Public License along | ||
23 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
24 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
25 | |||
26 | import os | ||
27 | import sys | ||
28 | import bb | ||
29 | from bb import data | ||
30 | from bb.fetch import Fetch | ||
31 | from bb.fetch import FetchError | ||
32 | from bb.fetch import MissingParameterError | ||
33 | from bb.fetch import runfetchcmd | ||
34 | |||
35 | class Bzr(Fetch): | ||
36 | def supports(self, url, ud, d): | ||
37 | return ud.type in ['bzr'] | ||
38 | |||
39 | def localpath (self, url, ud, d): | ||
40 | |||
41 | # Create paths to bzr checkouts | ||
42 | relpath = ud.path | ||
43 | if relpath.startswith('/'): | ||
44 | # Remove leading slash as os.path.join can't cope | ||
45 | relpath = relpath[1:] | ||
46 | ud.pkgdir = os.path.join(data.expand('${BZRDIR}', d), ud.host, relpath) | ||
47 | |||
48 | if 'rev' in ud.parm: | ||
49 | ud.revision = ud.parm['rev'] | ||
50 | else: | ||
51 | # ***Nasty hack*** | ||
52 | rev = data.getVar("SRCREV", d, 0) | ||
53 | if rev and "get_srcrev" in rev: | ||
54 | ud.revision = self.latest_revision(url, ud, d) | ||
55 | elif rev: | ||
56 | ud.revision = rev | ||
57 | else: | ||
58 | ud.revision = "" | ||
59 | |||
60 | |||
61 | ud.localfile = data.expand('bzr_%s_%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.revision), d) | ||
62 | |||
63 | return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) | ||
64 | |||
65 | def _buildbzrcommand(self, ud, d, command): | ||
66 | """ | ||
67 | Build up an bzr commandline based on ud | ||
68 | command is "fetch", "update", "revno" | ||
69 | """ | ||
70 | |||
71 | basecmd = data.expand('${FETCHCMD_bzr}', d) | ||
72 | |||
73 | proto = "http" | ||
74 | if "proto" in ud.parm: | ||
75 | proto = ud.parm["proto"] | ||
76 | |||
77 | bzrroot = ud.host + ud.path | ||
78 | |||
79 | options = [] | ||
80 | |||
81 | if command is "revno": | ||
82 | bzrcmd = "%s revno %s %s://%s" % (basecmd, " ".join(options), proto, bzrroot) | ||
83 | else: | ||
84 | if ud.revision: | ||
85 | options.append("-r %s" % ud.revision) | ||
86 | |||
87 | if command is "fetch": | ||
88 | bzrcmd = "%s co %s %s://%s" % (basecmd, " ".join(options), proto, bzrroot) | ||
89 | elif command is "update": | ||
90 | bzrcmd = "%s update %s" % (basecmd, " ".join(options)) | ||
91 | else: | ||
92 | raise FetchError("Invalid bzr command %s" % command) | ||
93 | |||
94 | return bzrcmd | ||
95 | |||
96 | def go(self, loc, ud, d): | ||
97 | """Fetch url""" | ||
98 | |||
99 | # try to use the tarball stash | ||
100 | if Fetch.try_mirror(d, ud.localfile): | ||
101 | bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping bzr checkout." % ud.localpath) | ||
102 | return | ||
103 | |||
104 | # Updating is disabled until bzr supports the syntax "bzr update -r X" to specify a revision | ||
105 | if 0 and os.access(os.path.join(ud.pkgdir, os.path.basename(ud.pkgdir), '.bzr'), os.R_OK): | ||
106 | bzrcmd = self._buildbzrcommand(ud, d, "update") | ||
107 | bb.msg.debug(1, bb.msg.domain.Fetcher, "BZR Update %s" % loc) | ||
108 | os.chdir(os.path.join (ud.pkgdir, os.path.basename(ud.path))) | ||
109 | runfetchcmd(bzrcmd, d) | ||
110 | else: | ||
111 | os.system("rm -rf %s" % os.path.join(ud.pkgdir, os.path.basename(ud.pkgdir))) | ||
112 | bzrcmd = self._buildbzrcommand(ud, d, "fetch") | ||
113 | bb.msg.debug(1, bb.msg.domain.Fetcher, "BZR Checkout %s" % loc) | ||
114 | bb.mkdirhier(ud.pkgdir) | ||
115 | os.chdir(ud.pkgdir) | ||
116 | bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % bzrcmd) | ||
117 | runfetchcmd(bzrcmd, d) | ||
118 | |||
119 | os.chdir(ud.pkgdir) | ||
120 | # tar them up to a defined filename | ||
121 | try: | ||
122 | runfetchcmd("tar -czf %s %s" % (ud.localpath, os.path.basename(ud.pkgdir)), d) | ||
123 | except: | ||
124 | t, v, tb = sys.exc_info() | ||
125 | try: | ||
126 | os.unlink(ud.localpath) | ||
127 | except OSError: | ||
128 | pass | ||
129 | raise t, v, tb | ||
130 | |||
131 | def suppports_srcrev(self): | ||
132 | return True | ||
133 | |||
134 | def _revision_key(self, url, ud, d): | ||
135 | """ | ||
136 | Return a unique key for the url | ||
137 | """ | ||
138 | return "bzr:" + ud.pkgdir | ||
139 | |||
140 | def _latest_revision(self, url, ud, d): | ||
141 | """ | ||
142 | Return the latest upstream revision number | ||
143 | """ | ||
144 | bb.msg.debug(2, bb.msg.domain.Fetcher, "BZR fetcher hitting network for %s" % url) | ||
145 | |||
146 | output = runfetchcmd(self._buildbzrcommand(ud, d, "revno"), d, True) | ||
147 | |||
148 | for line in output.splitlines(): | ||
149 | revision = line | ||
150 | |||
151 | return revision | ||
152 | |||
153 | def _sortable_revision(self, url, ud, d): | ||
154 | """ | ||
155 | Return a sortable revision number which in our case is the revision number | ||
156 | (use the cached version to avoid network access) | ||
157 | """ | ||
158 | |||
159 | return self.latest_revision(url, ud, d) | ||
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index 6311e76902..e6488bbe11 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py | |||
@@ -31,6 +31,7 @@ from bb.parse import ParseError | |||
31 | __config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") | 31 | __config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") |
32 | __include_regexp__ = re.compile( r"include\s+(.+)" ) | 32 | __include_regexp__ = re.compile( r"include\s+(.+)" ) |
33 | __require_regexp__ = re.compile( r"require\s+(.+)" ) | 33 | __require_regexp__ = re.compile( r"require\s+(.+)" ) |
34 | __export_regexp__ = re.compile( r"export\s+(.+)" ) | ||
34 | 35 | ||
35 | def init(data): | 36 | def init(data): |
36 | if not bb.data.getVar('TOPDIR', data): | 37 | if not bb.data.getVar('TOPDIR', data): |
@@ -214,6 +215,11 @@ def feeder(lineno, s, fn, data): | |||
214 | include(fn, s, data, "include required") | 215 | include(fn, s, data, "include required") |
215 | return | 216 | return |
216 | 217 | ||
218 | m = __export_regexp__.match(s) | ||
219 | if m: | ||
220 | bb.data.setVarFlag(m.group(1), "export", 1, data) | ||
221 | return | ||
222 | |||
217 | raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); | 223 | raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); |
218 | 224 | ||
219 | # Add us to the handlers list | 225 | # Add us to the handlers list |