mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 10:07:48 -06:00
Branch heads (scrapers, FBNeo import, data directories) resolve through core.upstream.resolve_head, with cache_dir=None to keep nothing under .cache/upstream. Streaming downloads (large files, external pack files, data directory archives, scraper downloads, standalone probe) go through one core.upstream.download: scratch then rename, size cap, retries of a cut stream, a 5xx or a rate limit. The shared rate limit wait reads GoatCounter's X-Rate-Limit-Reset, so site insights, download.py, indexnow and the contributor list use the same retrying client. list_gitlinks raises TruncatedListingError on a partial tree, read from one tree walk shared with list_tree (Forgejo paging included). The Recalbox configs/ listing is paged with the shared page cap.
90 lines
3.3 KiB
Python
90 lines
3.3 KiB
Python
"""Scraper for Recalbox per-board emulator availability.
|
|
|
|
Sources (recalbox/recalbox on GitLab, at the tag platforms/recalbox.yml names):
|
|
- configs/recalbox-<board>_defconfig -- the Buildroot packages each image
|
|
enables, one `BR2_PACKAGE_<NAME>=y` line per emulator package
|
|
- package/recalbox-romfs2/systems/<system>/system.ini -- the cores of each
|
|
system, each `[core.N]` naming the package that builds it, with board
|
|
overrides (`package.<board>`, `[core.N.<board>]`)
|
|
|
|
Recalbox runs on Raspberry Pi 3 to 5, two handhelds and x86_64: without a
|
|
target list, a Pi 3 pack carried the firmware of emulators only x86_64 builds.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
import sys
|
|
from datetime import datetime, timezone
|
|
|
|
|
|
from . import BaseTargetScraper, target_cli
|
|
from ..base_scraper import fetch_text
|
|
from ..recalbox_scraper import Scraper as PlatformScraper, board_cores, tree_listing
|
|
|
|
PLATFORM_NAME = "recalbox"
|
|
|
|
DEFCONFIG_URL = "https://gitlab.com/recalbox/recalbox/-/raw/{tag}/configs/{name}"
|
|
_DEFCONFIG_RE = re.compile(r"^recalbox-(\w+)_defconfig$")
|
|
_ENABLED_RE = re.compile(r"^(BR2_PACKAGE_\w+)=y\s*$", re.MULTILINE)
|
|
|
|
|
|
def enabled_packages(defconfig: str) -> set[str]:
|
|
"""The Buildroot packages a defconfig turns on."""
|
|
return set(_ENABLED_RE.findall(defconfig))
|
|
|
|
|
|
def defconfig_arch(defconfig: str) -> str:
|
|
"""The architecture a defconfig builds for, from its Buildroot arch symbol."""
|
|
for symbol, arch in (("BR2_x86_64", "x86_64"), ("BR2_aarch64", "aarch64"),
|
|
("BR2_arm", "armhf")):
|
|
if re.search(rf"^{symbol}=y\s*$", defconfig, re.MULTILINE):
|
|
return arch
|
|
raise RuntimeError("defconfig names no BR2_x86_64, BR2_aarch64 or BR2_arm")
|
|
|
|
|
|
class Scraper(BaseTargetScraper):
|
|
"""Per-board core lists from Recalbox's defconfigs and system.ini files."""
|
|
|
|
def __init__(self, url: str = "https://gitlab.com/recalbox/recalbox") -> None:
|
|
super().__init__(url=url)
|
|
|
|
def fetch_targets(self) -> dict:
|
|
tag = self.pinned_revision(PLATFORM_NAME)
|
|
platform = PlatformScraper(tag)
|
|
boards = {
|
|
match.group(1): item["name"]
|
|
for item in tree_listing("configs", tag)
|
|
if (match := _DEFCONFIG_RE.match(item.get("name", "")))
|
|
}
|
|
if not boards:
|
|
raise RuntimeError(f"no recalbox-*_defconfig in configs/ at {tag}")
|
|
|
|
inis = platform._system_inis(platform.system_folders())
|
|
|
|
targets: dict[str, dict] = {}
|
|
for board, name in sorted(boards.items()):
|
|
defconfig = fetch_text(DEFCONFIG_URL.format(tag=tag, name=name))
|
|
enabled = enabled_packages(defconfig)
|
|
cores: set[str] = set()
|
|
for text in inis:
|
|
cores |= board_cores(text, board, enabled)
|
|
arch = defconfig_arch(defconfig)
|
|
targets[board] = {"architecture": arch, "cores": sorted(cores)}
|
|
print(f" {board} ({arch}): {len(cores)} cores", file=sys.stderr)
|
|
|
|
return {
|
|
"platform": PLATFORM_NAME,
|
|
"source": f"{self.url}/-/tree/{tag}/configs",
|
|
"scraped_at": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
|
|
"targets": targets,
|
|
}
|
|
|
|
|
|
def main() -> None:
|
|
target_cli(Scraper, "Scrape Recalbox per-board cores")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|