mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-18 17:33:30 -05:00
fix: lay out both builds of a dual-mode emulator
Batocera, RetroBat, Recalbox and ROCKNIX offer some emulators both as a libretro core and standalone. Filed as standalone only, the libretro layout was dropped: libretro Dolphin had no dolphin-emu/Sys/GC files. Platforms now name dual-mode emulators and each gets both layouts.
This commit is contained in:
1 parent
2b535525ef
commit
3c856bbc10
23 files changed
+1367
-478
No files matched your search
@@ -1861,6 +1861,7 @@ def group_identical_platforms(
|
||||
emulators = [
|
||||
cores if isinstance(cores, str) else sorted(map(str, cores or [])),
|
||||
sorted(map(str, config.get("standalone_cores") or [])),
|
||||
sorted(map(str, config.get("dual_mode_cores") or [])),
|
||||
# One archive cannot serve a filesystem that folds case and one
|
||||
# that does not: Lakka keeps bios.col beside BIOS.col.
|
||||
bool(config.get("case_insensitive_fs")),
|
||||
@@ -2004,6 +2005,44 @@ def runs_standalone(
|
||||
)
|
||||
|
||||
|
||||
# Marks, in a platform's standalone set, an emulator it also launches as a
|
||||
# libretro core. No core name starts with it.
|
||||
DUAL_MODE_PREFIX = "dual:"
|
||||
|
||||
|
||||
def standalone_set(config: dict) -> set[str]:
|
||||
"""The emulators a platform launches standalone, with its dual-mode ones.
|
||||
|
||||
``dual_mode_cores`` names those it offers both ways (Batocera lists
|
||||
libretro:dolphin and standalone dolphin for GameCube). They travel in the
|
||||
same set, tagged, so every reader of standalone_cores sees them.
|
||||
"""
|
||||
names = {str(c) for c in config.get("standalone_cores") or []}
|
||||
names |= {DUAL_MODE_PREFIX + str(c) for c in config.get("dual_mode_cores") or []}
|
||||
return names
|
||||
|
||||
|
||||
def platform_layouts(
|
||||
emu_name: str, profile: dict, standalone_cores: set[str]
|
||||
) -> list[tuple[dict, bool]]:
|
||||
"""The layouts a platform gives an emulator: (profile, standalone?) each.
|
||||
|
||||
One, libretro or standalone, for most. Both for an emulator the platform
|
||||
launches either way: laid out standalone only, Batocera's libretro
|
||||
Dolphin found dolphin-emu/Sys/GC/ empty. Each layout keeps its own rules
|
||||
(what the build reads from the system directory, where it reads it).
|
||||
"""
|
||||
if not runs_standalone(emu_name, profile, standalone_cores):
|
||||
return [(profile, False)]
|
||||
dual = {c.removeprefix(DUAL_MODE_PREFIX) for c in standalone_cores
|
||||
if c.startswith(DUAL_MODE_PREFIX)}
|
||||
if "libretro" in str(profile.get("type", "")) and dual & {
|
||||
emu_name, *(str(c) for c in profile.get("cores", []))
|
||||
}:
|
||||
return [(profile, False), (profile, True)]
|
||||
return [(profile, True)]
|
||||
|
||||
|
||||
# What identifies a profile entry's content, carried unchanged wherever the
|
||||
# entry travels (cross-reference report, core extras, second-pass copies).
|
||||
# Each copy once kept its own subset: np2kai's bios.rom lost min_size and
|
||||
|
||||
@@ -38,7 +38,8 @@ from common import (
|
||||
require_platform,
|
||||
require_yaml,
|
||||
resolve_local_file,
|
||||
runs_standalone,
|
||||
platform_layouts,
|
||||
standalone_set,
|
||||
select_emulator_profiles,
|
||||
)
|
||||
from validation import declaration_settles, outside_gap_scope
|
||||
@@ -502,7 +503,10 @@ def _cross_reference_profile(
|
||||
|
||||
# The build a platform runs decides which entries it reads, as in
|
||||
# find_undeclared_files: without a platform, the libretro build.
|
||||
is_standalone = runs_standalone(emu_name, profile, standalone_cores or set())
|
||||
layouts = platform_layouts(emu_name, profile, standalone_cores or set())
|
||||
# Each file under each layout the platform gives the emulator: both, for
|
||||
# one it launches as a libretro core and standalone.
|
||||
layout_files = [(f, standalone) for view, standalone in layouts for f in view.get("files", [])]
|
||||
gaps = []
|
||||
covered = []
|
||||
unsourceable_list: list[dict] = []
|
||||
@@ -516,7 +520,7 @@ def _cross_reference_profile(
|
||||
for f in emu_files:
|
||||
versions.setdefault(slot_key(f), []).append(f)
|
||||
|
||||
for f in emu_files:
|
||||
for f, is_standalone in layout_files:
|
||||
fname = f.get("name", "")
|
||||
# The destination the running build reads, as find_undeclared_files
|
||||
# takes it: Batocera's standalone Cemu reads keys.txt at
|
||||
@@ -527,6 +531,9 @@ def _cross_reference_profile(
|
||||
else:
|
||||
effective_path = f.get("path") or fname
|
||||
seen_key = slot_key(f)
|
||||
if len(layouts) > 1:
|
||||
# One file read at one path by both builds counts once.
|
||||
seen_key = (effective_path.casefold(), seen_key)
|
||||
if not fname or seen_key in seen_files:
|
||||
continue
|
||||
|
||||
@@ -820,7 +827,7 @@ def main() -> None:
|
||||
config = load_platform_config(args.platform, args.platforms_dir)
|
||||
relevant = resolve_platform_cores(config, profiles, target_cores=target_cores)
|
||||
profiles = {k: v for k, v in profiles.items() if k in relevant}
|
||||
standalone_cores = set(map(str, config.get("standalone_cores", [])))
|
||||
standalone_cores = standalone_set(config)
|
||||
|
||||
if not profiles:
|
||||
if args.emulator:
|
||||
|
||||
+158
-157
@@ -15,7 +15,8 @@ from common import load_emulator_profiles
|
||||
from common import resolution_is_hash_exact
|
||||
from common import resolve_local_file
|
||||
from common import resolve_platform_cores
|
||||
from common import runs_standalone
|
||||
from common import platform_layouts
|
||||
from common import standalone_set as platform_standalone_set
|
||||
from common import sanitize_pack_path
|
||||
from common import size_fits
|
||||
from validation import read_from_system_dir
|
||||
@@ -290,96 +291,96 @@ def _agnostic_scan_extras(
|
||||
agnostic_votes.get(directory + "/", 0) + 1
|
||||
)
|
||||
|
||||
standalone = runs_standalone(emu_name, profile, standalone_set or set())
|
||||
for f in profile.get("files", []):
|
||||
if not is_profile_agnostic and not f.get("agnostic"):
|
||||
continue
|
||||
fname = f.get("name", "")
|
||||
if not fname:
|
||||
continue
|
||||
# A file of the build the platform does not run seeds nothing:
|
||||
# armsx2's proverb.zip is fetched by the Android app into its own
|
||||
# arcade/ folder, and the libretro packs carried it at system/.
|
||||
mode = f.get("mode")
|
||||
if (mode == "standalone" and not standalone) or (
|
||||
mode == "libretro" and standalone
|
||||
):
|
||||
continue
|
||||
# An agnostic BIOS mode says the BIOS filename is free, not that
|
||||
# every file the emulator loads is. A free filename still has a
|
||||
# known shape, and that shape is what identifies a candidate: an
|
||||
# entry declaring no size takes the whole directory, which is how
|
||||
# the flag icons of an Android package walked into a PS2 pack.
|
||||
if f.get("category", "bios") != "bios":
|
||||
continue
|
||||
if not (f.get("size") or f.get("min_size") or f.get("max_size")):
|
||||
continue
|
||||
# The free name is the BIOS directory's: a shader, a sound or a
|
||||
# font the emulator reads from its resources tree has a fixed
|
||||
# name and must not seed a scan (yaps2 flattened 189 of them to
|
||||
# the root of the RetroArch pack).
|
||||
bios_dir = profile.get("bios_directory")
|
||||
fpath = f.get("path") or ""
|
||||
if bios_dir and "/" in fpath and not fpath.startswith(bios_dir):
|
||||
continue
|
||||
for profile, standalone in platform_layouts(emu_name, profile, standalone_set or set()):
|
||||
for f in profile.get("files", []):
|
||||
if not is_profile_agnostic and not f.get("agnostic"):
|
||||
continue
|
||||
fname = f.get("name", "")
|
||||
if not fname:
|
||||
continue
|
||||
# A file of the build the platform does not run seeds nothing:
|
||||
# armsx2's proverb.zip is fetched by the Android app into its own
|
||||
# arcade/ folder, and the libretro packs carried it at system/.
|
||||
mode = f.get("mode")
|
||||
if (mode == "standalone" and not standalone) or (
|
||||
mode == "libretro" and standalone
|
||||
):
|
||||
continue
|
||||
# An agnostic BIOS mode says the BIOS filename is free, not that
|
||||
# every file the emulator loads is. A free filename still has a
|
||||
# known shape, and that shape is what identifies a candidate: an
|
||||
# entry declaring no size takes the whole directory, which is how
|
||||
# the flag icons of an Android package walked into a PS2 pack.
|
||||
if f.get("category", "bios") != "bios":
|
||||
continue
|
||||
if not (f.get("size") or f.get("min_size") or f.get("max_size")):
|
||||
continue
|
||||
# The free name is the BIOS directory's: a shader, a sound or a
|
||||
# font the emulator reads from its resources tree has a fixed
|
||||
# name and must not seed a scan (yaps2 flattened 189 of them to
|
||||
# the root of the RetroArch pack).
|
||||
bios_dir = profile.get("bios_directory")
|
||||
fpath = f.get("path") or ""
|
||||
if bios_dir and "/" in fpath and not fpath.startswith(bios_dir):
|
||||
continue
|
||||
|
||||
path_prefix = resolved_dirs.get(id(f), "")
|
||||
if not path_prefix:
|
||||
continue
|
||||
# A name matching one file identifies it. A name matching several
|
||||
# identifies nothing on its own, so the profile's other files have
|
||||
# to agree on the directory before the scan walks it.
|
||||
ambiguous = id(f) in named_only and len(by_name.get(fname, [])) > 1
|
||||
if ambiguous and agnostic_votes.get(path_prefix, 0) < 2:
|
||||
continue
|
||||
path_prefix = resolved_dirs.get(id(f), "")
|
||||
if not path_prefix:
|
||||
continue
|
||||
# A name matching one file identifies it. A name matching several
|
||||
# identifies nothing on its own, so the profile's other files have
|
||||
# to agree on the directory before the scan walks it.
|
||||
ambiguous = id(f) in named_only and len(by_name.get(fname, [])) > 1
|
||||
if ambiguous and agnostic_votes.get(path_prefix, 0) < 2:
|
||||
continue
|
||||
|
||||
# Scan DB for all files under this prefix matching size
|
||||
for sha1, entry in files_db.items():
|
||||
path = entry.get("path", "")
|
||||
if not path.startswith(path_prefix):
|
||||
continue
|
||||
if not size_fits(f, entry.get("size", 0)):
|
||||
continue
|
||||
scan_name = entry.get("name", "")
|
||||
if not scan_name:
|
||||
continue
|
||||
# Into the directory the seed entry names, not the root:
|
||||
# yaps2 reads its BIOS from pcsx2/bios/.
|
||||
seed = f.get("path") or ""
|
||||
if standalone:
|
||||
seed = f.get("standalone_path") or seed
|
||||
folder = seed.rsplit("/", 1)[0] if "/" in seed else ""
|
||||
dest = f"{folder}/{scan_name}" if folder else scan_name
|
||||
full_dest = f"{extras_prefix}/{dest}" if extras_prefix else dest
|
||||
if full_dest in seen_dests and (taken is None or full_dest not in taken):
|
||||
continue
|
||||
extra = {
|
||||
"name": scan_name,
|
||||
"destination": dest,
|
||||
# The scan already holds the entry it selected, so it
|
||||
# names it by content. Emitting the filename alone
|
||||
# sent the packing step back to a by-name lookup, and
|
||||
# three PS2 resources came back from another
|
||||
# emulator's copy of the same filename.
|
||||
"sha1": sha1,
|
||||
"required": False,
|
||||
"hle_fallback": False,
|
||||
"source_emulator": profile.get("emulator", emu_name),
|
||||
"source_profile": emu_name,
|
||||
"source_system": f.get("system"),
|
||||
"source_systems": list(profile.get("systems", [])),
|
||||
"region": f.get("region"),
|
||||
"variant_group": f.get("variant_group"),
|
||||
"agnostic_scan": True,
|
||||
}
|
||||
extra["claim_order"] = (4, 0, emu_name)
|
||||
if not _take(extra, full_dest, seen_dests, taken):
|
||||
continue
|
||||
extras.append(extra)
|
||||
extras.extend(_companion_extras(
|
||||
_companions(path, scan_name, _companion_extensions(profile, fname), files_db),
|
||||
folder, extras_prefix, seen_dests, profile, emu_name, f, taken,
|
||||
))
|
||||
# Scan DB for all files under this prefix matching size
|
||||
for sha1, entry in files_db.items():
|
||||
path = entry.get("path", "")
|
||||
if not path.startswith(path_prefix):
|
||||
continue
|
||||
if not size_fits(f, entry.get("size", 0)):
|
||||
continue
|
||||
scan_name = entry.get("name", "")
|
||||
if not scan_name:
|
||||
continue
|
||||
# Into the directory the seed entry names, not the root:
|
||||
# yaps2 reads its BIOS from pcsx2/bios/.
|
||||
seed = f.get("path") or ""
|
||||
if standalone:
|
||||
seed = f.get("standalone_path") or seed
|
||||
folder = seed.rsplit("/", 1)[0] if "/" in seed else ""
|
||||
dest = f"{folder}/{scan_name}" if folder else scan_name
|
||||
full_dest = f"{extras_prefix}/{dest}" if extras_prefix else dest
|
||||
if full_dest in seen_dests and (taken is None or full_dest not in taken):
|
||||
continue
|
||||
extra = {
|
||||
"name": scan_name,
|
||||
"destination": dest,
|
||||
# The scan already holds the entry it selected, so it
|
||||
# names it by content. Emitting the filename alone
|
||||
# sent the packing step back to a by-name lookup, and
|
||||
# three PS2 resources came back from another
|
||||
# emulator's copy of the same filename.
|
||||
"sha1": sha1,
|
||||
"required": False,
|
||||
"hle_fallback": False,
|
||||
"source_emulator": profile.get("emulator", emu_name),
|
||||
"source_profile": emu_name,
|
||||
"source_system": f.get("system"),
|
||||
"source_systems": list(profile.get("systems", [])),
|
||||
"region": f.get("region"),
|
||||
"variant_group": f.get("variant_group"),
|
||||
"agnostic_scan": True,
|
||||
}
|
||||
extra["claim_order"] = (4, 0, emu_name)
|
||||
if not _take(extra, full_dest, seen_dests, taken):
|
||||
continue
|
||||
extras.append(extra)
|
||||
extras.extend(_companion_extras(
|
||||
_companions(path, scan_name, _companion_extensions(profile, fname), files_db),
|
||||
folder, extras_prefix, seen_dests, profile, emu_name, f, taken,
|
||||
))
|
||||
return extras
|
||||
|
||||
|
||||
@@ -701,7 +702,7 @@ def _collect_emulator_extras(
|
||||
return extras
|
||||
|
||||
relevant = resolve_platform_cores(config, profiles, target_cores=target_cores)
|
||||
standalone_set = {str(c) for c in config.get("standalone_cores", [])}
|
||||
standalone_set = platform_standalone_set(config)
|
||||
by_name = db.get("indexes", {}).get("by_name", {})
|
||||
by_path_suffix = db.get("indexes", {}).get("by_path_suffix", {})
|
||||
|
||||
@@ -716,73 +717,73 @@ def _collect_emulator_extras(
|
||||
continue
|
||||
if emu_name not in relevant:
|
||||
continue
|
||||
is_standalone = runs_standalone(emu_name, profile, standalone_set)
|
||||
for f in profile.get("files", []):
|
||||
fname = f.get("name", "")
|
||||
if not fname:
|
||||
continue
|
||||
# Only duplicate files already covered at another destination.
|
||||
# An unsourceable entry is a file no collection holds: the name
|
||||
# covered elsewhere belongs to another program's file.
|
||||
if fname not in covered_names or f.get("unsourceable"):
|
||||
continue
|
||||
# A member of an archive is read inside it, never as a loose
|
||||
# file; the archive itself is placed by the passes above.
|
||||
if f.get("archive"):
|
||||
continue
|
||||
# No path: the core reads it from nowhere a pack reaches
|
||||
# (Dolphin's codehandler.bin ships in its Sys tree).
|
||||
if "path" in f and f["path"] is None:
|
||||
continue
|
||||
file_mode = f.get("mode")
|
||||
if file_mode == "standalone" and not is_standalone:
|
||||
continue
|
||||
if file_mode == "libretro" and is_standalone:
|
||||
continue
|
||||
if not read_from_system_dir(f, is_standalone):
|
||||
continue
|
||||
if is_standalone:
|
||||
raw = f.get("standalone_path") or f.get("path") or fname
|
||||
else:
|
||||
raw = f.get("path") or fname
|
||||
dest = f"{raw}{fname}" if raw.endswith("/") else raw
|
||||
# A bare name is a destination too: the core reads it at the root
|
||||
# of the directory core files go to, which the platform may not
|
||||
# declare (Recalbox has its System Cards under pcenginecd/ only,
|
||||
# geargrafx reads them from the root).
|
||||
full_dest = f"{extras_prefix}/{dest}" if extras_prefix else dest
|
||||
if full_dest in seen_dests and full_dest not in taken:
|
||||
continue
|
||||
# Check file exists in repo or data dirs
|
||||
if not (
|
||||
by_name.get(fname)
|
||||
or by_name.get(dest.rsplit("/", 1)[-1])
|
||||
or by_path_suffix.get(dest)
|
||||
):
|
||||
continue
|
||||
extra = {
|
||||
"name": fname,
|
||||
"destination": dest,
|
||||
"required": f.get("required", False),
|
||||
"hle_fallback": f.get("hle_fallback", False),
|
||||
"source_emulator": profile.get("emulator", emu_name),
|
||||
"source_profile": emu_name,
|
||||
"source_system": f.get("system"),
|
||||
"source_systems": list(profile.get("systems", [])),
|
||||
"region": f.get("region"),
|
||||
"variant_group": f.get("variant_group"),
|
||||
}
|
||||
# The same identity the first pass carries: without it the copy
|
||||
# resolves on its name alone and a same-named file of another
|
||||
# game fills the slot the profile marks as not held.
|
||||
for identity in PROFILE_IDENTITY_FIELDS:
|
||||
if f.get(identity) not in (None, "", []):
|
||||
extra[identity] = f[identity]
|
||||
if f.get("contents"):
|
||||
extra["contents"] = f["contents"]
|
||||
extra["claim_order"] = (2, 0, emu_name)
|
||||
if _take(extra, full_dest, seen_dests, taken):
|
||||
extras.append(extra)
|
||||
for profile, is_standalone in platform_layouts(emu_name, profile, standalone_set):
|
||||
for f in profile.get("files", []):
|
||||
fname = f.get("name", "")
|
||||
if not fname:
|
||||
continue
|
||||
# Only duplicate files already covered at another destination.
|
||||
# An unsourceable entry is a file no collection holds: the name
|
||||
# covered elsewhere belongs to another program's file.
|
||||
if fname not in covered_names or f.get("unsourceable"):
|
||||
continue
|
||||
# A member of an archive is read inside it, never as a loose
|
||||
# file; the archive itself is placed by the passes above.
|
||||
if f.get("archive"):
|
||||
continue
|
||||
# No path: the core reads it from nowhere a pack reaches
|
||||
# (Dolphin's codehandler.bin ships in its Sys tree).
|
||||
if "path" in f and f["path"] is None:
|
||||
continue
|
||||
file_mode = f.get("mode")
|
||||
if file_mode == "standalone" and not is_standalone:
|
||||
continue
|
||||
if file_mode == "libretro" and is_standalone:
|
||||
continue
|
||||
if not read_from_system_dir(f, is_standalone):
|
||||
continue
|
||||
if is_standalone:
|
||||
raw = f.get("standalone_path") or f.get("path") or fname
|
||||
else:
|
||||
raw = f.get("path") or fname
|
||||
dest = f"{raw}{fname}" if raw.endswith("/") else raw
|
||||
# A bare name is a destination too: the core reads it at the root
|
||||
# of the directory core files go to, which the platform may not
|
||||
# declare (Recalbox has its System Cards under pcenginecd/ only,
|
||||
# geargrafx reads them from the root).
|
||||
full_dest = f"{extras_prefix}/{dest}" if extras_prefix else dest
|
||||
if full_dest in seen_dests and full_dest not in taken:
|
||||
continue
|
||||
# Check file exists in repo or data dirs
|
||||
if not (
|
||||
by_name.get(fname)
|
||||
or by_name.get(dest.rsplit("/", 1)[-1])
|
||||
or by_path_suffix.get(dest)
|
||||
):
|
||||
continue
|
||||
extra = {
|
||||
"name": fname,
|
||||
"destination": dest,
|
||||
"required": f.get("required", False),
|
||||
"hle_fallback": f.get("hle_fallback", False),
|
||||
"source_emulator": profile.get("emulator", emu_name),
|
||||
"source_profile": emu_name,
|
||||
"source_system": f.get("system"),
|
||||
"source_systems": list(profile.get("systems", [])),
|
||||
"region": f.get("region"),
|
||||
"variant_group": f.get("variant_group"),
|
||||
}
|
||||
# The same identity the first pass carries: without it the copy
|
||||
# resolves on its name alone and a same-named file of another
|
||||
# game fills the slot the profile marks as not held.
|
||||
for identity in PROFILE_IDENTITY_FIELDS:
|
||||
if f.get(identity) not in (None, "", []):
|
||||
extra[identity] = f[identity]
|
||||
if f.get("contents"):
|
||||
extra["contents"] = f["contents"]
|
||||
extra["claim_order"] = (2, 0, emu_name)
|
||||
if _take(extra, full_dest, seen_dests, taken):
|
||||
extras.append(extra)
|
||||
|
||||
extras.extend(
|
||||
_archive_prefix_extras(
|
||||
|
||||
@@ -97,3 +97,15 @@ def yaml_load(stream: str | TextIO) -> Any:
|
||||
if yaml is None:
|
||||
return require_yaml() # exits with the install hint
|
||||
return yaml.load(stream, Loader=_YAML_LOADER)
|
||||
|
||||
|
||||
def yaml_load_upstream(stream: str | TextIO) -> Any:
|
||||
"""Parse a third party's YAML the way its own PyYAML code reads it.
|
||||
|
||||
Our files refuse a repeated key; a platform's file is data we transcribe,
|
||||
and its code keeps the last value. Batocera 43.1's configgen-defaults.yml
|
||||
names rtcw's core twice, and refusing it stopped the rescrape.
|
||||
"""
|
||||
if yaml is None:
|
||||
return require_yaml()
|
||||
return yaml.load(stream, Loader=getattr(yaml, "CSafeLoader", None) or yaml.SafeLoader)
|
||||
@@ -18,6 +18,7 @@ from pathlib import Path
|
||||
|
||||
|
||||
from common import yaml_load
|
||||
from safeparse import yaml_load_upstream
|
||||
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
@@ -98,7 +99,7 @@ def es_systems_emulators(text: str) -> tuple[set[str], set[str]]:
|
||||
reading it alone left DOSBox Staging, melonDS DS and nine other built
|
||||
cores outside the pack.
|
||||
"""
|
||||
data = yaml_load(text)
|
||||
data = yaml_load_upstream(text)
|
||||
if not isinstance(data, dict):
|
||||
raise ValueError("es_systems.yml is not a mapping")
|
||||
cores: set[str] = set()
|
||||
@@ -126,6 +127,20 @@ def es_systems_emulators(text: str) -> tuple[set[str], set[str]]:
|
||||
return cores, standalone
|
||||
|
||||
|
||||
def es_systems_libretro(text: str) -> set[str]:
|
||||
"""The cores es_systems.yml offers under `libretro:` for some system."""
|
||||
data = yaml_load_upstream(text)
|
||||
if not isinstance(data, dict):
|
||||
raise ValueError("es_systems.yml is not a mapping")
|
||||
found: set[str] = set()
|
||||
for system in data.values():
|
||||
emulators = system.get("emulators") if isinstance(system, dict) else None
|
||||
libretro = emulators.get("libretro") if isinstance(emulators, dict) else None
|
||||
if isinstance(libretro, dict):
|
||||
found.update(str(core) for core, spec in libretro.items() if isinstance(spec, dict))
|
||||
return found
|
||||
|
||||
|
||||
SYSTEM_SLUG_MAP = {
|
||||
"advision": "entex-advision",
|
||||
"amiga500": "commodore-amiga",
|
||||
@@ -253,11 +268,12 @@ class Scraper(BaseScraper):
|
||||
self.tag = fetch_stable_tag()
|
||||
super().__init__(url=SOURCE_URL.format(tag=self.tag))
|
||||
|
||||
def _fetch_cores(self) -> tuple[list[str], list[str]]:
|
||||
def _fetch_cores(self) -> tuple[list[str], list[str], list[str]]:
|
||||
"""Extract core names and standalone cores from configgen-defaults.yml.
|
||||
|
||||
Returns (all_cores, standalone_cores) where standalone_cores are
|
||||
those with emulator != "libretro".
|
||||
Returns (all_cores, standalone_cores, dual_mode_cores): standalone
|
||||
cores are those with emulator != "libretro", dual-mode ones those
|
||||
es_systems.yml also offers under libretro (dolphin for GameCube).
|
||||
"""
|
||||
url = CONFIGGEN_DEFAULTS_URL.format(tag=self.tag)
|
||||
try:
|
||||
@@ -271,10 +287,10 @@ class Scraper(BaseScraper):
|
||||
raise ConnectionError(
|
||||
f"Failed to fetch {url}: {e}"
|
||||
) from e
|
||||
data = yaml_load(raw)
|
||||
cores, standalone = es_systems_emulators(
|
||||
self._fetch_text(ES_SYSTEMS_URL.format(tag=self.tag))
|
||||
)
|
||||
data = yaml_load_upstream(raw)
|
||||
es_systems = self._fetch_text(ES_SYSTEMS_URL.format(tag=self.tag))
|
||||
cores, standalone = es_systems_emulators(es_systems)
|
||||
libretro = es_systems_libretro(es_systems)
|
||||
if not cores:
|
||||
raise RuntimeError("es_systems.yml names no emulator")
|
||||
for system, cfg in data.items():
|
||||
@@ -289,7 +305,8 @@ class Scraper(BaseScraper):
|
||||
if core and core != emulator:
|
||||
standalone.add(core)
|
||||
dropped = _not_cores()
|
||||
return sorted(cores - dropped), sorted(standalone - dropped)
|
||||
dual = (standalone & libretro) - dropped
|
||||
return sorted(cores - dropped), sorted(standalone - dropped), sorted(dual)
|
||||
|
||||
def _fetch_text(self, url: str) -> str:
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "retrobios-scraper/1.0"})
|
||||
@@ -449,7 +466,7 @@ class Scraper(BaseScraper):
|
||||
|
||||
systems[req.system]["files"].append(requirement_entry(req))
|
||||
|
||||
cores, standalone = self._fetch_cores()
|
||||
cores, standalone, dual = self._fetch_cores()
|
||||
result = {
|
||||
"platform": "Batocera",
|
||||
"version": self.tag.removeprefix("batocera-"),
|
||||
@@ -463,6 +480,9 @@ class Scraper(BaseScraper):
|
||||
}
|
||||
if standalone:
|
||||
result["standalone_cores"] = standalone
|
||||
if dual:
|
||||
# Launched both ways: each layout gets its files.
|
||||
result["dual_mode_cores"] = dual
|
||||
return result
|
||||
|
||||
|
||||
|
||||
@@ -153,6 +153,18 @@ def _core_names(values: dict[str, str]) -> tuple[set[str], set[str]]:
|
||||
return names, set(names)
|
||||
|
||||
|
||||
def system_ini_libretro(text: str) -> set[str]:
|
||||
"""The libretro cores one Recalbox system.ini offers."""
|
||||
import re
|
||||
|
||||
return {
|
||||
values.get("core", "")
|
||||
for section, values in _ini_sections(text).items()
|
||||
if re.fullmatch(r"core\.\d+(\.[\w-]+)?", section)
|
||||
and values.get("emulator") == "libretro" and values.get("core")
|
||||
}
|
||||
|
||||
|
||||
def system_ini_cores(text: str) -> tuple[set[str], set[str]]:
|
||||
"""The cores one Recalbox system.ini offers, and those run standalone.
|
||||
|
||||
@@ -227,8 +239,9 @@ class Scraper(BaseScraper):
|
||||
raise RuntimeError(f"no system.ini at {self.tag} for {', '.join(missing[:5])}")
|
||||
return [texts[path] for path in paths]
|
||||
|
||||
def _fetch_cores(self) -> tuple[list[str], list[str]]:
|
||||
"""Every core Recalbox's systems offer, and those it runs standalone.
|
||||
def _fetch_cores(self) -> tuple[list[str], list[str], list[str]]:
|
||||
"""Every core Recalbox's systems offer, those it runs standalone, and
|
||||
those it offers both as a libretro core and standalone.
|
||||
|
||||
Read from each system.ini of recalbox-romfs2 at the scraped tag: the
|
||||
systems ES lists and the cores a user can pick for each.
|
||||
@@ -250,13 +263,15 @@ class Scraper(BaseScraper):
|
||||
raise RuntimeError(f"no Recalbox system found at {self.tag}")
|
||||
cores: set[str] = set()
|
||||
standalone: set[str] = set()
|
||||
libretro: set[str] = set()
|
||||
for text in self._system_inis(systems):
|
||||
found, alone = system_ini_cores(text)
|
||||
cores |= found
|
||||
standalone |= alone
|
||||
libretro |= system_ini_libretro(text)
|
||||
if not cores:
|
||||
raise RuntimeError(f"no core in Recalbox's system.ini files at {self.tag}")
|
||||
return sorted(cores), sorted(standalone)
|
||||
return sorted(cores), sorted(standalone), sorted(libretro & standalone)
|
||||
|
||||
def fetch_requirements(self) -> list[BiosRequirement]:
|
||||
"""Parse es_bios.xml and return BIOS requirements."""
|
||||
@@ -350,7 +365,7 @@ class Scraper(BaseScraper):
|
||||
|
||||
systems[req.system]["files"].append(requirement_entry(req))
|
||||
|
||||
cores, standalone = self._fetch_cores()
|
||||
cores, standalone, dual = self._fetch_cores()
|
||||
return {
|
||||
"platform": "Recalbox",
|
||||
"version": self.tag,
|
||||
@@ -361,6 +376,8 @@ class Scraper(BaseScraper):
|
||||
"verification_mode": "md5",
|
||||
"cores": cores,
|
||||
"standalone_cores": standalone,
|
||||
# Launched both ways: each layout gets its files.
|
||||
**({"dual_mode_cores": dual} if dual else {}),
|
||||
"systems": systems,
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,21 @@ ES_SYSTEMS_URL = (
|
||||
)
|
||||
|
||||
|
||||
def es_systems_dual(text: str) -> set[str]:
|
||||
"""Emulators es_systems.cfg offers both as a libretro core and standalone."""
|
||||
from common import parse_untrusted_xml
|
||||
|
||||
libretro: set[str] = set()
|
||||
standalone: set[str] = set()
|
||||
for emulator in parse_untrusted_xml(text, "es_systems.cfg").iter("emulator"):
|
||||
name = (emulator.get("name") or "").strip()
|
||||
if name == "libretro":
|
||||
libretro |= {(core.text or "").strip() for core in emulator.iter("core")} - {""}
|
||||
elif name:
|
||||
standalone.add(name)
|
||||
return libretro & standalone
|
||||
|
||||
|
||||
def es_systems_cores(text: str) -> tuple[set[str], set[str]]:
|
||||
"""Every core RetroBat's ES offers, and the emulators it runs standalone.
|
||||
|
||||
@@ -207,7 +222,9 @@ class Scraper(BaseScraper):
|
||||
req = urllib.request.Request(es_url, headers={"User-Agent": "retrobios-scraper/1.0"})
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=30) as resp:
|
||||
cores, standalone = es_systems_cores(resp.read().decode("utf-8"))
|
||||
es_text = resp.read().decode("utf-8")
|
||||
cores, standalone = es_systems_cores(es_text)
|
||||
dual = es_systems_dual(es_text)
|
||||
except urllib.error.URLError as e:
|
||||
raise ConnectionError(f"Failed to fetch {es_url}: {e}") from e
|
||||
if not cores:
|
||||
@@ -223,6 +240,8 @@ class Scraper(BaseScraper):
|
||||
"verification_mode": "md5",
|
||||
"cores": sorted(cores),
|
||||
"standalone_cores": sorted(standalone),
|
||||
# Launched both ways: each layout gets its files.
|
||||
**({"dual_mode_cores": sorted(dual)} if dual else {}),
|
||||
"systems": systems,
|
||||
}
|
||||
|
||||
|
||||
@@ -236,6 +236,9 @@ class Scraper(BaseScraper):
|
||||
# emulators ROCKNIX packages beside it.
|
||||
"cores": ["retroarch", *standalone],
|
||||
"standalone_cores": standalone,
|
||||
# RetroArch carries every libretro core beside them, so an
|
||||
# emulator with a libretro build is launched both ways.
|
||||
"dual_mode_cores": list(standalone),
|
||||
"systems": systems,
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ from datetime import datetime, timezone
|
||||
|
||||
import yaml
|
||||
|
||||
from common import yaml_load
|
||||
from safeparse import yaml_load_upstream
|
||||
|
||||
from . import BaseTargetScraper
|
||||
|
||||
@@ -244,7 +244,7 @@ def _parse_es_systems(text: str) -> dict[str, list[str]]:
|
||||
<core_name>: {requireAnyOf: [BR2_PACKAGE_FOO]}
|
||||
"""
|
||||
try:
|
||||
data = yaml_load(text)
|
||||
data = yaml_load_upstream(text)
|
||||
except yaml.YAMLError:
|
||||
return {}
|
||||
|
||||
|
||||
+58
-57
@@ -32,7 +32,8 @@ from common import (
|
||||
resolution_is_hash_exact,
|
||||
resolve_local_file,
|
||||
resolve_platform_cores,
|
||||
runs_standalone,
|
||||
platform_layouts,
|
||||
standalone_set as platform_standalone_set,
|
||||
variant_base_name,
|
||||
)
|
||||
from packresolve import preferred_entries
|
||||
@@ -202,63 +203,63 @@ def profile_claims(
|
||||
# carries its scan candidates, never its named entries.
|
||||
if profile.get("bios_mode") == "agnostic":
|
||||
continue
|
||||
is_standalone = runs_standalone(emu_name, profile, standalone_cores)
|
||||
claims.extend(
|
||||
_archive_claims(
|
||||
emu_name, profile, is_standalone, db, base_dest, placement,
|
||||
zip_contents, data_dir_registry,
|
||||
)
|
||||
)
|
||||
for entry in profile.get("files") or []:
|
||||
if not isinstance(entry, dict):
|
||||
continue
|
||||
# The same rule as the gap report and the builder: an entry the
|
||||
# pack never carries (read from the save directory, a
|
||||
# placeholder, a filename-agnostic scan) arbitrates nothing.
|
||||
if outside_gap_scope(entry, is_standalone):
|
||||
continue
|
||||
# A member of a romset is not a file at the BIOS root: the archive
|
||||
# holding it occupies the destination (_archive_claims). Claiming
|
||||
# the member put FBNeo's msx.zip contents loose at the root.
|
||||
if entry.get("archive"):
|
||||
continue
|
||||
dest = (
|
||||
(entry.get("standalone_path") or entry.get("path"))
|
||||
if is_standalone
|
||||
else entry.get("path")
|
||||
) or entry.get("name") or ""
|
||||
if not dest:
|
||||
continue
|
||||
if placement is None:
|
||||
full = f"{base_dest}/{dest}" if base_dest else dest
|
||||
else:
|
||||
placed = placement.place(
|
||||
{"profile": emu_name, "system": entry.get("system")}, dest
|
||||
for profile, is_standalone in platform_layouts(emu_name, profile, standalone_cores):
|
||||
claims.extend(
|
||||
_archive_claims(
|
||||
emu_name, profile, is_standalone, db, base_dest, placement,
|
||||
zip_contents, data_dir_registry,
|
||||
)
|
||||
if placed is None:
|
||||
)
|
||||
for entry in profile.get("files") or []:
|
||||
if not isinstance(entry, dict):
|
||||
continue
|
||||
full = placed[1]
|
||||
# The owner's own copy is the one the builder ships.
|
||||
local, status = resolve_local_file(
|
||||
{**entry, "source_profile": emu_name},
|
||||
db,
|
||||
zip_contents,
|
||||
dest_hint=dest,
|
||||
data_dir_registry=data_dir_registry,
|
||||
)
|
||||
if status == "name_exact" and _size_the_code_reads(entry, local):
|
||||
status = SIZE_EXACT
|
||||
claims.append(
|
||||
Claim(
|
||||
origin="profile",
|
||||
destination=full,
|
||||
name=entry.get("name", ""),
|
||||
emulator=emu_name,
|
||||
entry=entry,
|
||||
local_path=local,
|
||||
status=status,
|
||||
# The same rule as the gap report and the builder: an entry the
|
||||
# pack never carries (read from the save directory, a
|
||||
# placeholder, a filename-agnostic scan) arbitrates nothing.
|
||||
if outside_gap_scope(entry, is_standalone):
|
||||
continue
|
||||
# A member of a romset is not a file at the BIOS root: the archive
|
||||
# holding it occupies the destination (_archive_claims). Claiming
|
||||
# the member put FBNeo's msx.zip contents loose at the root.
|
||||
if entry.get("archive"):
|
||||
continue
|
||||
dest = (
|
||||
(entry.get("standalone_path") or entry.get("path"))
|
||||
if is_standalone
|
||||
else entry.get("path")
|
||||
) or entry.get("name") or ""
|
||||
if not dest:
|
||||
continue
|
||||
if placement is None:
|
||||
full = f"{base_dest}/{dest}" if base_dest else dest
|
||||
else:
|
||||
placed = placement.place(
|
||||
{"profile": emu_name, "system": entry.get("system")}, dest
|
||||
)
|
||||
if placed is None:
|
||||
continue
|
||||
full = placed[1]
|
||||
# The owner's own copy is the one the builder ships.
|
||||
local, status = resolve_local_file(
|
||||
{**entry, "source_profile": emu_name},
|
||||
db,
|
||||
zip_contents,
|
||||
dest_hint=dest,
|
||||
data_dir_registry=data_dir_registry,
|
||||
)
|
||||
if status == "name_exact" and _size_the_code_reads(entry, local):
|
||||
status = SIZE_EXACT
|
||||
claims.append(
|
||||
Claim(
|
||||
origin="profile",
|
||||
destination=full,
|
||||
name=entry.get("name", ""),
|
||||
emulator=emu_name,
|
||||
entry=entry,
|
||||
local_path=local,
|
||||
status=status,
|
||||
)
|
||||
)
|
||||
)
|
||||
return claims
|
||||
|
||||
|
||||
@@ -524,7 +525,7 @@ def slot_choices(
|
||||
platform_profiles,
|
||||
db,
|
||||
config.get("base_destination", ""),
|
||||
{str(c) for c in config.get("standalone_cores", [])},
|
||||
platform_standalone_set(config),
|
||||
zip_contents,
|
||||
data_dir_registry,
|
||||
)
|
||||
@@ -821,7 +822,7 @@ def scan_platform(
|
||||
relevant,
|
||||
db,
|
||||
config.get("base_destination", ""),
|
||||
{str(c) for c in config.get("standalone_cores", [])},
|
||||
platform_standalone_set(config),
|
||||
build_zip_contents_index(db),
|
||||
load_data_dir_registry(platforms_dir),
|
||||
)
|
||||
|
||||
+12
-5
@@ -8,7 +8,12 @@ from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
from common import _norm_system_id, resolve_platform_cores, runs_standalone
|
||||
from common import (
|
||||
_norm_system_id,
|
||||
platform_layouts,
|
||||
resolve_platform_cores,
|
||||
standalone_set as platform_standalone_set,
|
||||
)
|
||||
from hashing import parse_md5_list
|
||||
from validation import filter_files_by_mode, read_from_system_dir
|
||||
|
||||
@@ -395,7 +400,7 @@ def generate_platform_truth(
|
||||
# The layout rule verify and the pack builder apply: truth guessed its
|
||||
# own from the profile type where the platform names no standalone
|
||||
# emulator, and kept files the pack never carries.
|
||||
standalone_set = {str(c) for c in config.get("standalone_cores") or []}
|
||||
standalone_set = platform_standalone_set(config)
|
||||
|
||||
resolved = resolve_platform_cores(config, profiles, target_cores)
|
||||
|
||||
@@ -449,9 +454,11 @@ def generate_platform_truth(
|
||||
continue
|
||||
cores_profiled.add(emu_name)
|
||||
|
||||
filtered = _archives_not_members(_system_dir_files(
|
||||
profile, runs_standalone(emu_name, profile, standalone_set)
|
||||
))
|
||||
filtered = _archives_not_members([
|
||||
fe
|
||||
for view, standalone in platform_layouts(emu_name, profile, standalone_set)
|
||||
for fe in _system_dir_files(view, standalone)
|
||||
])
|
||||
|
||||
on_platform = {
|
||||
_map_sys_id(sid) for sid in profile.get("systems", [])
|
||||
|
||||
+154
-152
@@ -65,7 +65,9 @@ from common import (
|
||||
resolve_local_file,
|
||||
ProfileSelectionError,
|
||||
resolve_platform_cores,
|
||||
platform_layouts,
|
||||
runs_standalone,
|
||||
standalone_set as platform_standalone_set,
|
||||
sanitize_pack_path,
|
||||
select_emulator_profiles,
|
||||
)
|
||||
@@ -483,7 +485,7 @@ def find_undeclared_files(
|
||||
)
|
||||
|
||||
relevant = resolve_platform_cores(config, profiles, target_cores=target_cores)
|
||||
standalone_set = set(str(c) for c in config.get("standalone_cores", []))
|
||||
standalone_set = platform_standalone_set(config)
|
||||
undeclared = []
|
||||
seen_files: set[tuple] = set()
|
||||
# Key -> the entry reported for it. A later profile reading the same
|
||||
@@ -503,166 +505,166 @@ def find_undeclared_files(
|
||||
if profile.get("bios_mode") == "agnostic":
|
||||
continue
|
||||
|
||||
is_standalone = runs_standalone(emu_name, profile, standalone_set)
|
||||
for profile, is_standalone in platform_layouts(emu_name, profile, standalone_set):
|
||||
|
||||
for f in expand_directory_entries(
|
||||
profile.get("files", []), db, is_standalone
|
||||
):
|
||||
fname = f.get("name", "")
|
||||
# One destination rule for the dedup key and for the entry: a
|
||||
# standalone build without standalone_path falls back on path.
|
||||
# The key used to skip that fallback, so clk's Acorn/basic.rom and
|
||||
# Electron/basic.rom both keyed as "basic.rom" under Batocera's
|
||||
# standalone clk and the second was dropped.
|
||||
if is_standalone:
|
||||
dest = f.get("standalone_path") or f.get("path") or fname
|
||||
else:
|
||||
dest = f.get("path") or fname
|
||||
raw_regions = f.get("region") or []
|
||||
region_key = tuple(
|
||||
str(value) for value in (
|
||||
raw_regions if isinstance(raw_regions, list) else [raw_regions]
|
||||
for f in expand_directory_entries(
|
||||
profile.get("files", []), db, is_standalone
|
||||
):
|
||||
fname = f.get("name", "")
|
||||
# One destination rule for the dedup key and for the entry: a
|
||||
# standalone build without standalone_path falls back on path.
|
||||
# The key used to skip that fallback, so clk's Acorn/basic.rom and
|
||||
# Electron/basic.rom both keyed as "basic.rom" under Batocera's
|
||||
# standalone clk and the second was dropped.
|
||||
if is_standalone:
|
||||
dest = f.get("standalone_path") or f.get("path") or fname
|
||||
else:
|
||||
dest = f.get("path") or fname
|
||||
raw_regions = f.get("region") or []
|
||||
region_key = tuple(
|
||||
str(value) for value in (
|
||||
raw_regions if isinstance(raw_regions, list) else [raw_regions]
|
||||
)
|
||||
)
|
||||
)
|
||||
# Same-name requirements at different paths, for different systems,
|
||||
# or in distinct variant groups are not interchangeable.
|
||||
seen_key = (
|
||||
fname,
|
||||
f.get("archive"),
|
||||
dest,
|
||||
f.get("system"),
|
||||
f.get("variant_group"),
|
||||
region_key,
|
||||
)
|
||||
if not fname:
|
||||
continue
|
||||
first = reported.get(seen_key)
|
||||
duplicate = seen_key in seen_files
|
||||
if duplicate and (first is None or first["profile"] == emu_name):
|
||||
continue
|
||||
verdict = _candidate_verdict(
|
||||
f, fname, is_standalone, include_all, declared_names, dest
|
||||
)
|
||||
if verdict == "settled":
|
||||
seen_files.add(seen_key)
|
||||
continue
|
||||
if verdict == "skip":
|
||||
continue
|
||||
|
||||
archive = f.get("archive")
|
||||
seen_files.add(seen_key)
|
||||
|
||||
# Archived files are grouped by archive
|
||||
if archive:
|
||||
archive_key = (
|
||||
archive,
|
||||
# Same-name requirements at different paths, for different systems,
|
||||
# or in distinct variant groups are not interchangeable.
|
||||
seen_key = (
|
||||
fname,
|
||||
f.get("archive"),
|
||||
dest,
|
||||
f.get("system"),
|
||||
f.get("variant_group"),
|
||||
region_key,
|
||||
is_standalone,
|
||||
)
|
||||
if archive_key not in archive_entries:
|
||||
in_repo = _name_in_index(
|
||||
archive, by_name, by_path_suffix, data_names,
|
||||
by_name_lower,
|
||||
)
|
||||
archive_entries[archive_key] = {
|
||||
"profile": emu_name,
|
||||
"emulator": profile.get("emulator", emu_name),
|
||||
"systems": list(profile.get("systems", [])),
|
||||
"system": f.get("system"),
|
||||
"region": f.get("region"),
|
||||
"variant_group": f.get("variant_group"),
|
||||
"name": archive,
|
||||
"archive": archive,
|
||||
"path": archive,
|
||||
"required": False,
|
||||
"hle_fallback": False,
|
||||
"category": f.get("category", "bios"),
|
||||
"in_repo": in_repo,
|
||||
"note": "",
|
||||
"checks": [],
|
||||
"source_ref": None,
|
||||
"expected": {},
|
||||
"archive_file_count": 0,
|
||||
"archive_required_count": 0,
|
||||
"members": archive_members(archive, profile.get("files", [])),
|
||||
}
|
||||
entry = archive_entries[archive_key]
|
||||
entry["archive_file_count"] += 1
|
||||
if f.get("required", False):
|
||||
entry["archive_required_count"] += 1
|
||||
entry["required"] = True
|
||||
continue
|
||||
if not fname:
|
||||
continue
|
||||
first = reported.get(seen_key)
|
||||
duplicate = seen_key in seen_files
|
||||
if duplicate and (first is None or first["profile"] == emu_name):
|
||||
continue
|
||||
verdict = _candidate_verdict(
|
||||
f, fname, is_standalone, include_all, declared_names, dest
|
||||
)
|
||||
if verdict == "settled":
|
||||
seen_files.add(seen_key)
|
||||
continue
|
||||
if verdict == "skip":
|
||||
continue
|
||||
|
||||
# Resolution: storage flag, then name, then path basename
|
||||
storage = f.get("storage", "")
|
||||
if storage in ("release", "large_file"):
|
||||
in_repo = True
|
||||
elif shipped_on_mismatch and (f.get("md5") or f.get("sha1")):
|
||||
# The entry states what its content should be and the builder
|
||||
# drops a copy that contradicts it, so content decides here
|
||||
# too. A name match would not do: generic names collide across
|
||||
# systems, and answering yes on one describes a pack that will
|
||||
# not contain the file.
|
||||
_lp, _st = resolve_local_file(f, db, dest_hint=dest)
|
||||
in_repo = _lp is not None and _st != "hash_mismatch"
|
||||
else:
|
||||
in_repo = _name_in_index(
|
||||
fname, by_name, by_path_suffix, data_names, by_name_lower,
|
||||
)
|
||||
if not in_repo and dest != fname:
|
||||
path_base = dest.rsplit("/", 1)[-1]
|
||||
in_repo = _name_in_index(
|
||||
path_base, by_name, by_path_suffix, data_names,
|
||||
by_name_lower,
|
||||
archive = f.get("archive")
|
||||
seen_files.add(seen_key)
|
||||
|
||||
# Archived files are grouped by archive
|
||||
if archive:
|
||||
archive_key = (
|
||||
archive,
|
||||
f.get("system"),
|
||||
f.get("variant_group"),
|
||||
region_key,
|
||||
is_standalone,
|
||||
)
|
||||
if not in_repo:
|
||||
# Hash fallback: the repo may hold the content under a
|
||||
# different filename (exos21.rom vs exos21.bin).
|
||||
#
|
||||
# A copy contradicting the declared hash counts as held
|
||||
# only where the builder would ship it. Under existence
|
||||
# the frontend never opens the file, so the pack carries
|
||||
# it and reports the divergence; under a digest mode the
|
||||
# frontend would reject it, the builder leaves it out, and
|
||||
# calling it available here would describe a pack that
|
||||
# does not contain it.
|
||||
if archive_key not in archive_entries:
|
||||
in_repo = _name_in_index(
|
||||
archive, by_name, by_path_suffix, data_names,
|
||||
by_name_lower,
|
||||
)
|
||||
archive_entries[archive_key] = {
|
||||
"profile": emu_name,
|
||||
"emulator": profile.get("emulator", emu_name),
|
||||
"systems": list(profile.get("systems", [])),
|
||||
"system": f.get("system"),
|
||||
"region": f.get("region"),
|
||||
"variant_group": f.get("variant_group"),
|
||||
"name": archive,
|
||||
"archive": archive,
|
||||
"path": archive,
|
||||
"required": False,
|
||||
"hle_fallback": False,
|
||||
"category": f.get("category", "bios"),
|
||||
"in_repo": in_repo,
|
||||
"note": "",
|
||||
"checks": [],
|
||||
"source_ref": None,
|
||||
"expected": {},
|
||||
"archive_file_count": 0,
|
||||
"archive_required_count": 0,
|
||||
"members": archive_members(archive, profile.get("files", [])),
|
||||
}
|
||||
entry = archive_entries[archive_key]
|
||||
entry["archive_file_count"] += 1
|
||||
if f.get("required", False):
|
||||
entry["archive_required_count"] += 1
|
||||
entry["required"] = True
|
||||
continue
|
||||
|
||||
# Resolution: storage flag, then name, then path basename
|
||||
storage = f.get("storage", "")
|
||||
if storage in ("release", "large_file"):
|
||||
in_repo = True
|
||||
elif shipped_on_mismatch and (f.get("md5") or f.get("sha1")):
|
||||
# The entry states what its content should be and the builder
|
||||
# drops a copy that contradicts it, so content decides here
|
||||
# too. A name match would not do: generic names collide across
|
||||
# systems, and answering yes on one describes a pack that will
|
||||
# not contain the file.
|
||||
_lp, _st = resolve_local_file(f, db, dest_hint=dest)
|
||||
in_repo = _st != "not_found" and _lp is not None
|
||||
if in_repo and _st == "hash_mismatch" and shipped_on_mismatch:
|
||||
in_repo = False
|
||||
in_repo = _lp is not None and _st != "hash_mismatch"
|
||||
else:
|
||||
in_repo = _name_in_index(
|
||||
fname, by_name, by_path_suffix, data_names, by_name_lower,
|
||||
)
|
||||
if not in_repo and dest != fname:
|
||||
path_base = dest.rsplit("/", 1)[-1]
|
||||
in_repo = _name_in_index(
|
||||
path_base, by_name, by_path_suffix, data_names,
|
||||
by_name_lower,
|
||||
)
|
||||
if not in_repo:
|
||||
# Hash fallback: the repo may hold the content under a
|
||||
# different filename (exos21.rom vs exos21.bin).
|
||||
#
|
||||
# A copy contradicting the declared hash counts as held
|
||||
# only where the builder would ship it. Under existence
|
||||
# the frontend never opens the file, so the pack carries
|
||||
# it and reports the divergence; under a digest mode the
|
||||
# frontend would reject it, the builder leaves it out, and
|
||||
# calling it available here would describe a pack that
|
||||
# does not contain it.
|
||||
_lp, _st = resolve_local_file(f, db, dest_hint=dest)
|
||||
in_repo = _st != "not_found" and _lp is not None
|
||||
if in_repo and _st == "hash_mismatch" and shipped_on_mismatch:
|
||||
in_repo = False
|
||||
|
||||
checks = _parse_validation(f.get("validation"))
|
||||
entry = {
|
||||
"profile": emu_name,
|
||||
"emulator": profile.get("emulator", emu_name),
|
||||
"systems": list(profile.get("systems", [])),
|
||||
"system": f.get("system"),
|
||||
"region": f.get("region"),
|
||||
"variant_group": f.get("variant_group"),
|
||||
"name": fname,
|
||||
"path": dest,
|
||||
"required": f.get("required", False),
|
||||
"hle_fallback": f.get("hle_fallback", False),
|
||||
"bundled": f.get("bundled", False),
|
||||
"category": f.get("category", "bios"),
|
||||
"in_repo": in_repo,
|
||||
"note": f.get("note", ""),
|
||||
"checks": sorted(checks) if checks else [],
|
||||
"source_ref": f.get("source_ref"),
|
||||
"expected": _build_expected(f, checks),
|
||||
**_identity_of(f),
|
||||
"sha1": f.get("sha1"),
|
||||
"md5": f.get("md5"),
|
||||
}
|
||||
if f.get("contents"):
|
||||
entry["contents"] = f["contents"]
|
||||
if duplicate:
|
||||
first.setdefault("other_claims", []).append(entry)
|
||||
continue
|
||||
reported[seen_key] = entry
|
||||
undeclared.append(entry)
|
||||
checks = _parse_validation(f.get("validation"))
|
||||
entry = {
|
||||
"profile": emu_name,
|
||||
"emulator": profile.get("emulator", emu_name),
|
||||
"systems": list(profile.get("systems", [])),
|
||||
"system": f.get("system"),
|
||||
"region": f.get("region"),
|
||||
"variant_group": f.get("variant_group"),
|
||||
"name": fname,
|
||||
"path": dest,
|
||||
"required": f.get("required", False),
|
||||
"hle_fallback": f.get("hle_fallback", False),
|
||||
"bundled": f.get("bundled", False),
|
||||
"category": f.get("category", "bios"),
|
||||
"in_repo": in_repo,
|
||||
"note": f.get("note", ""),
|
||||
"checks": sorted(checks) if checks else [],
|
||||
"source_ref": f.get("source_ref"),
|
||||
"expected": _build_expected(f, checks),
|
||||
**_identity_of(f),
|
||||
"sha1": f.get("sha1"),
|
||||
"md5": f.get("md5"),
|
||||
}
|
||||
if f.get("contents"):
|
||||
entry["contents"] = f["contents"]
|
||||
if duplicate:
|
||||
first.setdefault("other_claims", []).append(entry)
|
||||
continue
|
||||
reported[seen_key] = entry
|
||||
undeclared.append(entry)
|
||||
|
||||
# Append grouped archive entries
|
||||
for entry in sorted(archive_entries.values(), key=lambda e: e["name"]):
|
||||
@@ -731,7 +733,7 @@ def find_exclusion_notes(
|
||||
|
||||
# Count standalone-only files -but only report as excluded if the
|
||||
# platform does NOT use this emulator in standalone mode
|
||||
standalone_set = set(str(c) for c in config.get("standalone_cores", []))
|
||||
standalone_set = platform_standalone_set(config)
|
||||
is_standalone = runs_standalone(emu_name, profile, standalone_set)
|
||||
if not is_standalone:
|
||||
standalone_files = [
|
||||
|
||||
Reference in new issue
Block a user