mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 22:38:54 -06:00
fix: one rule for where a standalone app reads
The site kept a table of entries the app reads outside data_root and the installer never read it: the manifests copied Cemu's shared fonts, the Amiberry ROMs and the YAPS2 resources to folders the apps do not open. The facts now live in each profile as outside_data_root with their source_ref, and resolve.layout.data_root_place answers for both. Rows that changed no place were dropped (citra, ymir, cxbx-reloaded, ppsspp-1.5.4, hatari, the DEV9 files of aethersx2 and armsx2), and the fsuae row predated its ROMs/Kickstarts standalone_path, which the launcher walks: its page now gives that folder, as the installer does.
This commit is contained in:
1 parent
13f92eaf4a
commit
46e6b94171
21 files changed
+213
-899
No files matched your search
@@ -9,6 +9,7 @@ from core.paths import REPO_ROOT
|
||||
from packs.archive import PackRecord
|
||||
from packs.emulatorpack import build_emulator_pack
|
||||
from packs.manifestentry import manifest_entry
|
||||
from resolve.layout import data_root_place
|
||||
|
||||
|
||||
def _placed_copies(copies: list[dict], dests: list[str]) -> list[dict]:
|
||||
@@ -78,10 +79,11 @@ def _one_content(held: list[str], entries: dict[str, dict], emulator: str) -> li
|
||||
return [min(own or held, key=lambda dest: (dest.count("/"), len(dest), dest))]
|
||||
|
||||
|
||||
def _profile_roots(profile: dict) -> dict[str, str]:
|
||||
"""The data_root of each system the profile names a findable place for."""
|
||||
def _profile_roots(profile: dict) -> dict[str, tuple[str, str]]:
|
||||
"""The data_root key and copy target of each system the profile names a
|
||||
findable place for."""
|
||||
return {
|
||||
_DATA_ROOT_SYSTEMS[key]: target
|
||||
_DATA_ROOT_SYSTEMS[key]: (key, target)
|
||||
for key, value in (profile.get("data_root") or {}).items()
|
||||
if key in _DATA_ROOT_SYSTEMS and isinstance(value, dict)
|
||||
and (target := _data_root_target(_DATA_ROOT_SYSTEMS[key], value.get("path", "")))
|
||||
@@ -157,9 +159,13 @@ def _profile_copies(
|
||||
source = _copy_source(entry, by_tail, entries, profile_name)
|
||||
if source is None:
|
||||
continue
|
||||
where = PurePosixPath(entry["standalone_path"])
|
||||
placed: dict[str, list[str]] = {}
|
||||
for system, root in roots.items():
|
||||
for system, (key, root) in roots.items():
|
||||
# The app reads the file there, else no copy on this system.
|
||||
place = data_root_place(profile, entry, key)
|
||||
if not place:
|
||||
continue
|
||||
where = PurePosixPath(place)
|
||||
sep = "\\" if system == "windows" else "/"
|
||||
target = root if str(where.parent) == "." else (
|
||||
root + sep + str(where.parent).replace("/", sep))
|
||||
@@ -168,8 +174,9 @@ def _profile_copies(
|
||||
if not placed:
|
||||
continue
|
||||
copy = {"file": source, "targets": placed}
|
||||
if where.name != PurePosixPath(source).name:
|
||||
copy["as"] = where.name
|
||||
name = PurePosixPath(entry["standalone_path"]).name
|
||||
if name != PurePosixPath(source).name:
|
||||
copy["as"] = name
|
||||
copies.append(copy)
|
||||
return copies
|
||||
|
||||
|
||||
@@ -207,6 +207,45 @@ def standalone_layout_path(entry: dict, profile: dict) -> str | None:
|
||||
return entry.get("path") or None
|
||||
|
||||
|
||||
def _names_entry(pattern: str, entry: dict) -> bool:
|
||||
"""Whether an ``outside_data_root`` pattern names this entry: ``*``, a
|
||||
path or standalone_path prefix ending in ``/``, or a name."""
|
||||
if pattern == "*":
|
||||
return True
|
||||
if pattern.endswith("/"):
|
||||
return any(str(entry.get(key) or "").startswith(pattern)
|
||||
for key in ("path", "standalone_path"))
|
||||
return entry.get("name") == pattern
|
||||
|
||||
|
||||
def outside_data_root(profile: dict, entry: dict) -> set[str]:
|
||||
"""The data_root keys on which the app reads this entry from another
|
||||
folder than data_root: every key ({"*"}), some, or none."""
|
||||
keys: set[str] = set()
|
||||
for rule in profile.get("outside_data_root") or ():
|
||||
if any(_names_entry(pattern, entry) for pattern in rule.get("files") or ()):
|
||||
keys |= set(rule.get("systems") or ()) or {"*"}
|
||||
return keys
|
||||
|
||||
|
||||
def data_root_place(profile: dict, entry: dict, key: str = "") -> str:
|
||||
"""The path under data_root where the standalone app reads this entry, or "".
|
||||
|
||||
Nothing for a profile without data_root, an entry the libretro core alone
|
||||
reads, or one the profile's ``outside_data_root`` lists (on ``key``, or on
|
||||
any key when ``key`` is empty). The site prints this place and the
|
||||
installer copies the file there, so both read it here.
|
||||
"""
|
||||
if not isinstance(entry, dict) or not profile.get("data_root"):
|
||||
return ""
|
||||
if entry.get("mode") == "libretro":
|
||||
return ""
|
||||
excluded = outside_data_root(profile, entry)
|
||||
if "*" in excluded or (key in excluded if key else excluded):
|
||||
return ""
|
||||
return str(standalone_layout_path(entry, profile) or "")
|
||||
|
||||
|
||||
def standalone_destination(
|
||||
entry: dict, profile: dict, bindings: dict[str, tuple[str, str]]
|
||||
) -> tuple[str, str] | None:
|
||||
|
||||
@@ -366,7 +366,7 @@ def _card_place_details(f: dict, profile: dict, owner: str, data_href: str) -> l
|
||||
fsystem = f.get("system", "")
|
||||
# Where the app reads it under its data folder, said beside the path:
|
||||
# Ryujinx's card read "Path: system/prod.keys" with no root.
|
||||
place = standalone_place(owner, profile, f) if owner else ""
|
||||
place = standalone_place(profile, f) if owner else ""
|
||||
under = f", in [the data folder]({data_href})"
|
||||
standalone_path = f.get("standalone_path", "")
|
||||
if (fpath and fpath != fname) or (place and place == fpath):
|
||||
|
||||
@@ -556,10 +556,10 @@ def _any_name_steps(emu_name: str, profile: dict, entry: dict, href: str,
|
||||
get = f"Get one from the {named_system_link(profile['systems'][0], '../')} files."
|
||||
steps = [get]
|
||||
folders: list[str] = []
|
||||
if profile.get("type") == "standalone" and standalone_place(name, profile, entry):
|
||||
if profile.get("type") == "standalone" and standalone_place(profile, entry):
|
||||
steps.append("Put it in this folder:")
|
||||
folders = ['<div id="data-folder" class="rb-anchor"></div>', "",
|
||||
*data_folder_block(name, profile, [entry])]
|
||||
*data_folder_block(profile, [entry])]
|
||||
else:
|
||||
folder = _any_name_folder(profile, entry)
|
||||
if folder:
|
||||
@@ -583,13 +583,13 @@ def _data_folder_intro(name: str, profile: dict) -> list[str]:
|
||||
if not profile.get("data_root"):
|
||||
return []
|
||||
files = [f for f in profile.get("files") or [] if isinstance(f, dict)]
|
||||
placed = [f for f in files if standalone_place(name, profile, f)]
|
||||
placed = [f for f in files if standalone_place(profile, f)]
|
||||
subject = ("The app" if profile.get("type") == "standalone"
|
||||
else "Run on its own, the app")
|
||||
lead = (f"{subject} reads its files from this folder:" if placed
|
||||
else f"{subject} keeps its data in this folder:")
|
||||
return ['<div id="data-folder" class="rb-anchor"></div>', "", lead, "",
|
||||
*data_folder_block(name, profile, files)]
|
||||
*data_folder_block(profile, files)]
|
||||
|
||||
|
||||
def _emulator_intro(emu_name: str, profile: dict, href: str = "", name: str = "") -> str:
|
||||
|
||||
+10
-78
@@ -17,7 +17,7 @@ from model.guides import platform_guides, terminals, install_command
|
||||
from model.platforms import load_platform_config
|
||||
from model.registry import list_release_pack_platforms
|
||||
from model.profiles import reads_own_files
|
||||
from resolve.layout import runs_standalone, standalone_layout_path
|
||||
from resolve.layout import data_root_place, runs_standalone
|
||||
from resolve.standalone import standalone_set
|
||||
from resolve.validation import installed_everywhere, installed_with_emulator
|
||||
from sitegen import markup
|
||||
@@ -240,83 +240,15 @@ def install_block(name: str, profile: dict) -> list[str]:
|
||||
]))
|
||||
|
||||
|
||||
# Entries whose folder the app opens is not data_root joined to their
|
||||
# standalone_path (or path): the pack builder still places them by that
|
||||
# field, so the joined path names a place the app never reads. Their page
|
||||
# gives the data folder alone. A row names the profile, the entries (a name,
|
||||
# a path prefix ending in "/", or "*" for every file) and, when the rule
|
||||
# holds on some systems only, the data_root keys it covers.
|
||||
FOLDER_ONLY: tuple[tuple[str, tuple[str, ...], tuple[str, ...], str], ...] = (
|
||||
("amiberry", ("*",), (),
|
||||
"the app reads every ROM, Kickstarts included, under ROMs/ of its folder"),
|
||||
("fsuae", ("fsuae/Kickstarts/",), (),
|
||||
"the app reads Kickstarts from ROMs/Kickstart/ of its folder"),
|
||||
("citra", ("Citra/sysdata/",), (),
|
||||
"the app reads its keys and shared fonts from sysdata/ of its folder"),
|
||||
("ymir", ("*",), (),
|
||||
"the app reads its IPL, cartridge and CD-block ROMs from roms/ipl/, roms/cart/ and roms/cdb/"),
|
||||
("mame", ("*",), (),
|
||||
"the app reads every set under roms/ of its working directory"),
|
||||
("eka2l1", ("data/",), ("ios",),
|
||||
"on iOS the data folder is the data-storage folder itself, so data/ would be one level too deep"),
|
||||
("aethersx2", ("resources/", "eeprom.dat", "flash.dat"), (),
|
||||
"resources sit beside the program, and eeprom.dat and flash.dat in the working directory"),
|
||||
("cemu", ("resources/sharedFonts/",), (),
|
||||
"the shared fonts are read from the program's data path"),
|
||||
("cxbx-reloaded", ("hlsl/",), (),
|
||||
"the shaders are read from beside the program"),
|
||||
("ppsspp-1.5.4", ("ppsspp-1.5.4/assets/",), (),
|
||||
"the assets tree is read from beside the program"),
|
||||
("yaps2", ("resources/",), (),
|
||||
"resources are read from beside the program"),
|
||||
("hatari", ("tos.img", "tos.sym"), (),
|
||||
"the TOS image is read from the install data directory"),
|
||||
("armsx2", ("proverb.zip",), ("android",),
|
||||
"the Android app keeps the arcade boot programs in its internal storage"),
|
||||
("armsx2", ("eeprom.dat", "flash.dat"), (),
|
||||
"eeprom.dat and flash.dat are read from the working directory"),
|
||||
("kenji-nx", ("drivers/",), (),
|
||||
"a driver archive is unpacked under drivers/, a layout not confirmed in the source"),
|
||||
)
|
||||
|
||||
|
||||
def folder_only_matches(pattern: str, entry: dict) -> bool:
|
||||
"""Whether a FOLDER_ONLY pattern names this entry."""
|
||||
if pattern == "*":
|
||||
return True
|
||||
if pattern.endswith("/"):
|
||||
return any(str(entry.get(key) or "").startswith(pattern)
|
||||
for key in ("path", "standalone_path"))
|
||||
return entry.get("name") == pattern
|
||||
|
||||
|
||||
def _folder_only(name: str, entry: dict) -> set[str]:
|
||||
"""The data_root keys on which this entry's joined path is not the app's
|
||||
folder: every key ({"*"}), some, or none."""
|
||||
keys: set[str] = set()
|
||||
for profile, patterns, only, _reason in FOLDER_ONLY:
|
||||
if profile == name and any(folder_only_matches(p, entry) for p in patterns):
|
||||
keys |= set(only) or {"*"}
|
||||
return keys
|
||||
|
||||
|
||||
def standalone_place(name: str, profile: dict, entry: dict, key: str = "") -> str:
|
||||
def standalone_place(profile: dict, entry: dict, key: str = "") -> str:
|
||||
"""Where under the data folder the app reads this entry, or "".
|
||||
|
||||
Only what the app opens there: a lone app's ``standalone_path`` or
|
||||
``path``, a dual profile's ``standalone_path`` or the ``path`` of an
|
||||
entry its standalone build alone reads. Nothing for an entry found by
|
||||
name, one the app ships, one the libretro core alone reads, or one
|
||||
FOLDER_ONLY lists (on ``key``, or on any key when ``key`` is empty).
|
||||
The place the installer copies the file to (resolve.layout.data_root_place),
|
||||
and nothing for an entry the app ships.
|
||||
"""
|
||||
if not isinstance(entry, dict) or not profile.get("data_root"):
|
||||
if not isinstance(entry, dict) or comes_with_app(entry):
|
||||
return ""
|
||||
if entry.get("mode") == "libretro" or comes_with_app(entry):
|
||||
return ""
|
||||
excluded = _folder_only(name, entry)
|
||||
if "*" in excluded or (key in excluded if key else excluded):
|
||||
return ""
|
||||
return str(standalone_layout_path(entry, profile) or "")
|
||||
return data_root_place(profile, entry, key)
|
||||
|
||||
|
||||
OS_LABELS = {"windows": "Windows", "macos": "macOS", "linux": "Linux",
|
||||
@@ -340,7 +272,7 @@ def under_root(root: str, folder: str) -> str:
|
||||
return ", else ".join(shown)
|
||||
|
||||
|
||||
def _data_root_folder(name: str, profile: dict, key: str, entries: list[dict]) -> str:
|
||||
def _data_root_folder(profile: dict, key: str, entries: list[dict]) -> str:
|
||||
"""The one folder under the root that every entry the app reads sits
|
||||
in, or "": VICE places 3 of its 322 files in DRIVES/, and naming that
|
||||
folder would send the other 319 there."""
|
||||
@@ -349,14 +281,14 @@ def _data_root_folder(name: str, profile: dict, key: str, entries: list[dict]) -
|
||||
mode = f.get("mode")
|
||||
if mode == "libretro" or comes_with_app(f):
|
||||
continue
|
||||
place = standalone_place(name, profile, f, key)
|
||||
place = standalone_place(profile, f, key)
|
||||
if not place:
|
||||
return ""
|
||||
folders.add(place.rpartition("/")[0])
|
||||
return folders.pop() if len(folders) == 1 else ""
|
||||
|
||||
|
||||
def data_folder_block(name: str, profile: dict, entries: list[dict] | None = None) -> list[str]:
|
||||
def data_folder_block(profile: dict, entries: list[dict] | None = None) -> list[str]:
|
||||
"""The app's data folder, one tab per system it runs on, each with the
|
||||
code that names it and its note: 61 profiles cite it and no page showed
|
||||
it. ``entries`` are the files the folder is for: when they all sit in
|
||||
@@ -372,7 +304,7 @@ def data_folder_block(name: str, profile: dict, entries: list[dict] | None = Non
|
||||
if not isinstance(root, dict) or not root.get("path"):
|
||||
continue
|
||||
path = str(root["path"])
|
||||
line = under_root(path, _data_root_folder(name, profile, key, entries))
|
||||
line = under_root(path, _data_root_folder(profile, key, entries))
|
||||
if key == "android" and path.startswith("Android/data/"):
|
||||
line += ", on the internal storage."
|
||||
body = [line]
|
||||
|
||||
Reference in new issue
Block a user