From 149157279e27e0ebc717218891d40df715340d59 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Fri, 16 Oct 2026 07:42:26 +0200 Subject: [PATCH] fix: copy a settled core file to its root path --- scripts/packextras.py | 6 ++++-- tests/test_extra_identity.py | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/scripts/packextras.py b/scripts/packextras.py index dfb82d30..7ae85b2c 100644 --- a/scripts/packextras.py +++ b/scripts/packextras.py @@ -609,8 +609,10 @@ def _collect_emulator_extras( else: raw = f.get("path") or fname dest = f"{raw}{fname}" if raw.endswith("/") else raw - if dest == fname: - continue # no alternative destination + # 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 diff --git a/tests/test_extra_identity.py b/tests/test_extra_identity.py index 9a52d7e3..0294c1a6 100644 --- a/tests/test_extra_identity.py +++ b/tests/test_extra_identity.py @@ -97,5 +97,30 @@ class UnsourceableIsNoCopy(unittest.TestCase): ) +class BareNameIsADestination(unittest.TestCase): + """geargrafx reads syscard1.pce at the root of the system directory; + Recalbox declares it only under pcenginecd/. The declaration settles the + core's need on the promise that the builder copies the file to the + core's path, and the second pass skipped every entry with no path.""" + + def test_a_root_copy_of_a_file_declared_in_a_subdirectory(self): + profiles = {"geargrafx": { + "emulator": "Geargrafx", "type": "libretro", "systems": ["pce"], + "files": [{"name": "syscard1.pce"}], + }} + config = {"cores": ["geargrafx"], "systems": {"pcenginecd": {"files": [ + {"name": "syscard1.pce", "destination": "pcenginecd/syscard1.pce"}]}}} + db = { + "files": {"s1": {"name": "syscard1.pce", "path": "bios/NEC/syscard1.pce", + "size": 10, "sha1": "s1", "md5": "m1", "crc32": "c1"}}, + "indexes": {"by_name": {"syscard1.pce": ["s1"]}, "by_md5": {"m1": "s1"}, + "by_crc32": {"c1": "s1"}, "by_path_suffix": {}}, + } + extras = _collect_emulator_extras( + config, "emulators", db, {"pcenginecd/syscard1.pce"}, "", profiles + ) + self.assertIn("syscard1.pce", [e["destination"] for e in extras]) + + if __name__ == "__main__": unittest.main()