From 35b5458a2d846866ad801f334a7c031c59189915 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sun, 22 Nov 2026 01:42:24 +0100 Subject: [PATCH] fix: read the lakka release from lakka.yml The target scraper asked for the latest Lakka release while lakka.yml named its version by hand, kept in step by a test alone. The scraper now reads that field, and check_freshness reports a newer Lakka release. --- platforms/lakka.yml | 6 ++-- scripts/check_freshness.py | 3 +- scripts/freshness/targets.py | 30 +++++++++++++++++ scripts/scraper/targets/__init__.py | 17 ++++++++++ .../scraper/targets/lakka_targets_scraper.py | 7 ++-- tests/test_audit_regressions.py | 4 +++ tests/test_check_freshness.py | 16 ++++++++++ tests/test_lakka_targets.py | 32 +++++++++++++++++++ wiki/tools.md | 5 +++ 9 files changed, 113 insertions(+), 7 deletions(-) diff --git a/platforms/lakka.yml b/platforms/lakka.yml index b5dfabda4..efec1b1a5 100644 --- a/platforms/lakka.yml +++ b/platforms/lakka.yml @@ -1,7 +1,9 @@ inherits: retroarch platform: Lakka homepage: "https://www.lakka.tv" -# Lakka-LibreELEC's release tag, the revision platforms/targets/lakka.yml -# reads its cores at. A version is never inherited from retroarch.yml. +# Lakka-LibreELEC's release tag, the revision the target scraper reads +# platforms/targets/lakka.yml at. Moving to a new release is an edit of this +# field, then a rescrape of the targets. A version is never inherited from +# retroarch.yml. version: v6.1 # Lakka uses the same BIOS requirements as RetroArch diff --git a/scripts/check_freshness.py b/scripts/check_freshness.py index c45bbd242..9feef9ac8 100644 --- a/scripts/check_freshness.py +++ b/scripts/check_freshness.py @@ -55,7 +55,7 @@ from freshness.platforms import check_emulatorjs, check_platforms from freshness.profiles import check_profiles, check_source_paths from freshness.report import exit_code, render, unknown_areas_message from freshness.romfolders import check_romfolders -from freshness.targets import check_targets +from freshness.targets import check_lakka_release, check_targets from model.profiles import load_emulator_profiles @@ -138,6 +138,7 @@ def main() -> int: ) if "targets" in areas: findings.extend(check_targets(platforms_dir, workdir, profiles, args.jobs, args.offline)) + findings.append(check_lakka_release(platforms_dir, args.cache_dir, args.offline)) if "romfolders" in areas: findings.extend(check_romfolders(platforms_dir, args.cache_dir, args.offline)) if "coreinfo" in areas: diff --git a/scripts/freshness/targets.py b/scripts/freshness/targets.py index 4f0b6fc18..b9562f2be 100644 --- a/scripts/freshness/targets.py +++ b/scripts/freshness/targets.py @@ -8,6 +8,7 @@ from concurrent.futures import ThreadPoolExecutor from datetime import datetime, timezone from pathlib import Path +from core import upstream from model.profiles import upstream_profile_index from model.sources import source_yaml_file from model.targets import apply_target_overrides, platform_overrides, read_target_overrides @@ -17,6 +18,8 @@ from freshness.findings import ( from freshness.platformdiff import diff_targets from freshness.rescrape import scrape_into_copy from freshness.scrapers import target_scrapers +from scraper.targets import BaseTargetScraper +from scraper.targets.lakka_targets_scraper import PLATFORM_NAME as LAKKA, REPO as LAKKA_REPO def profile_name_index(profiles: dict[str, dict]) -> dict[str, set[str]]: @@ -133,6 +136,33 @@ def check_targets( return findings +def check_lakka_release(platforms_dir: Path, cache_dir: str, offline: bool) -> Finding: + """The Lakka release platforms/lakka.yml pins against the newest one. + + The target scraper reads the release lakka.yml names, so a rescrape + never moves it: only this row says Lakka published a newer one. + """ + subject = f"{LAKKA} release" + try: + local = BaseTargetScraper.pinned_version(LAKKA, str(platforms_dir)) + except (OSError, RuntimeError) as exc: + return Finding("targets", subject, ERROR, detail=str(exc)) + if offline: + return Finding("targets", subject, SKIPPED, local=local, detail="offline") + repo = upstream.parse_repo(f"https://github.com/{LAKKA_REPO}") + try: + release = upstream.latest_release(repo, cache_dir) if repo else None + except upstream.UpstreamError as exc: + return Finding("targets", subject, UNKNOWN, local=local, detail=str(exc)) + if release is None: + return Finding("targets", subject, UNKNOWN, local=local, detail="no release listed") + if release.tag == local: + return Finding("targets", subject, OK, local=local, remote=release.tag, + detail="newest release") + return Finding("targets", subject, STALE, local=local, remote=release.tag, + detail=f"edit version: in platforms/{LAKKA}.yml, then rescrape the targets") + + def _declared_cores(platform: str, platforms_dir: Path) -> list[str]: """The cores and standalone emulators a platform's own file names.""" from model.platforms import load_platform_config diff --git a/scripts/scraper/targets/__init__.py b/scripts/scraper/targets/__init__.py index 444bef32e..9e85334b5 100644 --- a/scripts/scraper/targets/__init__.py +++ b/scripts/scraper/targets/__init__.py @@ -12,6 +12,7 @@ from abc import ABC, abstractmethod from pathlib import Path from model.safeparse import require_yaml +from model.sources import source_yaml_file from model.sourcerevision import platform_revision # Every target scraper reads the network through the platform scrapers' @@ -47,6 +48,22 @@ class BaseTargetScraper(ABC): ) return platform_revision(directory / f"{platform}.yml") + @staticmethod + def pinned_version(platform: str, platforms_dir: str | None = None) -> str: + """The release tag platforms/.yml names in its own `version:`. + + A platform that inherits its BIOS list (Lakka) has no source of its + own to pin: its file names the release by hand, and moving to a new + release is an edit of that field. + """ + directory = Path(platforms_dir) if platforms_dir else ( + Path(__file__).resolve().parents[3] / "platforms" + ) + version = str((source_yaml_file(directory / f"{platform}.yml") or {}).get("version") or "") + if not version: + raise RuntimeError(f"platforms/{platform}.yml names no version") + return version + def write_output(self, data: dict, output_path: str) -> None: """Write target data to YAML file.""" from core.artifacts import write_text_atomic diff --git a/scripts/scraper/targets/lakka_targets_scraper.py b/scripts/scraper/targets/lakka_targets_scraper.py index 987c664f5..abbf2f471 100644 --- a/scripts/scraper/targets/lakka_targets_scraper.py +++ b/scripts/scraper/targets/lakka_targets_scraper.py @@ -1,6 +1,6 @@ """Scraper for Lakka per-device core availability. -Sources (libretro/Lakka-LibreELEC, at the latest Lakka release tag): +Sources (libretro/Lakka-LibreELEC, at the release platforms/lakka.yml names): - packages/lakka/libretro_cores/package.mk -- LIBRETRO_CORES, then the EXCLUDE_LIBRETRO_CORES each PROJECT/DEVICE and OPENGLES_SUPPORT add - projects//options and projects//devices//options @@ -16,9 +16,8 @@ import re import sys from datetime import datetime, timezone - from . import BaseTargetScraper, target_cli -from ..base_scraper import fetch_github_latest_version, fetch_text, github_tree +from ..base_scraper import fetch_text, github_tree PLATFORM_NAME = "lakka" @@ -220,7 +219,7 @@ class Scraper(BaseTargetScraper): return found def fetch_targets(self) -> dict: - self.tag = fetch_github_latest_version(REPO) + self.tag = self.pinned_version(PLATFORM_NAME) cores_mk = self._raw(CORES_MK) targets: dict[str, dict] = {} for project, device in self._devices(): diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 4ef3486b1..56319bf86 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -5215,6 +5215,10 @@ class TargetListsReadThePinnedRelease(unittest.TestCase): ) self.assertNotIn("fetch_stable_tag()", source) self.assertNotIn("fetch_github_latest_version(", source) + # Lakka inherits its BIOS list and pins the release in its own version:. + source = (ROOT / "scripts" / "scraper" / "targets" / "lakka_targets_scraper.py").read_text() + self.assertIn("self.pinned_version(PLATFORM_NAME)", source) + self.assertNotIn("fetch_github_latest_version(", source) diff --git a/tests/test_check_freshness.py b/tests/test_check_freshness.py index e81f9bcb8..7ef92ae38 100644 --- a/tests/test_check_freshness.py +++ b/tests/test_check_freshness.py @@ -60,6 +60,7 @@ from freshness.scrapers import rescrape_command, target_scrapers from freshness.targets import ( _declared_cores, _unresolved_findings, + check_lakka_release, check_targets, profile_name_index, unresolved_target_cores, @@ -764,6 +765,21 @@ class RepositoryWiringTests(unittest.TestCase): self.assertNotIn("lakka", names) self.assertIn("retropie", names) + def test_a_newer_lakka_release_is_reported_not_followed(self): + """The target scraper reads the release lakka.yml names, so only + this row says Lakka published a newer one.""" + with tempfile.TemporaryDirectory() as tmp: + Path(tmp, "lakka.yml").write_text("inherits: retroarch\nversion: v6.1\n") + for tag, status in (("v6.1", OK), ("v6.2", STALE)): + release = upstream.Release(tag, "2026-11-01", False) + with self.subTest(tag=tag), \ + mock.patch.object(upstream, "latest_release", return_value=release): + row = check_lakka_release(Path(tmp), "", False) + self.assertEqual((row.status, row.local, row.remote), (status, "v6.1", tag)) + self.assertEqual(check_lakka_release(Path(tmp), "", True).status, SKIPPED) + Path(tmp, "lakka.yml").write_text("inherits: retroarch\n") + self.assertEqual(check_lakka_release(Path(tmp), "", True).status, ERROR) + def test_render_counts_every_status_once(self): findings = [ Finding("ci", "a", OK), diff --git a/tests/test_lakka_targets.py b/tests/test_lakka_targets.py index de7ba49c1..cd5a2facf 100644 --- a/tests/test_lakka_targets.py +++ b/tests/test_lakka_targets.py @@ -9,7 +9,10 @@ from __future__ import annotations import tests +import tempfile import unittest +from pathlib import Path +from unittest import mock from scripts.scraper.targets import lakka_targets_scraper as lakka @@ -95,6 +98,35 @@ class OptionsEvaluation(unittest.TestCase): lakka.evaluate(text, {}) +def _files(url: str) -> str: + return CORES_MK if url.endswith(lakka.CORES_MK) else "" + + +class Release(unittest.TestCase): + def test_the_release_is_the_one_lakka_yml_names(self): + """platforms/lakka.yml decides the release: a scraper that asked + for the latest one moved the cores away from the version it shows.""" + with tempfile.TemporaryDirectory() as tmp: + Path(tmp, "lakka.yml").write_text("inherits: retroarch\nversion: v6.1\n") + self.assertEqual(lakka.Scraper.pinned_version("lakka", tmp), "v6.1") + Path(tmp, "lakka.yml").write_text("inherits: retroarch\n") + with self.assertRaises(RuntimeError): + lakka.Scraper.pinned_version("lakka", tmp) + + def test_the_scrape_reads_at_that_release(self): + scraper = lakka.Scraper() + tree = [ + {"path": "projects/Generic/options"}, + {"path": "projects/Generic/devices/Generic/options"}, + ] + with mock.patch.object(lakka.Scraper, "pinned_version", return_value="v6.1"), \ + mock.patch.object(lakka, "fetch_text", side_effect=_files) as fetch, \ + mock.patch.object(lakka, "github_tree", return_value=tree): + data = scraper.fetch_targets() + self.assertTrue(all("/v6.1/" in call.args[0] for call in fetch.call_args_list)) + self.assertIn("/blob/v6.1/", data["source"]) + + class Architecture(unittest.TestCase): def test_aarch64_where_listed_else_arm(self): self.assertEqual(lakka.device_arch("RPi", "case $TARGET_ARCH in\n aarch64)\n"), "aarch64") diff --git a/wiki/tools.md b/wiki/tools.md index cc5f05cbc..bfe848c88 100644 --- a/wiki/tools.md +++ b/wiki/tools.md @@ -742,6 +742,11 @@ newest release, or with its branch head when the project publishes none. A stale pin is moved by hand, then `python -m scripts.scraper.romfolders --setup NAME` reads the folders again. +The `targets` area also compares the Lakka release `platforms/lakka.yml` +names in `version:` with Lakka's newest release. The target scraper reads +its core lists at that release and never moves it, so a newer release is +`STALE` until the field is edited by hand and the targets are scraped again. + The `profiles` area always checks `website/src/data/source-paths.json` against the profiles, offline: a recorded tree that no profile pins any more is `STALE` until `sitesources.py --fetch` runs again. It also reads each