... |
... |
@@ -137,6 +137,7 @@ from . import Plugin |
137
|
137
|
from . import _yaml, utils
|
138
|
138
|
from ._exceptions import BstError, ImplError, ErrorDomain
|
139
|
139
|
from ._projectrefs import ProjectRefStorage
|
|
140
|
+from .plugin import CoreWarnings
|
140
|
141
|
|
141
|
142
|
|
142
|
143
|
class Consistency():
|
... |
... |
@@ -219,9 +220,7 @@ class SourceFetcher(): |
219
|
220
|
Args:
|
220
|
221
|
url (str): The url used to download.
|
221
|
222
|
"""
|
222
|
|
- # Not guaranteed to be a valid alias yet.
|
223
|
|
- # Ensuring it's a valid alias currently happens in Project.get_alias_uris
|
224
|
|
- alias, _ = url.split(utils._ALIAS_SEPARATOR, 1)
|
|
223
|
+ alias = url.split(utils._ALIAS_SEPARATOR, 1)[0]
|
225
|
224
|
self.__alias = alias
|
226
|
225
|
|
227
|
226
|
#############################################################
|
... |
... |
@@ -459,8 +458,8 @@ class Source(Plugin): |
459
|
458
|
|
460
|
459
|
*Since: 1.2*
|
461
|
460
|
"""
|
462
|
|
- alias, _ = url.split(utils._ALIAS_SEPARATOR, 1)
|
463
|
|
- self.__expected_alias = alias
|
|
461
|
+ url_alias = url.split(utils._ALIAS_SEPARATOR, 1)[0]
|
|
462
|
+ self.__expected_alias = url_alias
|
464
|
463
|
|
465
|
464
|
def get_source_fetchers(self):
|
466
|
465
|
"""Get the objects that are used for fetching
|
... |
... |
@@ -505,6 +504,7 @@ class Source(Plugin): |
505
|
504
|
Returns:
|
506
|
505
|
str: The fully qualified url, with aliases resolved
|
507
|
506
|
"""
|
|
507
|
+ self.__validate_raw_url(url)
|
508
|
508
|
# Alias overriding can happen explicitly (by command-line) or
|
509
|
509
|
# implicitly (the Source being constructed with an __alias_override).
|
510
|
510
|
if alias_override or self.__alias_override:
|
... |
... |
@@ -525,8 +525,7 @@ class Source(Plugin): |
525
|
525
|
else:
|
526
|
526
|
# Sneakily store the alias if it hasn't already been stored
|
527
|
527
|
if not self.__expected_alias and url and utils._ALIAS_SEPARATOR in url:
|
528
|
|
- url_alias, _ = url.split(utils._ALIAS_SEPARATOR, 1)
|
529
|
|
- self.__expected_alias = url_alias
|
|
528
|
+ self.mark_download_url(url)
|
530
|
529
|
|
531
|
530
|
project = self._get_project()
|
532
|
531
|
return project.translate_url(url, first_pass=self.__first_pass)
|
... |
... |
@@ -988,3 +987,23 @@ class Source(Plugin): |
988
|
987
|
|
989
|
988
|
if src.get_consistency() == Consistency.RESOLVED:
|
990
|
989
|
src._fetch(previous_sources[0:index])
|
|
990
|
+
|
|
991
|
+ # __validate_raw_url():
|
|
992
|
+ #
|
|
993
|
+ # Validates a url prior to url substitution.
|
|
994
|
+ # This checks the url and produces warnings.
|
|
995
|
+ #
|
|
996
|
+ def __validate_raw_url(self, url):
|
|
997
|
+ url_parts = url.split(utils._ALIAS_SEPARATOR, 1)
|
|
998
|
+ alias = url_parts[0]
|
|
999
|
+
|
|
1000
|
+ # Check and warn when detecting no valid alias.
|
|
1001
|
+ project = self._get_project()
|
|
1002
|
+ if alias.lower() in utils._URI_SCHEMES:
|
|
1003
|
+ self.warn("{}: The use of an alias in urls is strongly advised.".format(self._get_provenance()),
|
|
1004
|
+ detail="See https://buildstream.gitlab.io/buildstream/format_project.html#source-aliases",
|
|
1005
|
+ warning_token=CoreWarnings.URL_WITHOUT_ALIAS)
|
|
1006
|
+
|
|
1007
|
+ elif not project.get_alias_uri(alias, first_pass=self.__first_pass) and len(url_parts) > 1:
|
|
1008
|
+ self.warn("{}: Unknown alias '{}' in url".format(self._get_provenance(), alias),
|
|
1009
|
+ warning_token=CoreWarnings.UNKNOWN_ALIAS)
|