|
74 | 74 | *version_type*, for which it reports the checksum of the archive as the *version*. |
75 | 75 |
|
76 | 76 | The versions extracted from the Cargo.lock at tracking time are used to report the *guess_version*. |
| 77 | +
|
| 78 | +Additional source info can be specified using the `provenance` field for each referenced crate as per |
| 79 | +`built-in source provenance documentation |
| 80 | +<https://docs.buildstream.build/master/buildstream.source.html#built-in-functionality>`_. |
77 | 81 | """ |
78 | 82 |
|
79 | 83 | import json |
|
125 | 129 | # sha (str|None): The sha256 checksum of the downloaded crate |
126 | 130 | # |
127 | 131 | class Crate(SourceFetcher): |
128 | | - def __init__(self, cargo, name, version, sha=None): |
| 132 | + def __init__(self, cargo, name, version, sha=None, provenance=None): |
129 | 133 | super().__init__() |
130 | 134 |
|
131 | 135 | self.cargo = cargo |
132 | 136 | self.name = name |
133 | 137 | self.version = str(version) |
134 | 138 | self.sha = sha |
| 139 | + self.provenance = provenance |
135 | 140 | self.mark_download_url(cargo.url) |
136 | 141 |
|
137 | 142 | ######################################################## |
@@ -159,7 +164,12 @@ def fetch(self, alias_override=None, **kwargs): |
159 | 164 | def get_source_info(self): |
160 | 165 | url, _ = self._get_url() |
161 | 166 | return self.cargo.create_source_info( |
162 | | - url, SourceInfoMedium.REMOTE_FILE, SourceVersionType.SHA256, self.sha, version_guess=self.version |
| 167 | + url, |
| 168 | + SourceInfoMedium.REMOTE_FILE, |
| 169 | + SourceVersionType.SHA256, |
| 170 | + self.sha, |
| 171 | + version_guess=self.version, |
| 172 | + provenance_node=self.provenance, |
163 | 173 | ) |
164 | 174 |
|
165 | 175 | ######################################################## |
@@ -368,6 +378,8 @@ class CargoSource(Source): |
368 | 378 | # We need the Cargo.lock file to construct our ref at track time |
369 | 379 | BST_REQUIRES_PREVIOUS_SOURCES_TRACK = True |
370 | 380 |
|
| 381 | + BST_CUSTOM_SOURCE_PROVENANCE = True |
| 382 | + |
371 | 383 | ######################################################## |
372 | 384 | # Plugin/Source API method implementations # |
373 | 385 | ######################################################## |
@@ -513,6 +525,7 @@ def _parse_crates(self, refs): |
513 | 525 | crate.get_str("name"), |
514 | 526 | crate.get_str("version"), |
515 | 527 | sha=crate.get_str("sha", None), |
| 528 | + provenance=crate.get_mapping("provenance", None), |
516 | 529 | ) |
517 | 530 | for crate in refs |
518 | 531 | ] |
|
0 commit comments