From 5d3291d818ba479afc112370e3c5fc2dc0587d6e Mon Sep 17 00:00:00 2001 From: LaMont Jones <lamontjones@google.com> Date: Wed, 23 Mar 2022 19:03:02 +0000 Subject: [PATCH] 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> --- manifest_xml.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/manifest_xml.py b/manifest_xml.py index fa3e1034..a14cc526 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -237,8 +237,13 @@ class _XmlSubmanifest: 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 @@ class XmlManifest(object): 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