From 8a053d590e9610624957e0116deb23bf943d31c6 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sun, 18 Oct 2026 20:44:39 +0200 Subject: [PATCH] fix: publish every config file the installer reads --- platforms/_registry.yml | 67 +++++++++++++++++++++++++++++++++++++++++ tests/test_install.py | 54 +++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) diff --git a/platforms/_registry.yml b/platforms/_registry.yml index 00d97f2f..ed2d4760 100644 --- a/platforms/_registry.yml +++ b/platforms/_registry.yml @@ -180,26 +180,81 @@ platforms: method: config_file config: $HOME/.var/app/org.libretro.RetroArch/config/retroarch/retroarch.cfg parse_key: system_directory + - os: linux + method: config_file + config: $HOME/snap/retroarch/current/.config/retroarch/retroarch.cfg + parse_key: system_directory - os: linux method: config_file config: $HOME/.config/retroarch/retroarch.cfg parse_key: system_directory # configuration.c reads /RetroArch/config; a value # left at default is ~/Documents/RetroArch/system (platform_darwin.m). + # Older builds kept the file one level up. - os: darwin method: config_file config: $HOME/Library/Application Support/RetroArch/config/retroarch.cfg parse_key: system_directory bios_path: $HOME/Documents/RetroArch/system + - os: darwin + method: config_file + config: $HOME/Library/Application Support/RetroArch/retroarch.cfg + parse_key: system_directory + bios_path: $HOME/Documents/RetroArch/system # Beside retroarch.exe first, then %APPDATA%; default \system. + # The folders its installers, Steam and ES-DE put it in. - os: windows method: config_file config: 'C:\RetroArch-Win64\retroarch.cfg' parse_key: system_directory + - os: windows + method: config_file + config: 'C:\RetroArch\retroarch.cfg' + parse_key: system_directory + - os: windows + method: config_file + config: '%ProgramFiles%\RetroArch-Win64\retroarch.cfg' + parse_key: system_directory + - os: windows + method: config_file + config: '%ProgramFiles%\RetroArch\retroarch.cfg' + parse_key: system_directory + - os: windows + method: config_file + config: '%ProgramFiles%\ES-DE\Emulators\RetroArch-Win64\retroarch.cfg' + parse_key: system_directory + - os: windows + method: config_file + config: '%ProgramFiles%\ES-DE\Emulators\RetroArch\retroarch.cfg' + parse_key: system_directory + - os: windows + method: config_file + config: '%ProgramFiles(x86)%\RetroArch-Win64\retroarch.cfg' + parse_key: system_directory + - os: windows + method: config_file + config: '%ProgramFiles(x86)%\RetroArch\retroarch.cfg' + parse_key: system_directory + - os: windows + method: config_file + config: '%ProgramFiles(x86)%\ES-DE\Emulators\RetroArch-Win64\retroarch.cfg' + parse_key: system_directory + - os: windows + method: config_file + config: '%ProgramFiles(x86)%\ES-DE\Emulators\RetroArch\retroarch.cfg' + parse_key: system_directory - os: windows method: config_file config: '%APPDATA%\RetroArch\retroarch.cfg' parse_key: system_directory + - os: windows + method: config_file + config: '%ProgramFiles(x86)%\Steam\steamapps\common\RetroArch\retroarch.cfg' + parse_key: system_directory + - os: windows + method: config_file + config: '%ProgramFiles%\Steam\steamapps\common\RetroArch\retroarch.cfg' + parse_key: system_directory # Handheld firmwares that run RetroArch as their frontend: muOS, # ArkOS, and the stock Linux of Anbernic devices (dmenu). - os: linux @@ -363,6 +418,18 @@ platforms: target_source: null install: detect: + # retrodeck.json since the cfg-to-json migration (global.sh:149-153), + # retrodeck.cfg before it; a home moved to an SD card lives only there. + - os: linux + method: config_file + config: $HOME/.var/app/net.retrodeck.retrodeck/config/retrodeck/retrodeck.json + parse_key: paths.rd_home_path + bios_path: $HOME/retrodeck + - os: linux + method: config_file + config: $HOME/.var/app/net.retrodeck.retrodeck/config/retrodeck/retrodeck.cfg + parse_key: rdhome + bios_path: $HOME/retrodeck - os: linux method: path_exists path: $HOME/.var/app/net.retrodeck.retrodeck diff --git a/tests/test_install.py b/tests/test_install.py index 19210a12..e267e788 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -965,6 +965,60 @@ class DetectionFollowsTheRegistry(unittest.TestCase): rules.add((name, "file_exists", tuple(files), rule["bios_path"])) self.assertEqual(set(install._EMBEDDED_RULES), rules) + def test_every_config_file_read_is_published(self): + """The registry published five RetroArch config files and the fixed + RetroDECK folder; the installer also read Snap, the older macOS file, + C:\\RetroArch, Program Files, ES-DE, Steam and RetroDECK's own + config. A manifest reader saw a subset of what the installer does.""" + import yaml # noqa: PLC0415 + + registry = yaml.safe_load( + (Path(__file__).resolve().parents[1] / "platforms" / "_registry.yml").read_text() + ) + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + env = { + "HOME": str(root / "home"), "APPDATA": str(root / "appdata"), + "ProgramFiles": str(root / "pf"), "ProgramFiles(x86)": str(root / "pf86"), + } + + def expand(text: str) -> str: + text = text.replace("$HOME", env["HOME"]) + for var in ("ProgramFiles(x86)", "ProgramFiles", "APPDATA"): + text = text.replace(f"%{var}%", env[var]) + return str(Path(text.replace("\\", "/"))) + + published = { + (rule["os"], expand(rule["config"])) + for entry in registry["platforms"].values() + for rule in (entry.get("install") or {}).get("detect", []) + if rule["method"] == "config_file" + } + read: set[tuple[str, str]] = set() + + def record(os_type: str): + def probe(path, *_args, **_kwargs): + read.add((os_type, str(Path(str(path).replace("\\", "/"))))) + return None + return probe + + with unittest.mock.patch.dict(os.environ, env), \ + unittest.mock.patch.object(install, "_detect_embedded", lambda: []), \ + unittest.mock.patch.object(install, "_detect_android", lambda: []): + for os_type in ("linux", "darwin", "windows"): + with unittest.mock.patch.object( + install, "_parse_retroarch_system_dir", record(os_type) + ): + install.detect_platforms(os_type) + with unittest.mock.patch.object(Path, "is_file", lambda _self: True): + for folder in install._windows_retroarch_dirs(): + read.add(("windows", str(folder / "retroarch.cfg"))) + retrodeck = root / "home/.var/app/net.retrodeck.retrodeck/config/retrodeck" + read |= {("linux", str(retrodeck / "retrodeck.json")), + ("linux", str(retrodeck / "retrodeck.cfg"))} + # The default Steam library is the Program Files one, already read. + self.assertEqual(sorted(read - published), []) + def test_the_first_embedded_match_wins(self): with unittest.mock.patch.object(install, "_parse_os_release", return_value={}), \ unittest.mock.patch.object(