fix: place AdvanceMAME's sets in EmuELEC's dir_rom

AdvanceMAME reads its sets from dir_rom, a list of folders
(advance/osd/fileio.c:74, doc/advmame.d:680,699-701). EmuELEC's
advmame.rc sets dir_rom /storage/roms/mame (advmame.rc:11), and
advmame.sh rewrites /roms/mame to /roms/arcade when it is started for
the arcade system (advmame.sh:26-30). The extractor kept the keys under
the BIOS root alone: it now records those under the roms root too, and
a key the script rewrites gives one record for arcade and one for every
other system. A configgen record carries the systems it is written for.

The profile lays its 29 sets out at the top of dir_rom. On EmuELEC they
land in roms/mame. The 12 root archives AdvanceMAME alone claimed there
now hold the copies of the cores that also declare them (mame, geolith),
none of them lost.

A destination outside the BIOS tree is no proof of content: the moved
entry resolves by its layout path alone. roms/mame/konamigv.zip took
bios/Arcade/MAME/konamigv.zip, MAME 0.289's set, by that tail.
This commit is contained in:
Abdessamad Derraz committed 2026-11-10 13:07:12 +01:00
1 parent 4a5c693b66
commit 8eaffcfead
7 files changed
+384 -29

No files matched your search

+4 -1
View File
@@ -1541,12 +1541,15 @@ def resolve_local_file(
layout = file_entry.get("layout_path")
if layout and layout != dest_hint:
plain = {k: v for k, v in file_entry.items() if k != "layout_path"}
# A destination outside the BIOS tree says nothing of the collection:
# EmuELEC's roms/mame/konamigv.zip is not bios/Arcade/MAME's set.
outside = file_entry.get("unprefixed") or file_entry.get("root")
answers = [
resolve_local_file(
plain, db, zip_contents, dest_hint=hint, _depth=_depth,
data_dir_registry=data_dir_registry,
)
for hint in (dest_hint, str(layout))
for hint in ((str(layout),) if outside else (dest_hint, str(layout)))
]
for found in answers:
if found[0] is not None and (
+3 -1
View File
@@ -37,11 +37,13 @@ class Launcher:
device: str | None = None
# The machines the platform offers under the record's systems.
machines: list[str] | None = None
# The platform systems the record is written for, none for every one.
systems: list[str] | None = None
def entry(self) -> dict[str, Any]:
"""The platform YAML form, in a fixed key order, unset keys left out."""
order = (
"emulator", "build", "kind", "slot", "names", "expands",
"emulator", "systems", "build", "kind", "slot", "names", "expands",
"case_insensitive", "search_dir", "passes_to",
"fails_when_missing", "fails_scope", "depends_on_option",
"device", "machines", "source_ref",
+49 -21
View File
@@ -38,6 +38,8 @@ EMULATORS = f"{SX05RE}/emulators"
LIBRETRO = f"{SX05RE}/libretro"
RETROARCH_MK = f"{SX05RE}/libretro_base/retroarch/package.mk"
BIOS_ROOT = "/storage/roms/bios"
# The roms root that holds it (packages/sx05re/libretro_base/retroarch/package.mk:112,117).
ROMS_ROOT = "/storage/roms"
_EMU_TEST = re.compile(r'\$\{?EMU\}?"?\s*==?\s*"([^"]+)"')
_ARM = re.compile(r'^\s*((?:"[^"]+"\|?)+)\)\s*$')
@@ -487,8 +489,18 @@ def hatari(tree: RepoTree, runs: Runs) -> list[Launcher]:
]
_ADVMAME_SYSTEM = re.compile(r'^\s*if \[\[ "\$\{1\}" = "([\w-]+)" \]\]; then$')
_ADVMAME_SED = re.compile(r'^\s*sed -i "s\|([^|]+)\|([^|]+)\|g" \$\{CONFIG_DIR\}/advmame\.rc$')
def advancemame(tree: RepoTree, runs: Runs) -> list[Launcher]:
"""Folder keys of the advmame.rc package.mk installs, one per device branch."""
"""Folder keys of the advmame.rc package.mk installs, one per device branch.
A key under the roms root is one too: dir_rom is /storage/roms/mame. The
start script rewrites the config for the system it is launched for
(advmame.sh:26-30): /roms/mame becomes /roms/arcade for arcade, so that
system reads its own record.
"""
package = f"{EMULATORS}/advancemame"
mk = _read(tree, f"{package}/package.mk")
installs = [
@@ -501,8 +513,8 @@ def advancemame(tree: RepoTree, runs: Runs) -> list[Launcher]:
by_value: dict[tuple[tuple[str, str], ...], list[tuple[str, set[int], int]]] = {}
for mk_line, file in installs:
path = f"{package}/config/{file}"
keys = [s for s in settings(tree.read(path), separator=" ") if _under(s.value)]
if not keys:
keys = [s for s in settings(tree.read(path), separator=" ") if _under(s.value, ROMS_ROOT)]
if not any(_under(s.value) for s in keys):
raise LauncherPatternMissing(path, f"key naming a folder under {BIOS_ROOT}")
value = tuple((s.key, s.value) for s in keys)
by_value.setdefault(value, []).append((path, {s.line for s in keys}, mk_line))
@@ -511,25 +523,41 @@ def advancemame(tree: RepoTree, runs: Runs) -> list[Launcher]:
((value, configs),) = by_value.items()
script = _read(tree, f"{package}/bin/advmame.sh")
run_line, _ = script.find(r"^\s*(?:\w+=\S+ )*advmame ", "advmame start")
test_line, test = script.find(_ADVMAME_SYSTEM.pattern, "system test", end=run_line)
sed_line, sed = script.find(_ADVMAME_SED.pattern, "system rewrite", test_line + 1, test_line + 1)
name = posixpath.basename(script.path)
refs = [
runs.ref(name),
*((path, lines) for path, lines, _ in configs),
(mk.path, {mk_line for _, _, mk_line in configs}),
(script.path, {run_line}),
]
return [
Launcher(
emulator=runs.emulator(name),
build="standalone",
kind="passes_path",
names=[],
source_ref=source_ref(refs),
search_dir=folder,
passes_to=f"advmame.rc {key}",
)
for key, folder in value
]
def refs(*lines: int) -> str:
return source_ref([
runs.ref(name),
*((path, lines) for path, lines, _ in configs),
(mk.path, {mk_line for _, _, mk_line in configs}),
(script.path, {run_line, *lines}),
])
found = []
for key, folder in value:
rewritten = folder.replace(sed.group(1), sed.group(2))
if rewritten != folder:
# Every system but the one the script rewrites the key for, and
# that system with the rewritten folder.
found.append(Launcher(
emulator=runs.emulator(name), build="standalone", kind="passes_path", names=[],
source_ref=refs(test_line, sed_line), search_dir=folder,
passes_to=f"advmame.rc {key}",
depends_on_option=f"system != {test.group(1)}",
))
found.append(Launcher(
emulator=runs.emulator(name), build="standalone", kind="passes_path", names=[],
source_ref=refs(test_line, sed_line), search_dir=rewritten,
passes_to=f"advmame.rc {key}", systems=[test.group(1)],
))
continue
found.append(Launcher(
emulator=runs.emulator(name), build="standalone", kind="passes_path", names=[],
source_ref=refs(), search_dir=folder, passes_to=f"advmame.rc {key}",
))
return found
def mame(tree: RepoTree, runs: Runs) -> list[Launcher]: