blob: a0252057231835306b994a9d348dad5a8b77e53c [file] [log] [blame]
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07001#
2# Copyright (C) 2008 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import os
17import sys
18import xml.dom.minidom
19
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070020from git_config import GitConfig, IsId
Shawn O. Pearced1f70d92009-05-19 14:58:02 -070021from project import RemoteSpec, Project, MetaProject, R_HEADS, HEAD
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070022from error import ManifestParseError
23
24MANIFEST_FILE_NAME = 'manifest.xml'
Shawn O. Pearce5cc66792008-10-23 16:19:27 -070025LOCAL_MANIFEST_NAME = 'local_manifest.xml'
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070026
27class _Default(object):
28 """Project defaults within the manifest."""
29
Shawn O. Pearce3c8dea12009-05-29 18:38:17 -070030 revisionExpr = None
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070031 remote = None
Shawn O. Pearce6392c872011-09-22 17:44:31 -070032 sync_j = 1
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070033
Shawn O. Pearced1f70d92009-05-19 14:58:02 -070034class _XmlRemote(object):
35 def __init__(self,
36 name,
37 fetch=None,
38 review=None):
39 self.name = name
40 self.fetchUrl = fetch
41 self.reviewUrl = review
42
43 def ToRemoteSpec(self, projectName):
44 url = self.fetchUrl
45 while url.endswith('/'):
46 url = url[:-1]
47 url += '/%s.git' % projectName
48 return RemoteSpec(self.name, url, self.reviewUrl)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070049
Shawn O. Pearcec8a300f2009-05-18 13:19:57 -070050class XmlManifest(object):
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070051 """manages the repo configuration file"""
52
53 def __init__(self, repodir):
54 self.repodir = os.path.abspath(repodir)
55 self.topdir = os.path.dirname(self.repodir)
56 self.manifestFile = os.path.join(self.repodir, MANIFEST_FILE_NAME)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070057 self.globalConfig = GitConfig.ForUser()
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070058
59 self.repoProject = MetaProject(self, 'repo',
60 gitdir = os.path.join(repodir, 'repo/.git'),
61 worktree = os.path.join(repodir, 'repo'))
62
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070063 self.manifestProject = MetaProject(self, 'manifests',
Shawn O. Pearcef5c25a62008-11-04 08:11:53 -080064 gitdir = os.path.join(repodir, 'manifests.git'),
65 worktree = os.path.join(repodir, 'manifests'))
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070066
67 self._Unload()
68
Nico Sallembiena1bfd2c2010-04-06 10:40:01 -070069 def Override(self, name):
70 """Use a different manifest, just for the current instantiation.
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070071 """
72 path = os.path.join(self.manifestProject.worktree, name)
73 if not os.path.isfile(path):
74 raise ManifestParseError('manifest %s not found' % name)
75
76 old = self.manifestFile
77 try:
78 self.manifestFile = path
79 self._Unload()
80 self._Load()
81 finally:
82 self.manifestFile = old
83
Nico Sallembiena1bfd2c2010-04-06 10:40:01 -070084 def Link(self, name):
85 """Update the repo metadata to use a different manifest.
86 """
87 self.Override(name)
88
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070089 try:
90 if os.path.exists(self.manifestFile):
91 os.remove(self.manifestFile)
92 os.symlink('manifests/%s' % name, self.manifestFile)
93 except OSError, e:
94 raise ManifestParseError('cannot link manifest %s' % name)
95
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -080096 def _RemoteToXml(self, r, doc, root):
97 e = doc.createElement('remote')
98 root.appendChild(e)
99 e.setAttribute('name', r.name)
100 e.setAttribute('fetch', r.fetchUrl)
101 if r.reviewUrl is not None:
102 e.setAttribute('review', r.reviewUrl)
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800103
104 def Save(self, fd, peg_rev=False):
105 """Write the current manifest out to the given file descriptor.
106 """
107 doc = xml.dom.minidom.Document()
108 root = doc.createElement('manifest')
109 doc.appendChild(root)
110
Doug Anderson2b8db3c2010-11-01 15:08:06 -0700111 # Save out the notice. There's a little bit of work here to give it the
112 # right whitespace, which assumes that the notice is automatically indented
113 # by 4 by minidom.
114 if self.notice:
115 notice_element = root.appendChild(doc.createElement('notice'))
116 notice_lines = self.notice.splitlines()
117 indented_notice = ('\n'.join(" "*4 + line for line in notice_lines))[4:]
118 notice_element.appendChild(doc.createTextNode(indented_notice))
119
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800120 d = self.default
121 sort_remotes = list(self.remotes.keys())
122 sort_remotes.sort()
123
124 for r in sort_remotes:
125 self._RemoteToXml(self.remotes[r], doc, root)
126 if self.remotes:
127 root.appendChild(doc.createTextNode(''))
128
129 have_default = False
130 e = doc.createElement('default')
131 if d.remote:
132 have_default = True
133 e.setAttribute('remote', d.remote.name)
Shawn O. Pearce3c8dea12009-05-29 18:38:17 -0700134 if d.revisionExpr:
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800135 have_default = True
Shawn O. Pearce3c8dea12009-05-29 18:38:17 -0700136 e.setAttribute('revision', d.revisionExpr)
Shawn O. Pearce6392c872011-09-22 17:44:31 -0700137 if d.sync_j > 1:
138 have_default = True
139 e.setAttribute('sync-j', '%d' % d.sync_j)
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800140 if have_default:
141 root.appendChild(e)
142 root.appendChild(doc.createTextNode(''))
143
Nico Sallembiena1bfd2c2010-04-06 10:40:01 -0700144 if self._manifest_server:
145 e = doc.createElement('manifest-server')
146 e.setAttribute('url', self._manifest_server)
147 root.appendChild(e)
148 root.appendChild(doc.createTextNode(''))
149
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800150 sort_projects = list(self.projects.keys())
151 sort_projects.sort()
152
153 for p in sort_projects:
154 p = self.projects[p]
155 e = doc.createElement('project')
156 root.appendChild(e)
157 e.setAttribute('name', p.name)
158 if p.relpath != p.name:
159 e.setAttribute('path', p.relpath)
160 if not d.remote or p.remote.name != d.remote.name:
161 e.setAttribute('remote', p.remote.name)
162 if peg_rev:
163 if self.IsMirror:
164 e.setAttribute('revision',
Shawn O. Pearce3c8dea12009-05-29 18:38:17 -0700165 p.bare_git.rev_parse(p.revisionExpr + '^0'))
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800166 else:
167 e.setAttribute('revision',
168 p.work_git.rev_parse(HEAD + '^0'))
Shawn O. Pearce3c8dea12009-05-29 18:38:17 -0700169 elif not d.revisionExpr or p.revisionExpr != d.revisionExpr:
170 e.setAttribute('revision', p.revisionExpr)
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800171
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800172 for c in p.copyfiles:
173 ce = doc.createElement('copyfile')
174 ce.setAttribute('src', c.src)
175 ce.setAttribute('dest', c.dest)
176 e.appendChild(ce)
177
Doug Anderson37282b42011-03-04 11:54:18 -0800178 if self._repo_hooks_project:
179 root.appendChild(doc.createTextNode(''))
180 e = doc.createElement('repo-hooks')
181 e.setAttribute('in-project', self._repo_hooks_project.name)
182 e.setAttribute('enabled-list',
183 ' '.join(self._repo_hooks_project.enabled_repo_hooks))
184 root.appendChild(e)
185
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800186 doc.writexml(fd, '', ' ', '\n', 'UTF-8')
187
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700188 @property
189 def projects(self):
190 self._Load()
191 return self._projects
192
193 @property
194 def remotes(self):
195 self._Load()
196 return self._remotes
197
198 @property
199 def default(self):
200 self._Load()
201 return self._default
202
Shawn O. Pearcee284ad12008-11-04 07:37:10 -0800203 @property
Doug Anderson37282b42011-03-04 11:54:18 -0800204 def repo_hooks_project(self):
205 self._Load()
206 return self._repo_hooks_project
207
208 @property
Doug Anderson2b8db3c2010-11-01 15:08:06 -0700209 def notice(self):
210 self._Load()
211 return self._notice
212
213 @property
Nico Sallembiena1bfd2c2010-04-06 10:40:01 -0700214 def manifest_server(self):
215 self._Load()
216 return self._manifest_server
217
218 @property
Shawn O. Pearcee284ad12008-11-04 07:37:10 -0800219 def IsMirror(self):
220 return self.manifestProject.config.GetBoolean('repo.mirror')
221
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700222 def _Unload(self):
223 self._loaded = False
224 self._projects = {}
225 self._remotes = {}
226 self._default = None
Doug Anderson37282b42011-03-04 11:54:18 -0800227 self._repo_hooks_project = None
Doug Anderson2b8db3c2010-11-01 15:08:06 -0700228 self._notice = None
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700229 self.branch = None
Nico Sallembiena1bfd2c2010-04-06 10:40:01 -0700230 self._manifest_server = None
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700231
232 def _Load(self):
233 if not self._loaded:
Shawn O. Pearce2450a292008-11-04 08:22:07 -0800234 m = self.manifestProject
235 b = m.GetBranch(m.CurrentBranch).merge
Shawn O. Pearce21c5c342009-06-25 16:47:30 -0700236 if b is not None and b.startswith(R_HEADS):
Shawn O. Pearce2450a292008-11-04 08:22:07 -0800237 b = b[len(R_HEADS):]
238 self.branch = b
239
Shawn O. Pearce5cc66792008-10-23 16:19:27 -0700240 self._ParseManifest(True)
241
242 local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME)
243 if os.path.exists(local):
244 try:
245 real = self.manifestFile
246 self.manifestFile = local
247 self._ParseManifest(False)
248 finally:
249 self.manifestFile = real
250
Shawn O. Pearcee284ad12008-11-04 07:37:10 -0800251 if self.IsMirror:
252 self._AddMetaProjectMirror(self.repoProject)
253 self._AddMetaProjectMirror(self.manifestProject)
254
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700255 self._loaded = True
256
Shawn O. Pearce5cc66792008-10-23 16:19:27 -0700257 def _ParseManifest(self, is_root_file):
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700258 root = xml.dom.minidom.parse(self.manifestFile)
259 if not root or not root.childNodes:
Doug Anderson37282b42011-03-04 11:54:18 -0800260 raise ManifestParseError(
261 "no root node in %s" %
262 self.manifestFile)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700263
264 config = root.childNodes[0]
265 if config.nodeName != 'manifest':
Doug Anderson37282b42011-03-04 11:54:18 -0800266 raise ManifestParseError(
267 "no <manifest> in %s" %
268 self.manifestFile)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700269
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700270 for node in config.childNodes:
Shawn O. Pearce03eaf072008-11-20 11:42:22 -0800271 if node.nodeName == 'remove-project':
272 name = self._reqatt(node, 'name')
273 try:
274 del self._projects[name]
275 except KeyError:
Doug Anderson37282b42011-03-04 11:54:18 -0800276 raise ManifestParseError(
277 'project %s not found' %
278 (name))
279
280 # If the manifest removes the hooks project, treat it as if it deleted
281 # the repo-hooks element too.
282 if self._repo_hooks_project and (self._repo_hooks_project.name == name):
283 self._repo_hooks_project = None
Shawn O. Pearce03eaf072008-11-20 11:42:22 -0800284
285 for node in config.childNodes:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700286 if node.nodeName == 'remote':
287 remote = self._ParseRemote(node)
288 if self._remotes.get(remote.name):
Doug Anderson37282b42011-03-04 11:54:18 -0800289 raise ManifestParseError(
290 'duplicate remote %s in %s' %
291 (remote.name, self.manifestFile))
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700292 self._remotes[remote.name] = remote
293
294 for node in config.childNodes:
295 if node.nodeName == 'default':
296 if self._default is not None:
Doug Anderson37282b42011-03-04 11:54:18 -0800297 raise ManifestParseError(
298 'duplicate default in %s' %
299 (self.manifestFile))
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700300 self._default = self._ParseDefault(node)
301 if self._default is None:
302 self._default = _Default()
303
304 for node in config.childNodes:
Doug Anderson2b8db3c2010-11-01 15:08:06 -0700305 if node.nodeName == 'notice':
306 if self._notice is not None:
Doug Anderson37282b42011-03-04 11:54:18 -0800307 raise ManifestParseError(
308 'duplicate notice in %s' %
309 (self.manifestFile))
Doug Anderson2b8db3c2010-11-01 15:08:06 -0700310 self._notice = self._ParseNotice(node)
311
312 for node in config.childNodes:
Nico Sallembiena1bfd2c2010-04-06 10:40:01 -0700313 if node.nodeName == 'manifest-server':
314 url = self._reqatt(node, 'url')
315 if self._manifest_server is not None:
Doug Anderson37282b42011-03-04 11:54:18 -0800316 raise ManifestParseError(
317 'duplicate manifest-server in %s' %
318 (self.manifestFile))
Nico Sallembiena1bfd2c2010-04-06 10:40:01 -0700319 self._manifest_server = url
320
321 for node in config.childNodes:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700322 if node.nodeName == 'project':
323 project = self._ParseProject(node)
324 if self._projects.get(project.name):
Doug Anderson37282b42011-03-04 11:54:18 -0800325 raise ManifestParseError(
326 'duplicate project %s in %s' %
327 (project.name, self.manifestFile))
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700328 self._projects[project.name] = project
329
Doug Anderson37282b42011-03-04 11:54:18 -0800330 for node in config.childNodes:
331 if node.nodeName == 'repo-hooks':
332 # Get the name of the project and the (space-separated) list of enabled.
333 repo_hooks_project = self._reqatt(node, 'in-project')
334 enabled_repo_hooks = self._reqatt(node, 'enabled-list').split()
335
336 # Only one project can be the hooks project
337 if self._repo_hooks_project is not None:
338 raise ManifestParseError(
339 'duplicate repo-hooks in %s' %
340 (self.manifestFile))
341
342 # Store a reference to the Project.
343 try:
344 self._repo_hooks_project = self._projects[repo_hooks_project]
345 except KeyError:
346 raise ManifestParseError(
347 'project %s not found for repo-hooks' %
348 (repo_hooks_project))
349
350 # Store the enabled hooks in the Project object.
351 self._repo_hooks_project.enabled_repo_hooks = enabled_repo_hooks
352
Shawn O. Pearcee284ad12008-11-04 07:37:10 -0800353 def _AddMetaProjectMirror(self, m):
354 name = None
355 m_url = m.GetRemote(m.remote.name).url
356 if m_url.endswith('/.git'):
357 raise ManifestParseError, 'refusing to mirror %s' % m_url
358
359 if self._default and self._default.remote:
360 url = self._default.remote.fetchUrl
361 if not url.endswith('/'):
362 url += '/'
363 if m_url.startswith(url):
364 remote = self._default.remote
365 name = m_url[len(url):]
366
367 if name is None:
368 s = m_url.rindex('/') + 1
Shawn O. Pearced1f70d92009-05-19 14:58:02 -0700369 remote = _XmlRemote('origin', m_url[:s])
Shawn O. Pearcee284ad12008-11-04 07:37:10 -0800370 name = m_url[s:]
371
372 if name.endswith('.git'):
373 name = name[:-4]
374
375 if name not in self._projects:
376 m.PreSync()
377 gitdir = os.path.join(self.topdir, '%s.git' % name)
378 project = Project(manifest = self,
379 name = name,
Shawn O. Pearced1f70d92009-05-19 14:58:02 -0700380 remote = remote.ToRemoteSpec(name),
Shawn O. Pearcee284ad12008-11-04 07:37:10 -0800381 gitdir = gitdir,
382 worktree = None,
383 relpath = None,
Shawn O. Pearce3c8dea12009-05-29 18:38:17 -0700384 revisionExpr = m.revisionExpr,
385 revisionId = None)
Shawn O. Pearcee284ad12008-11-04 07:37:10 -0800386 self._projects[project.name] = project
387
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700388 def _ParseRemote(self, node):
389 """
390 reads a <remote> element from the manifest file
391 """
392 name = self._reqatt(node, 'name')
393 fetch = self._reqatt(node, 'fetch')
394 review = node.getAttribute('review')
Shawn O. Pearceae6e0942008-11-06 10:25:35 -0800395 if review == '':
396 review = None
Shawn O. Pearced1f70d92009-05-19 14:58:02 -0700397 return _XmlRemote(name, fetch, review)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700398
399 def _ParseDefault(self, node):
400 """
401 reads a <default> element from the manifest file
402 """
403 d = _Default()
404 d.remote = self._get_remote(node)
Shawn O. Pearce3c8dea12009-05-29 18:38:17 -0700405 d.revisionExpr = node.getAttribute('revision')
406 if d.revisionExpr == '':
407 d.revisionExpr = None
Shawn O. Pearce6392c872011-09-22 17:44:31 -0700408 sync_j = node.getAttribute('sync-j')
409 if sync_j == '' or sync_j is None:
410 d.sync_j = 1
411 else:
412 d.sync_j = int(sync_j)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700413 return d
414
Doug Anderson2b8db3c2010-11-01 15:08:06 -0700415 def _ParseNotice(self, node):
416 """
417 reads a <notice> element from the manifest file
418
419 The <notice> element is distinct from other tags in the XML in that the
420 data is conveyed between the start and end tag (it's not an empty-element
421 tag).
422
423 The white space (carriage returns, indentation) for the notice element is
424 relevant and is parsed in a way that is based on how python docstrings work.
425 In fact, the code is remarkably similar to here:
426 http://www.python.org/dev/peps/pep-0257/
427 """
428 # Get the data out of the node...
429 notice = node.childNodes[0].data
430
431 # Figure out minimum indentation, skipping the first line (the same line
432 # as the <notice> tag)...
433 minIndent = sys.maxint
434 lines = notice.splitlines()
435 for line in lines[1:]:
436 lstrippedLine = line.lstrip()
437 if lstrippedLine:
438 indent = len(line) - len(lstrippedLine)
439 minIndent = min(indent, minIndent)
440
441 # Strip leading / trailing blank lines and also indentation.
442 cleanLines = [lines[0].strip()]
443 for line in lines[1:]:
444 cleanLines.append(line[minIndent:].rstrip())
445
446 # Clear completely blank lines from front and back...
447 while cleanLines and not cleanLines[0]:
448 del cleanLines[0]
449 while cleanLines and not cleanLines[-1]:
450 del cleanLines[-1]
451
452 return '\n'.join(cleanLines)
453
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700454 def _ParseProject(self, node):
455 """
456 reads a <project> element from the manifest file
Nico Sallembiena1bfd2c2010-04-06 10:40:01 -0700457 """
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700458 name = self._reqatt(node, 'name')
459
460 remote = self._get_remote(node)
461 if remote is None:
462 remote = self._default.remote
463 if remote is None:
464 raise ManifestParseError, \
465 "no remote for project %s within %s" % \
466 (name, self.manifestFile)
467
Shawn O. Pearce3c8dea12009-05-29 18:38:17 -0700468 revisionExpr = node.getAttribute('revision')
469 if not revisionExpr:
470 revisionExpr = self._default.revisionExpr
471 if not revisionExpr:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700472 raise ManifestParseError, \
473 "no revision for project %s within %s" % \
474 (name, self.manifestFile)
475
476 path = node.getAttribute('path')
477 if not path:
478 path = name
479 if path.startswith('/'):
480 raise ManifestParseError, \
481 "project %s path cannot be absolute in %s" % \
482 (name, self.manifestFile)
483
Shawn O. Pearcee284ad12008-11-04 07:37:10 -0800484 if self.IsMirror:
485 relpath = None
486 worktree = None
487 gitdir = os.path.join(self.topdir, '%s.git' % name)
488 else:
Anthony Newnamdf14a702011-01-09 17:31:57 -0800489 worktree = os.path.join(self.topdir, path).replace('\\', '/')
Shawn O. Pearcee284ad12008-11-04 07:37:10 -0800490 gitdir = os.path.join(self.repodir, 'projects/%s.git' % path)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700491
492 project = Project(manifest = self,
493 name = name,
Shawn O. Pearced1f70d92009-05-19 14:58:02 -0700494 remote = remote.ToRemoteSpec(name),
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700495 gitdir = gitdir,
496 worktree = worktree,
497 relpath = path,
Shawn O. Pearce3c8dea12009-05-29 18:38:17 -0700498 revisionExpr = revisionExpr,
499 revisionId = None)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700500
501 for n in node.childNodes:
Shawn O. Pearce242b5262009-05-19 13:00:29 -0700502 if n.nodeName == 'copyfile':
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700503 self._ParseCopyFile(project, n)
504
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700505 return project
506
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700507 def _ParseCopyFile(self, project, node):
508 src = self._reqatt(node, 'src')
509 dest = self._reqatt(node, 'dest')
Shawn O. Pearcee284ad12008-11-04 07:37:10 -0800510 if not self.IsMirror:
511 # src is project relative;
512 # dest is relative to the top of the tree
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800513 project.AddCopyFile(src, dest, os.path.join(self.topdir, dest))
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700514
515 def _get_remote(self, node):
516 name = node.getAttribute('remote')
517 if not name:
518 return None
519
520 v = self._remotes.get(name)
521 if not v:
522 raise ManifestParseError, \
523 "remote %s not defined in %s" % \
524 (name, self.manifestFile)
525 return v
526
527 def _reqatt(self, node, attname):
528 """
529 reads a required attribute from the node.
530 """
531 v = node.getAttribute(attname)
532 if not v:
533 raise ManifestParseError, \
534 "no %s in <%s> within %s" % \
535 (attname, node.nodeName, self.manifestFile)
536 return v