fix: export only what the platform declares

This commit is contained in:
Abdessamad Derraz committed 2026-10-10 11:15:25 +02:00
1 parent b5f9095633
commit e26ee44229
9 files changed
+145 -5

No files matched your search

+5 -1
View File
@@ -159,7 +159,11 @@ def load_platform_config(platform_name: str, platforms_dir: str = "platforms") -
key = (gf.get("name"), gf.get("destination", gf.get("name")))
dest_lower = gf.get("destination", gf.get("name", "")).lower()
if key not in existing and dest_lower not in existing_lower:
system.setdefault("files", []).append(gf)
# Marked as ours: the platform's own file does not
# carry it, and an export must not count it kept.
system.setdefault("files", []).append(
{**gf, "shared_group": group_name}
)
existing.add(key)
# Merge metadata from _registry.yml. The registry is our curated source;
+28 -1
View File
@@ -205,7 +205,34 @@ def load_inputs(
scraped = load_platform_config(platform, platforms_dir)
except (FileNotFoundError, OSError):
scraped = None
return truth, scraped
return truth, _native_layer(scraped)
def _native_layer(config: dict | None) -> dict | None:
"""The platform config without what we add to it.
A shared group's files join the config for the pack, but the platform's
file does not carry them: counted kept, they were written into
libretro's System.dat (N88EXT0-3.ROM) as if libretro declared them. What
a core needs from a group reaches the export through the truth, as an
addition the format's gates apply to. A scraper's mirror of an entry
under another system (RomM's tg16 firmware under turbografx-cd), and a
file our scraper adds from the cores' source (Dolphin's DSP ROMs in
RetroArch's config), are not in the platform's file either.
"""
if config is None:
return None
systems = {
sys_id: {
**system,
"files": [
f for f in system.get("files", [])
if not ({"shared_group", "mirror_of", "curated"} & f.keys())
],
}
for sys_id, system in config.get("systems", {}).items()
}
return {**config, "systems": systems}
def refresh_cache(
+5
View File
@@ -35,6 +35,9 @@ class BiosRequirement:
# is not always derivable from ours: libretro writes iplromco.dat bare
# but ep128emu/roms/cpc464.rom with its directory.
native_path: str | None = None
# The native system whose entry this one repeats under another system.
# The platform's own file does not carry the copy: an export skips it.
mirror_of: str | None = None
# Fields the platform declares that have no equivalent in our model.
# Kept verbatim so the native file can be written back unchanged.
native: dict[str, object] = field(default_factory=dict)
@@ -95,6 +98,8 @@ def requirement_entry(req: BiosRequirement) -> dict:
entry["native_system"] = req.native_id
if req.native_path and req.native_path != req.name:
entry["native_path"] = req.native_path
if req.mirror_of:
entry["mirror_of"] = req.mirror_of
for key in sorted(req.native):
value = req.native[key]
if value not in (None, "", [], {}):
+9 -3
View File
@@ -279,9 +279,14 @@ class Scraper(BaseScraper):
"docs": "https://docs.libretro.com/library/xrick/",
},
}
# Every entry below is ours, not System.dat's: marked curated so an
# export of System.dat does not take it for libretro's.
for sys_id, sys_data in EXTRA_SYSTEMS.items():
if sys_id not in systems:
systems[sys_id] = sys_data
systems[sys_id] = {
**sys_data,
"files": [{**f, "curated": True} for f in sys_data["files"]],
}
# Arcade BIOS present in the repo but absent from System.dat.
# FBNeo expects them in system/ or system/fbneo/.
@@ -310,7 +315,7 @@ class Scraper(BaseScraper):
existing = {f["name"] for f in systems["arcade"].get("files", [])}
for ef in EXTRA_ARCADE_FILES:
if ef["name"] not in existing:
systems["arcade"]["files"].append(ef)
systems["arcade"]["files"].append({**ef, "curated": True})
# segasp.zip for Sega System SP (Flycast)
if "sega-dreamcast-arcade" in systems:
@@ -323,6 +328,7 @@ class Scraper(BaseScraper):
"name": "segasp.zip",
"destination": "dc/segasp.zip",
"required": True,
"curated": True,
}
)
@@ -442,7 +448,7 @@ class Scraper(BaseScraper):
for ef in extra_files:
key = (ef["name"], ef.get("destination", ef["name"]))
if key not in existing:
systems[sys_id]["files"].append(ef)
systems[sys_id]["files"].append({**ef, "curated": True})
existing.add(key)
# ep128emu shared group for Enterprise
+1
View File
@@ -175,6 +175,7 @@ class Scraper(BaseScraper):
destination=f"{slug}/{filename}",
required=True,
native_id=slug,
mirror_of=None if slug == igdb_slug else igdb_slug,
)
)