You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ak...@apache.org on 2024/03/07 14:55:56 UTC
(buildstream) branch abderrahim/toplevel-mirror created (now 94bd730da)
This is an automated email from the ASF dual-hosted git repository.
akitouni pushed a change to branch abderrahim/toplevel-mirror
in repository https://gitbox.apache.org/repos/asf/buildstream.git
at 94bd730da Allow toplevel project to override mirrors for subprojects
This branch includes the following new commits:
new 94bd730da Allow toplevel project to override mirrors for subprojects
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(buildstream) 01/01: Allow toplevel project to override mirrors for subprojects
Posted by ak...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
akitouni pushed a commit to branch abderrahim/toplevel-mirror
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 94bd730da75858f49d45e28d59af8102c2a47342
Author: Abderrahim Kitouni <ab...@codethink.co.uk>
AuthorDate: Thu Mar 7 15:54:07 2024 +0100
Allow toplevel project to override mirrors for subprojects
Previously, only the user configuration could override mirrors
---
src/buildstream/_project.py | 24 +++++++++++++++++++-----
src/buildstream/types.py | 4 ++++
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index 1a1054898..f7149f8c5 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -400,8 +400,8 @@ class Project:
policy = self._context.track_source if tracking else self._context.fetch_source
if policy in (_SourceUriPolicy.ALL, _SourceUriPolicy.MIRRORS) or (
- policy == _SourceUriPolicy.USER and self._mirror_override
- ):
+ policy == _SourceUriPolicy.USER and self._user_mirror_override
+ ) or (policy == _SourceUriPolicy.TOPLEVEL and self._toplevel_mirror_override):
for mirror_name, mirror in config.mirrors.items():
if alias in mirror.aliases:
if mirror_name == config.default_mirror:
@@ -641,6 +641,7 @@ class Project:
"sources",
"source-caches",
"junctions",
+ "projects",
"(@)",
"(?)",
]
@@ -1011,15 +1012,28 @@ class Project:
# Override default_mirror if not set by command-line
output.default_mirror = self._default_mirror or overrides.get_str("default-mirror", default=None)
+ if self == toplevel_project:
+ self.project_overrides = config.get_mapping("projects", default={})
+
# First try mirrors specified in user configuration, user configuration
# is allowed to completely disable mirrors by specifying an empty list,
# so we check for a None value here too.
#
mirrors_node = overrides.get_sequence("mirrors", default=None)
- if mirrors_node is None:
- mirrors_node = config.get_sequence("mirrors", default=[])
+
+ toplevel_override_node = toplevel_project.project_overrides.get_mapping(self.name, default={})
+
+ user_mirror_overrides = overrides.get_sequence("mirrors", default=None)
+ toplevel_mirror_overrides = toplevel_override_node.get_sequence("mirrors", default=None)
+
+ if user_mirror_overrides is not None:
+ mirrors_node = user_mirror_overrides
+ self._user_mirror_override = True
+ elif toplevel_mirror_overrides is not None:
+ mirrors_node = toplevel_mirror_overrides
+ self._toplevel_mirror_override = True
else:
- self._mirror_override = True
+ mirrors_node = config.get_sequence("mirrors", default=[])
# Perform variable substitutions in source mirror definitions,
# even if the mirrors are specified in user configuration.
diff --git a/src/buildstream/types.py b/src/buildstream/types.py
index 778941768..eef5885ee 100644
--- a/src/buildstream/types.py
+++ b/src/buildstream/types.py
@@ -274,6 +274,10 @@ class _SourceUriPolicy(FastEnum):
# configuration has not provided a mirror
USER = "user"
+ # Use only URIs defined in the toplevel project (the project on which
+ # BuildStream was invoked with as opposed to a junctioned subproject.
+ TOPLEVEL = "toplevel"
+
# _PipelineSelection()
#