diff --git a/app/appstate.py b/app/appstate.py index 145203d..5d0efa9 100644 --- a/app/appstate.py +++ b/app/appstate.py @@ -26,8 +26,16 @@ PackageKey = tuple[str, str, str, str, str] class ExtId(NamedTuple): id: str + """Internal ID""" + name: str - fallback: bool + """Display name of the external system""" + + fallback_only: bool + """Only use this as a fallback if no other match is found""" + + guess_name: bool + """Guess the external package name, if none is explicitely specified""" class ExtInfo(NamedTuple): @@ -527,7 +535,7 @@ class Source: for ext_id, info in self.external_infos: if info.version is None: continue - if ext_id.fallback: + if ext_id.fallback_only: if fallback is None or version_is_newer_than(info.version, fallback.version): fallback = info else: @@ -561,12 +569,13 @@ class Source: ext = [] for ext_id in state.ext_info_ids: + variants = [] if ext_id.id in self.pkgextra.references: mapped = self.pkgextra.references[ext_id.id] if mapped is None: continue variants = [mapped] - else: + elif ext_id.guess_name: variants = get_realname_variants(self) infos = state.get_ext_infos(ext_id) @@ -578,7 +587,7 @@ class Source: # XXX: let repology do the mapping for us repology_repo = "msys2_msys2" if self._package.repo == "msys" else "msys2_mingw" ext.append(( - ExtId("repology", "Repology", True), + ExtId("repology", "Repology", True, True), ExtInfo(self.realname, None, 0, f"https://repology.org/tools/project-by?repo={quote(repology_repo)}&name_type=srcname&target_page=project_versions&name={quote(self.name)}", {}))) @@ -586,7 +595,7 @@ class Source: project_id = self.pkgextra.references.get("anitya", self.realname) if project_id is not None: ext.append(( - ExtId("anitya", "Anitya", True), + ExtId("anitya", "Anitya", True, True), ExtInfo(self.realname, None, 0, f"https://release-monitoring.org/project/{quote(project_id)}", {}))) diff --git a/app/fetch/arch.py b/app/fetch/arch.py index 1bc9ca1..f8d08e7 100644 --- a/app/fetch/arch.py +++ b/app/fetch/arch.py @@ -62,7 +62,7 @@ async def update_arch_versions() -> None: arch_versions[provides] = ExtInfo(provides, version, p.builddate, url, {}) logger.info("done") - state.set_ext_infos(ExtId("archlinux", "Arch Linux", False), arch_versions) + state.set_ext_infos(ExtId("archlinux", "Arch Linux", False, True), arch_versions) logger.info("update versions from AUR") aur_versions: dict[str, ExtInfo] = {} @@ -91,4 +91,4 @@ async def update_arch_versions() -> None: aur_versions[provides] = ExtInfo(provides, msys_ver, last_modified, url, {}) logger.info("done") - state.set_ext_infos(ExtId("aur", "AUR", True), aur_versions) + state.set_ext_infos(ExtId("aur", "AUR", True, True), aur_versions) diff --git a/app/fetch/cygwin.py b/app/fetch/cygwin.py index 34c5c03..18a8440 100644 --- a/app/fetch/cygwin.py +++ b/app/fetch/cygwin.py @@ -65,5 +65,5 @@ async def update_cygwin_versions() -> None: data = await get_content_cached(url, timeout=REQUEST_TIMEOUT) data = zstandard.ZstdDecompressor().decompress(data) cygwin_versions, cygwin_versions_mingw64 = await asyncio.to_thread(parse_cygwin_versions, url, data) - state.set_ext_infos(ExtId("cygwin", "Cygwin", True), cygwin_versions) - state.set_ext_infos(ExtId("cygwin-mingw64", "Cygwin-mingw64", False), cygwin_versions_mingw64) + state.set_ext_infos(ExtId("cygwin", "Cygwin", True, True), cygwin_versions) + state.set_ext_infos(ExtId("cygwin-mingw64", "Cygwin-mingw64", False, True), cygwin_versions_mingw64) diff --git a/app/fetch/gentoo.py b/app/fetch/gentoo.py index 0131bf2..269b166 100644 --- a/app/fetch/gentoo.py +++ b/app/fetch/gentoo.py @@ -21,7 +21,7 @@ async def update_gentoo_versions() -> None: data = await get_content_cached(url, timeout=REQUEST_TIMEOUT) gentoo_versions = await asyncio.to_thread(parse_gentoo_versions, data) # fallback, since parsing isn't perfect and we include unstable versions - state.set_ext_infos(ExtId("gentoo", "Gentoo", True), gentoo_versions) + state.set_ext_infos(ExtId("gentoo", "Gentoo", True, True), gentoo_versions) def parse_gentoo_versions(data: bytes) -> dict[str, ExtInfo]: diff --git a/app/fetch/pypi.py b/app/fetch/pypi.py index ff490e0..672a487 100644 --- a/app/fetch/pypi.py +++ b/app/fetch/pypi.py @@ -51,4 +51,4 @@ async def update_pypi_versions(pkgextra: PkgExtra) -> None: pypi_versions[pypi_name] = ExtInfo( pypi_name, info["version"], oldest_timestamp, info["project_url"], {}) - state.set_ext_infos(ExtId("pypi", "PyPI", False), pypi_versions) + state.set_ext_infos(ExtId("pypi", "PyPI", False, False), pypi_versions)