From 6df087e3e98a66a469e17992a7d56f004f5e9b39 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 20 Oct 2026 06:36:32 +0200 Subject: [PATCH] fix: a platform's own data trees leave its pack The platform layer names data trees for its systems: retroarch.yml carries dolphin-sys and ppsspp-assets, and Lakka inherits them, while Lakka's core packages install both trees into the system directory. A profile records that with installed_on on its data directory, and the pack and the install manifest now leave those trees out for that platform. --- scripts/common.py | 18 ++++++++++++++++++ scripts/generate_pack.py | 3 +++ tests/test_audit_regressions.py | 19 +++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/scripts/common.py b/scripts/common.py index 686338c7..28a818f5 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -1779,6 +1779,24 @@ def source_yaml_paths(directory: str | Path) -> list[Path]: ] +def installed_data_refs(platform: str, emulators_dir: str = "") -> frozenset[str]: + """Data directories a platform's own packages install beside the cores. + + The platform layer names trees for its systems (retroarch.yml carries + dolphin-sys and ppsspp-assets, and Lakka inherits them), while Lakka's + core packages put both into the system directory themselves. A profile + records that with installed_on on its data directory reference. + """ + emulators_dir = emulators_dir or os.path.join( + os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "emulators") + return frozenset( + str(tree.get("ref", "")) + for profile in load_emulator_profiles(emulators_dir, skip_aliases=False).values() + for tree in profile.get("data_directories") or [] + if isinstance(tree, dict) and platform in (tree.get("installed_on") or []) + ) + + def load_emulator_profiles( emulators_dir: str, skip_aliases: bool = True, diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index 71ed0b29..6c6b666d 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -33,6 +33,7 @@ from pathlib import Path sys.path.insert(0, os.path.dirname(__file__)) from common import resolve_platform_cores as _platform_cores from common import ( + installed_data_refs, platform_arg, require_directory, target_listing_line, @@ -400,6 +401,8 @@ def _data_directory_members( ref_key = dd.get("ref", "") if not ref_key or not data_registry or ref_key not in data_registry: continue + if ref_key in installed_data_refs(platform_name): + continue entry = data_registry[ref_key] allowed = entry.get("for_platforms") if allowed and platform_name not in allowed: diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 1547bfa1..63694527 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -4625,6 +4625,25 @@ class BundledFilesAreNotToSource(unittest.TestCase): }) self.assertEqual(unknown, []) + def test_a_tree_the_platform_installs_leaves_its_pack(self): + """retroarch.yml names dolphin-sys and ppsspp-assets and Lakka + inherits them, while Lakka's core packages install both trees.""" + import tempfile + + import yaml as _yaml + + sys.path.insert(0, str(ROOT / "scripts")) + import common + + with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp: + Path(tmp, "dolphin.yml").write_text(_yaml.safe_dump({ + "emulator": "Dolphin", "type": "libretro", "files": [], + "data_directories": [{"ref": "dolphin-sys", "installed_on": ["lakka"]}]})) + self.assertEqual(common.installed_data_refs("lakka", tmp), frozenset({"dolphin-sys"})) + self.assertEqual(common.installed_data_refs("retroarch", tmp), frozenset()) + source = (ROOT / "scripts" / "generate_pack.py").read_text(encoding="utf-8") + self.assertIn("if ref_key in installed_data_refs(platform_name):", source) + def test_the_pack_builder_skips_it(self): source = (ROOT / "scripts" / "packextras.py").read_text(encoding="utf-8") self.assertIn('if u.get("bundled"):', source)