From 81b8dac4343cda7f8a7a3a29f38dada747310142 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Fri, 16 Oct 2026 12:50:48 +0200 Subject: [PATCH] fix: seed agnostic scans from the running build --- scripts/packextras.py | 11 ++++++- tests/test_agnostic_scan_mode.py | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 tests/test_agnostic_scan_mode.py diff --git a/scripts/packextras.py b/scripts/packextras.py index fb054e5c..eeb534a2 100644 --- a/scripts/packextras.py +++ b/scripts/packextras.py @@ -278,12 +278,21 @@ 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 @@ -325,7 +334,7 @@ def _agnostic_scan_extras( # Into the directory the seed entry names, not the root: # yaps2 reads its BIOS from pcsx2/bios/. seed = f.get("path") or "" - if runs_standalone(emu_name, profile, standalone_set or set()): + 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 diff --git a/tests/test_agnostic_scan_mode.py b/tests/test_agnostic_scan_mode.py new file mode 100644 index 00000000..7e165aa0 --- /dev/null +++ b/tests/test_agnostic_scan_mode.py @@ -0,0 +1,50 @@ +"""A filename-agnostic scan seeds only from the build the platform runs. + +armsx2 declares bios_mode: agnostic, and its proverb.zip is a standalone +file the Android app fetches into its arcade/ folder. The scan never read +`mode:` and put it at system/proverb.zip in every pack running armsx2 as a +libretro core, while verify set the entry aside. Reads the repository. +""" + +from __future__ import annotations + +import os +import sys +import unittest +from pathlib import Path + +REPO_ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(REPO_ROOT / "scripts")) + + +class ScanFollowsTheBuild(unittest.TestCase): + def test_no_standalone_seed_in_a_libretro_pack(self): + if not (REPO_ROOT / "database.json").exists(): + self.skipTest("database.json is not built") + previous = os.getcwd() + os.chdir(REPO_ROOT) + self.addCleanup(os.chdir, previous) + from common import load_database, load_emulator_profiles, load_platform_config + from packextras import _collect_emulator_extras + + profiles = load_emulator_profiles("emulators") + entry = next( + (f for f in profiles.get("armsx2", {}).get("files", []) + if f.get("name") == "proverb.zip"), + None, + ) + if entry is None or entry.get("mode") != "standalone": + self.skipTest("armsx2 no longer declares a standalone proverb.zip") + config = load_platform_config("retroarch") + extras = _collect_emulator_extras( + config, "emulators", load_database("database.json"), set(), + config.get("base_destination", ""), profiles, + ) + self.assertNotIn( + ("proverb.zip", "ARMSX2"), + {(e["name"], e.get("source_emulator")) for e in extras}, + ) + + +if __name__ == "__main__": + unittest.main()