diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-09-02 17:41:56 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-09-02 18:37:12 +0900 |
commit | 1f9c41476313614aec4f0444f0eef6055cf3cb14 (patch) | |
tree | dded059aace75bed66b68170b6c4169bece3f0ec /buildstream/plugins/sources | |
parent | 16462e9cd2007ae9e90fd94a7af5ba4c142cf83e (diff) | |
download | buildstream-1f9c41476313614aec4f0444f0eef6055cf3cb14.tar.gz |
source.py: Added `primary` argument to URL marking APIs
The Source must now mention whether the marked or translated
URL is "primary" or not. Even when a Source may have multiple
URLs, the auxilliary URLs are derived from the primary one, not
only is this true for git, but it is mandated by our tracking
API which assumes there is a primary URL.
This adjusts the `git` source and the test `fetch_source.py` source
to behave properly and advertize it's primary URL properly.
This is a part of #620
Diffstat (limited to 'buildstream/plugins/sources')
-rw-r--r-- | buildstream/plugins/sources/git.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py index da5563782..f45a23bfc 100644 --- a/buildstream/plugins/sources/git.py +++ b/buildstream/plugins/sources/git.py @@ -100,13 +100,14 @@ INCONSISTENT_SUBMODULE = "inconsistent-submodules" # class GitMirror(SourceFetcher): - def __init__(self, source, path, url, ref): + def __init__(self, source, path, url, ref, *, primary=False): super().__init__() self.source = source self.path = path self.url = url self.ref = ref + self.primary = primary self.mirror = os.path.join(source.get_mirror_directory(), utils.url_directory_name(url)) self.mark_download_url(url) @@ -124,7 +125,8 @@ class GitMirror(SourceFetcher): # system configured tmpdir is not on the same partition. # with self.source.tempdir() as tmpdir: - url = self.source.translate_url(self.url, alias_override=alias_override) + url = self.source.translate_url(self.url, alias_override=alias_override, + primary=self.primary) self.source.call([self.source.host_git, 'clone', '--mirror', '-n', url, tmpdir], fail="Failed to clone git repository {}".format(url), fail_temporarily=True) @@ -146,7 +148,9 @@ class GitMirror(SourceFetcher): .format(self.source, url, tmpdir, self.mirror, e)) from e def _fetch(self, alias_override=None): - url = self.source.translate_url(self.url, alias_override=alias_override) + url = self.source.translate_url(self.url, + alias_override=alias_override, + primary=self.primary) if alias_override: remote_name = utils.url_directory_name(alias_override) @@ -307,7 +311,7 @@ class GitSource(Source): self.node_validate(node, config_keys + Source.COMMON_CONFIG_KEYS) self.original_url = self.node_get_member(node, str, 'url') - self.mirror = GitMirror(self, '', self.original_url, ref) + self.mirror = GitMirror(self, '', self.original_url, ref, primary=True) self.tracking = self.node_get_member(node, str, 'track', None) # At this point we now know if the source has a ref and/or a track. @@ -327,6 +331,11 @@ class GitSource(Source): for path, _ in self.node_items(modules): submodule = self.node_get_member(modules, Mapping, path) url = self.node_get_member(submodule, str, 'url', None) + + # Make sure to mark all URLs that are specified in the configuration + if url: + self.mark_download_url(url, primary=False) + self.submodule_overrides[path] = url if 'checkout' in submodule: checkout = self.node_get_member(submodule, bool, 'checkout') |