mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
fix: read installed_on from the run's profiles
This commit is contained in:
1 parent
815341ba3b
commit
74c59ad3b9
7 files changed
+55
-33
No files matched your search
@@ -16,7 +16,6 @@ from model.profilekinds import reads_own_files as reads_own_files
|
||||
from model.safeparse import require_yaml
|
||||
from model.sources import source_yaml_file
|
||||
from model.systems import norm_system_id, system_index
|
||||
from core.paths import REPO_ROOT
|
||||
|
||||
|
||||
# The content tests a profile can declare in ``validation:``, each run by
|
||||
@@ -180,7 +179,7 @@ def source_yaml_paths(directory: str | Path) -> list[Path]:
|
||||
]
|
||||
|
||||
|
||||
def installed_data_refs(platform: str, emulators_dir: str = "") -> frozenset[str]:
|
||||
def installed_data_refs_in(platform: str, profiles: Mapping[str, dict]) -> frozenset[str]:
|
||||
"""Data directories a platform's own packages install beside the cores.
|
||||
|
||||
The platform layer names trees for its systems (retroarch.yml carries
|
||||
@@ -188,11 +187,9 @@ def installed_data_refs(platform: str, emulators_dir: str = "") -> frozenset[str
|
||||
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(
|
||||
REPO_ROOT, "emulators")
|
||||
return frozenset(
|
||||
str(tree.get("ref", ""))
|
||||
for profile in load_emulator_profiles(emulators_dir, skip_aliases=False).values()
|
||||
for profile in profiles.values()
|
||||
for tree in profile.get("data_directories") or []
|
||||
if isinstance(tree, dict) and platform in (tree.get("installed_on") or [])
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ def tree_members(
|
||||
) -> dict[str, int]:
|
||||
"""Archive path -> size of every file the platform's data trees can add."""
|
||||
from packs import datatrees
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.profiles import installed_data_refs_in, load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from packs.archive import Placed
|
||||
from packs.paths import flat_arcname
|
||||
@@ -21,14 +21,13 @@ def tree_members(
|
||||
config = load_platform_config(platform, platforms_dir)
|
||||
base_dest = config.get("base_destination", "")
|
||||
registry = load_data_dir_registry(platforms_dir)
|
||||
core_trees = datatrees.core_data_trees(
|
||||
config, load_emulator_profiles(emulators_dir), platform, registry,
|
||||
)
|
||||
profiles = load_emulator_profiles(emulators_dir)
|
||||
core_trees = datatrees.core_data_trees(config, profiles, platform, registry)
|
||||
members: dict[str, int] = {}
|
||||
for src, full in datatrees.data_directory_members(
|
||||
config.get("systems", {}), registry,
|
||||
platform, base_dest, Placed(False),
|
||||
core_trees=core_trees,
|
||||
core_trees=core_trees, installed=installed_data_refs_in(platform, profiles),
|
||||
):
|
||||
members[flat_arcname(full, base_dest, True)] = os.path.getsize(src)
|
||||
return members
|
||||
|
||||
@@ -13,7 +13,7 @@ from core.hashing import compute_hashes
|
||||
from core.options import reject_unknown
|
||||
from model.declarations import declared_root
|
||||
from model.registry import load_versions
|
||||
from model.profiles import entry_system_ids, installed_data_refs
|
||||
from model.profiles import entry_system_ids, installed_data_refs_in
|
||||
from model.systems import norm_system_id
|
||||
from packs.archive import PackRecord, Placed, add_pack_member
|
||||
from packs.datadirs import cache_lock, revisioned
|
||||
@@ -55,7 +55,7 @@ def core_data_trees(
|
||||
the core (and the build's own folder, ``pack_structure``), as the
|
||||
emulator pack lays them out. Left out: a tree the platform's package
|
||||
installs, for this core or another reading the same tree
|
||||
(``installed_data_refs``), one the build bundles or the platform never
|
||||
(``installed_data_refs_in``), one the build bundles or the platform never
|
||||
opens (``deliverable``), and one whose registry entry names the
|
||||
platforms it serves (``for_platforms``) without this one. A standalone build reads its data below its own folder, which a
|
||||
tree's destination does not describe, so its trees stay out, as does a
|
||||
@@ -66,7 +66,7 @@ def core_data_trees(
|
||||
"""
|
||||
if not data_registry:
|
||||
return []
|
||||
installed = installed_data_refs(platform_name)
|
||||
installed = installed_data_refs_in(platform_name, profiles)
|
||||
handed = standalone_set(config, profiles)
|
||||
# Relative to base_destination, which the members are written under. A
|
||||
# platform with none writes its BIOS folder into every destination, and
|
||||
@@ -146,15 +146,18 @@ class _TreeWalkOptions(TypedDict, total=False):
|
||||
required_only: bool
|
||||
core_trees: Iterable[dict]
|
||||
reclaim: dict[str, str] | None
|
||||
installed: frozenset[str]
|
||||
|
||||
|
||||
def _carried_tree(dd: dict, data_registry: dict | None, platform_name: str) -> str | None:
|
||||
def _carried_tree(
|
||||
dd: dict, data_registry: dict | None, platform_name: str, installed: frozenset[str],
|
||||
) -> str | None:
|
||||
"""The cache folder of a tree reference the pack carries ("" when the
|
||||
cache does not hold it), or None for a tree the pack does not carry."""
|
||||
ref_key = dd.get("ref", "")
|
||||
if not ref_key or not data_registry or ref_key not in data_registry:
|
||||
return None
|
||||
if ref_key in installed_data_refs(platform_name):
|
||||
if ref_key in installed:
|
||||
return None
|
||||
entry = data_registry[ref_key]
|
||||
allowed = entry.get("for_platforms")
|
||||
@@ -202,6 +205,10 @@ def data_directory_members(
|
||||
each tree the pack carries and the cache does not hold: the caller
|
||||
reports it and counts its run incomplete.
|
||||
|
||||
``installed`` names the trees the platform's packages install
|
||||
(installed_data_refs_in over the run's profiles): the walk leaves them
|
||||
out.
|
||||
|
||||
These are not BIOS and carry no hash of their own: they are whole
|
||||
trees an emulator reads, refreshed from upstream, so what ships is
|
||||
whatever the cache holds. The pack and the install manifest both read
|
||||
@@ -215,12 +222,13 @@ def data_directory_members(
|
||||
reclaim = options.get("reclaim")
|
||||
required_only = options.get("required_only", False)
|
||||
core_trees = options.get("core_trees", ())
|
||||
installed = options.get("installed", frozenset())
|
||||
# Data directories from _data_dirs.yml
|
||||
for systems, dd in _tree_references(pack_systems, core_trees):
|
||||
needed = dd.get("required") is not False
|
||||
if required_only and not needed:
|
||||
continue
|
||||
local_path = _carried_tree(dd, data_registry, platform_name)
|
||||
local_path = _carried_tree(dd, data_registry, platform_name, installed)
|
||||
if local_path is None:
|
||||
continue
|
||||
ref_key = dd.get("ref", "")
|
||||
|
||||
@@ -12,7 +12,7 @@ from core.options import reject_unknown
|
||||
from core.paths import EMULATORS_DIR, REPO_ROOT, declared_destination, sanitize_pack_path
|
||||
from model.declarations import OUTER_ROOTS, declared_root, outer_layout
|
||||
from model.platforms import load_platform_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.profiles import installed_data_refs_in, load_emulator_profiles
|
||||
from model.registry import load_data_dir_registry, platform_registry_at
|
||||
from model.systems import platform_system_names
|
||||
from packs import slots
|
||||
@@ -474,6 +474,7 @@ class _ManifestBuild:
|
||||
self.pack_systems, self.data_registry, self.platform_name, self.base_dest,
|
||||
self.placed, refs_out=data_refs, required_only=required_only,
|
||||
core_trees=core_trees,
|
||||
installed=installed_data_refs_in(self.platform_name, self.emu_profiles),
|
||||
reclaim=reclaim, uncached_out=uncached,
|
||||
))
|
||||
if opts.uncached_out is not None:
|
||||
|
||||
@@ -18,7 +18,7 @@ from core.ziptools import is_archive_path
|
||||
from model.alternatives import core_file_spares
|
||||
from model.declarations import OUTER_ROOTS, declared_root
|
||||
from model.platforms import load_platform_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.profiles import installed_data_refs_in, load_emulator_profiles
|
||||
from model.releaserecord import PACK_SUFFIX
|
||||
from packs import slots
|
||||
from packs.archive import (
|
||||
@@ -936,6 +936,7 @@ class _PlatformPackBuild:
|
||||
pack_systems, plan.opts.data_registry, plan.platform_name, plan.base_dest,
|
||||
self.placed, required_only=required_only,
|
||||
core_trees=core_trees, uncached_out=uncached,
|
||||
installed=installed_data_refs_in(plan.platform_name, plan.emu_profiles or {}),
|
||||
):
|
||||
# The installer writes a data tree member without the bit.
|
||||
add_pack_member(self.zf, src, self._flat(full), executable=False)
|
||||
|
||||
Reference in new issue
Block a user