Add support for multiple local manifests

Add support for multiple local manifests stored in the local_manifests
folder under the .repo home directory.

Local manifests will be processed in addition to local_manifest.xml.

Change-Id: Ia0569cea7e9ae0fe3208a8ffef5d9679e14db03b
This commit is contained in:
David Pursehouse 2012-11-13 02:50:36 +09:00
parent f7fc8a95be
commit 2d5a0df798
2 changed files with 26 additions and 7 deletions

View File

@ -224,15 +224,19 @@ Attribute `name`; the manifest to include, specified relative to
the manifest repositories root. the manifest repositories root.
Local Manifest Local Manifests
============== ===============
Additional remotes and projects may be added through a local Additional remotes and projects may be added through local manifest
manifest, stored in `$TOP_DIR/.repo/local_manifest.xml`. files stored in `$TOP_DIR/.repo/local_manifests/*.xml`.
For example: For example:
$ cat .repo/local_manifest.xml $ ls .repo/local_manifests
local_manifest.xml
another_local_manifest.xml
$ cat .repo/local_manifests/local_manifest.xml
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<manifest> <manifest>
<project path="manifest" <project path="manifest"
@ -241,6 +245,9 @@ For example:
name="platform/manifest" /> name="platform/manifest" />
</manifest> </manifest>
Users may add projects to the local manifest prior to a `repo sync` Users may add projects to the local manifest(s) prior to a `repo sync`
invocation, instructing repo to automatically download and manage invocation, instructing repo to automatically download and manage
these extra projects. these extra projects.
Additional remotes and projects may also be added through a local
manifest, stored in `$TOP_DIR/.repo/local_manifest.xml`.

View File

@ -27,6 +27,7 @@ from error import ManifestParseError
MANIFEST_FILE_NAME = 'manifest.xml' MANIFEST_FILE_NAME = 'manifest.xml'
LOCAL_MANIFEST_NAME = 'local_manifest.xml' LOCAL_MANIFEST_NAME = 'local_manifest.xml'
LOCAL_MANIFESTS_DIR_NAME = 'local_manifests'
urlparse.uses_relative.extend(['ssh', 'git']) urlparse.uses_relative.extend(['ssh', 'git'])
urlparse.uses_netloc.extend(['ssh', 'git']) urlparse.uses_netloc.extend(['ssh', 'git'])
@ -301,6 +302,17 @@ class XmlManifest(object):
if os.path.exists(local): if os.path.exists(local):
nodes.append(self._ParseManifestXml(local, self.repodir)) nodes.append(self._ParseManifestXml(local, self.repodir))
local_dir = os.path.abspath(os.path.join(self.repodir, LOCAL_MANIFESTS_DIR_NAME))
try:
for local_file in os.listdir(local_dir):
if local_file.endswith('.xml'):
try:
nodes.append(self._ParseManifestXml(local_file, self.repodir))
except ManifestParseError as e:
print >>sys.stderr, '%s' % str(e)
except OSError:
pass
self._ParseManifest(nodes) self._ParseManifest(nodes)
if self.IsMirror: if self.IsMirror:
@ -312,7 +324,7 @@ class XmlManifest(object):
def _ParseManifestXml(self, path, include_root): def _ParseManifestXml(self, path, include_root):
try: try:
root = xml.dom.minidom.parse(path) root = xml.dom.minidom.parse(path)
except (OSError, xml.parsers.expat.ExpatError), e: except (OSError, xml.parsers.expat.ExpatError) as e:
raise ManifestParseError("error parsing manifest %s: %s" % (path, e)) raise ManifestParseError("error parsing manifest %s: %s" % (path, e))
if not root or not root.childNodes: if not root or not root.childNodes: