Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/nixguix/loader.py
Show All 35 Lines | class NixGuixLoader(PackageLoader): | ||||
""" | """ | ||||
visit_type = 'nixguix' | visit_type = 'nixguix' | ||||
def __init__(self, url): | def __init__(self, url): | ||||
super().__init__(url=url) | super().__init__(url=url) | ||||
s = retrieve_sources(url) | s = retrieve_sources(url) | ||||
self.sources = s['sources'] | self.sources = s['sources'] | ||||
self.provider_url = url | self.provider_url = url | ||||
self._integrityByUrl = {s['url'][0]: s['integrity'] | |||||
for s in self.sources} | |||||
# The revision used to create the sources.json file. For Nix, | # The revision used to create the sources.json file. For Nix, | ||||
# this revision belongs to the github.com/nixos/nixpkgs | # this revision belongs to the github.com/nixos/nixpkgs | ||||
# repository | # repository | ||||
self.revision = s['revision'] | self.revision = s['revision'] | ||||
# Note: this could be renamed get_artifacts in the PackageLoader | # Note: this could be renamed get_artifacts in the PackageLoader | ||||
# base class. | # base class. | ||||
def get_versions(self): | def get_versions(self): | ||||
"""The first mirror of the mirror list is used as branch name in the | |||||
snapshot. | |||||
""" | |||||
return self._integrityByUrl.keys() | |||||
# Note: this could be renamed get_artifact_info in the PackageLoader | |||||
# base class. | |||||
def get_package_info(self, url): | |||||
# TODO: try all mirrors and not only the first one. A source | # TODO: try all mirrors and not only the first one. A source | ||||
# can be fetched from several urls, called mirrors. We | # can be fetched from several urls, called mirrors. We | ||||
# currently only use the first one, but if the first one | # currently only use the first one, but if the first one | ||||
# fails, we should try the second one and so on. | # fails, we should try the second one and so on. | ||||
return [s['url'][0] for s in self.sources] | integrity = self._integrityByUrl[url] | ||||
yield url, {'url': url, | |||||
# Note: this could be renamed get_artifact_info in the PackageLoader | 'raw': { | ||||
# base class. | 'url': url, | ||||
def get_package_info(self, source): | 'integrity': integrity}} | ||||
# TODO: we need to provide the sha256 of the source also | |||||
yield source, {'url': source, 'raw': {'url': source}} | |||||
def resolve_revision_from( | def resolve_revision_from( | ||||
self, known_artifacts: Dict, artifact_metadata: Dict) \ | self, known_artifacts: Dict, artifact_metadata: Dict) \ | ||||
-> Optional[bytes]: | -> Optional[bytes]: | ||||
for rev_id, known_artifact in known_artifacts.items(): | for rev_id, known_artifact in known_artifacts.items(): | ||||
known_url = known_artifact['extrinsic']['raw']['url'] | known_integrity = known_artifact['extrinsic']['raw']['integrity'] | ||||
if artifact_metadata['url'] == known_url: | if artifact_metadata['integrity'] == known_integrity: | ||||
return rev_id | return rev_id | ||||
ardumont: I would expect the coverage to currently be green here... | |||||
Done Inline ActionsI locally put a breakpoint line 82 and the breakpoint has been reached. So, this code is executed by the test test_loader_incremental. lewo: I locally put a breakpoint line 82 and the breakpoint has been reached. So, this code is… | |||||
return None | return None | ||||
def extra_branches(self) -> Dict[bytes, Mapping[str, Any]]: | def extra_branches(self) -> Dict[bytes, Mapping[str, Any]]: | ||||
"""We add a branch to the snapshot called 'evaluation' pointing to the | """We add a branch to the snapshot called 'evaluation' pointing to the | ||||
revision used to generate the sources.json file. This revision | revision used to generate the sources.json file. This revision | ||||
is specified in the sources.json file itself. For the nixpkgs | is specified in the sources.json file itself. For the nixpkgs | ||||
origin, this revision is coming from the | origin, this revision is coming from the | ||||
github.com/nixos/nixpkgs repository. | github.com/nixos/nixpkgs repository. | ||||
Show All 37 Lines |
I would expect the coverage to currently be green here...