diff options
| author | LaMont Jones <lamontjones@google.com> | 2022-03-23 19:03:02 +0000 |
|---|---|---|
| committer | LaMont Jones <lamontjones@google.com> | 2022-03-23 21:18:41 +0000 |
| commit | 5d3291d818ba479afc112370e3c5fc2dc0587d6e (patch) | |
| tree | a03279e41fa518d1113c52642e0ac80a890b78dc | |
| parent | 244c9a71a689743acea97c6a07ff4dfce4dc6dab (diff) | |
| download | git-repo-5d3291d818ba479afc112370e3c5fc2dc0587d6e.tar.gz | |
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>
| -rw-r--r-- | manifest_xml.py | 9 |
1 files changed, 8 insertions, 1 deletions
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: | |||
| 237 | if self.remote and not self.project: | 237 | if self.remote and not self.project: |
| 238 | raise ManifestParseError( | 238 | raise ManifestParseError( |
| 239 | f'Submanifest {name}: must specify project when remote is given.') | 239 | f'Submanifest {name}: must specify project when remote is given.') |
| 240 | # Construct the absolute path to the manifest file using the parent's | ||
| 241 | # method, so that we can correctly create our repo_client. | ||
| 242 | manifestFile = parent.SubmanifestInfoDir( | ||
| 243 | os.path.join(parent.path_prefix, self.relpath), | ||
| 244 | os.path.join('manifests', manifestName or 'default.xml')) | ||
| 240 | rc = self.repo_client = RepoClient( | 245 | rc = self.repo_client = RepoClient( |
| 241 | parent.repodir, manifestName, parent_groups=','.join(groups) or '', | 246 | parent.repodir, manifestFile, parent_groups=','.join(groups) or '', |
| 242 | submanifest_path=self.relpath, outer_client=outer_client) | 247 | submanifest_path=self.relpath, outer_client=outer_client) |
| 243 | 248 | ||
| 244 | self.present = os.path.exists(os.path.join(self.repo_client.subdir, | 249 | self.present = os.path.exists(os.path.join(self.repo_client.subdir, |
| @@ -337,6 +342,8 @@ class XmlManifest(object): | |||
| 337 | self.repodir = os.path.abspath(repodir) | 342 | self.repodir = os.path.abspath(repodir) |
| 338 | self._CheckLocalPath(submanifest_path) | 343 | self._CheckLocalPath(submanifest_path) |
| 339 | self.topdir = os.path.join(os.path.dirname(self.repodir), submanifest_path) | 344 | self.topdir = os.path.join(os.path.dirname(self.repodir), submanifest_path) |
| 345 | if manifest_file != os.path.abspath(manifest_file): | ||
| 346 | raise ManifestParseError('manifest_file must be abspath') | ||
| 340 | self.manifestFile = manifest_file | 347 | self.manifestFile = manifest_file |
| 341 | self.local_manifests = local_manifests | 348 | self.local_manifests = local_manifests |
| 342 | self._load_local_manifests = True | 349 | self._load_local_manifests = True |
