summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2018-06-06 18:32:15 +0100
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-07-29 17:12:42 +0900
commit8a9fd8e1f757ebde1e8b417240c15d35c00ae3aa (patch)
tree31942e80975abb33cc291b308de292b2d768f3a7
parent590b0b47da0a6b604ab9b647bcff842815862074 (diff)
downloadbuildstream-8a9fd8e1f757ebde1e8b417240c15d35c00ae3aa.tar.gz
Add mirrored source tracking
-rw-r--r--buildstream/source.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/buildstream/source.py b/buildstream/source.py
index e0fa5918d..548692cf4 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -736,7 +736,7 @@ class Source(Plugin):
# Wrapper for track()
#
def _track(self):
- new_ref = self.track()
+ new_ref = self.__do_track()
current_ref = self.get_ref()
if new_ref is None:
@@ -763,6 +763,33 @@ class Source(Plugin):
# Local Private Methods #
#############################################################
+ # Tries to call track for every mirror, stopping once it succeeds
+ def __do_track(self):
+ project = self._get_project()
+ # If there are no mirrors, or no aliases to replace, there's nothing to do here.
+ alias = self._get_alias()
+ if not project.mirrors or not alias:
+ return self.track()
+
+ context = self._get_context()
+ source_kind = type(self)
+
+ # NOTE: We are assuming here that tracking only requires substituting the
+ # first alias used
+ for uri in reversed(project.get_alias_uris(alias)):
+ new_source = source_kind(context, project, self.__meta,
+ alias_override=(alias, uri))
+ new_source._preflight()
+ try:
+ ref = new_source.track()
+ # FIXME: Need to consider temporary vs. permanent failures,
+ # and how this works with retries.
+ except BstError as e:
+ last_error = e
+ continue
+ return ref
+ raise last_error
+
# Ensures a fully constructed path and returns it
def __ensure_directory(self, directory):