manifest_file must be an absolute path
Correctly pass the full path of the manifest file for the submanifest.
The manifest-name in the <submanifest/> element was being passed in
as given, which caused it to not be found since the current directory
never set. (b/226333721: fails when manifest-name is given.)
Also verify that the manifest_file passed to XmlManifest() is an
absolute path.
Bug: https://b.corp.google.com/issues/226333721
Change-Id: I23461078233e34562bc2eafeb732cfe8bd38ddc1
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/333861
Tested-by: LaMont Jones <lamontjones@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
diff --git a/manifest_xml.py b/manifest_xml.py
index fa3e103..a14cc52 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -237,8 +237,13 @@
if self.remote and not self.project:
raise ManifestParseError(
f'Submanifest {name}: must specify project when remote is given.')
+ # Construct the absolute path to the manifest file using the parent's
+ # method, so that we can correctly create our repo_client.
+ manifestFile = parent.SubmanifestInfoDir(
+ os.path.join(parent.path_prefix, self.relpath),
+ os.path.join('manifests', manifestName or 'default.xml'))
rc = self.repo_client = RepoClient(
- parent.repodir, manifestName, parent_groups=','.join(groups) or '',
+ parent.repodir, manifestFile, parent_groups=','.join(groups) or '',
submanifest_path=self.relpath, outer_client=outer_client)
self.present = os.path.exists(os.path.join(self.repo_client.subdir,
@@ -337,6 +342,8 @@
self.repodir = os.path.abspath(repodir)
self._CheckLocalPath(submanifest_path)
self.topdir = os.path.join(os.path.dirname(self.repodir), submanifest_path)
+ if manifest_file != os.path.abspath(manifest_file):
+ raise ManifestParseError('manifest_file must be abspath')
self.manifestFile = manifest_file
self.local_manifests = local_manifests
self._load_local_manifests = True