@@ -759,6 +759,14 @@ class Source(Plugin):
759759 # The defaults from the project
760760 __defaults : Optional [Dict [str , Any ]] = None
761761
762+ BST_CUSTOM_SOURCE_PROVENANCE = False
763+ """Whether multiple sources' provenance information are provided
764+
765+ Used primarily to override the usage of top-level source
766+ provenance of a source where individual sub-source's
767+ provenance should instead be provided
768+ """
769+
762770 BST_REQUIRES_PREVIOUS_SOURCES_TRACK = False
763771 """Whether access to previous sources is required during track
764772
@@ -828,6 +836,12 @@ def __init__(
828836 _SourceProvenance
829837 ] = meta .provenance # The _SourceProvenance for general user provided SourceInfo
830838
839+ if self .__provenance is not None and self .BST_CUSTOM_SOURCE_PROVENANCE :
840+ raise SourceError (
841+ f"{ self ._get_provenance ()} Custom source provenance plugin: Refusing to use top level source provenance" ,
842+ reason = "top-level-provenance-on-custom-implementation" ,
843+ )
844+
831845 self .__key = None # Cache key for source
832846
833847 # The alias_override is only set on a re-instantiated Source
@@ -1368,6 +1382,7 @@ def create_source_info(
13681382 * ,
13691383 version_guess : Optional [str ] = None ,
13701384 extra_data : Optional [Dict [str , str ]] = None ,
1385+ provenance_node : Optional [MappingNode ] = None ,
13711386 ) -> SourceInfo :
13721387 """Create a :class:`.SourceInfo` object
13731388
@@ -1387,14 +1402,22 @@ def create_source_info(
13871402 version: A string which represents a unique version of this source input
13881403 version_guess: An optional string representing the guessed human readable version
13891404 extra_data: Additional plugin defined key/values
1405+ provenance_node: An optional :class:`Node <buildstream.node.Node>` with source provenance attributes,
1406+ defaults to the provenance specified at the top level of the source.
13901407
13911408 *Since: 2.5*
13921409 """
13931410 homepage = None
13941411 issue_tracker = None
1395- if self .__provenance is not None :
1396- homepage = self .__provenance .homepage
1397- issue_tracker = self .__provenance .issue_tracker
1412+
1413+ if provenance_node is not None :
1414+ source_provenance : Optional [_SourceProvenance ] = _SourceProvenance .new_from_node (provenance_node )
1415+ else :
1416+ source_provenance = self .__provenance
1417+
1418+ if source_provenance is not None :
1419+ homepage = source_provenance .homepage
1420+ issue_tracker = source_provenance .issue_tracker
13981421
13991422 return SourceInfo (
14001423 self .get_kind (),
0 commit comments