refactor: name release packs from the record

model.releaserecord now holds match_key, pack_label and pack_owner,
which the release notes and download.py each kept a copy of, and
recorded_pack, the pack release.json says serves a platform.

download.py reads release.json when it records the release it
downloads from. Otherwise it matches pack names and takes the shortest
match, so retroarch gets RetroArch_v1.22.2 rather than the
AndroidArm64V8A target pack listed before it.
This commit is contained in:
Abdessamad Derraz committed 2026-11-20 20:03:26 +01:00
1 parent e6e4095081
commit 97af05db9a
4 files changed
+71 -34

No files matched your search

+3 -21
View File
@@ -3,13 +3,13 @@
from __future__ import annotations
import json
import re
import subprocess
from collections.abc import Callable
from core.sizes import size_text
from model.guides import install_command
from model.platforms import load_platform_config
from model.releaserecord import pack_label, pack_owner
from model.registry import (
list_registered_platforms,
list_release_pack_platforms,
@@ -26,25 +26,12 @@ SITE = "https://abdess.github.io/retrobios/"
HANDHELD_PAGE = "wiki/installer/#on-a-handheld-the-retrobios-port"
def _display(pack: str) -> str:
"""RetroArch_Lakka_v1.22.2_BIOS_Pack.zip reads as RetroArch Lakka v1.22.2."""
return pack.split("_BIOS_Pack", 1)[0].replace("_", " ")
def _owner(name: str, pack: dict) -> str:
"""The platform a pack is named after: RetroArch_Lakka is RetroArch's."""
key = _match_key(name)
return sorted(
pack.get("platforms", ()), key=lambda p: key.find(_match_key(p)) % (len(key) + 1)
)[0]
def _extract_folders(record: dict, platforms_dir: str) -> dict[str, str]:
"""Pack name to the folder the registry says it extracts into."""
registry = load_platform_registry(platforms_dir)
folders: dict[str, str] = {}
for name, pack in sorted(record.get("packs", {}).items()):
folder = registry.get(_owner(name, pack), {}).get("extract_to")
folder = registry.get(pack_owner(name, pack), {}).get("extract_to")
if folder:
folders[name] = folder
return folders
@@ -76,11 +63,6 @@ def no_pack_paragraph(platforms_dir: str) -> list[str]:
]
def _match_key(value: str) -> str:
"""Letters and digits only: the platform is `misterfpga`, the pack MiSTer_FPGA."""
return re.sub(r"[^a-z0-9]", "", value.lower())
def _link(pack: dict, tag: str) -> str:
"""The pack's files on this release, one link per part."""
base = f"https://github.com/{REPO}/releases/download/{tag}"
@@ -239,7 +221,7 @@ def render(record: dict, platforms_dir: str, whats_new: str,
for name, pack in sorted(packs.items(), key=lambda item: -item[1]["extracted_size"]):
folder = folders.get(name)
lines.append(
f"| {_display(name)} | {_link(pack, tag)} |"
f"| {pack_label(name)} | {_link(pack, tag)} |"
f" {size_text(pack['extracted_size'])} | {pack['files']:,} |"
f" {f'`{folder}`' if folder else '-'} |"
)