mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 06:18:51 -06:00
fix: place hash-selected files like the platform
The hash-selected pack decided a declaration's place with a string prefix test on base_destination, so Batocera's bios_CD_U.bin and bios7.bin stayed at the root of the pack while scph5501.bin went under bios/. platform_destination in packs/paths.py now places a platform declaration for the platform pack, the manifest and the --from-md5 pack.
This commit is contained in:
1 parent
3344cfd2fb
commit
d2f4ef6f9c
5 files changed
+56
-12
No files matched your search
@@ -50,7 +50,7 @@ from packs.manifestentry import (
|
||||
record_unplaceable,
|
||||
)
|
||||
from packs.manifestselect import SelectionIndex
|
||||
from packs.paths import save_layout
|
||||
from packs.paths import platform_destination, save_layout
|
||||
from packs.scope import pack_sections, platform_list_version, system_titles
|
||||
from packs.standalone import standalone_copies, standalone_layouts
|
||||
from resolve.contentlayout import TARGET_KEY
|
||||
@@ -255,12 +255,11 @@ class _ManifestBuild:
|
||||
for file_entry in system.get("files", []):
|
||||
if opts.required_only and file_entry.get("required") is False:
|
||||
continue
|
||||
dest = sanitize_pack_path(file_entry.get("destination", file_entry["name"]))
|
||||
dest, full_dest = platform_destination(file_entry, self.base_dest)
|
||||
if not dest:
|
||||
continue
|
||||
if self.region_drops and dest in self.region_drops:
|
||||
continue
|
||||
full_dest = f"{self.base_dest}/{dest}" if self.base_dest else dest
|
||||
yield sys_id, file_entry, dest, full_dest
|
||||
|
||||
def declaration_order(self, full_dest: str) -> list[tuple[list[str], dict, str]]:
|
||||
|
||||
@@ -13,7 +13,7 @@ from model.profiles import load_emulator_profiles, select_emulator_profiles
|
||||
from model.releaserecord import PACK_SUFFIX
|
||||
from packs.archive import add_pack_member, writing_pack
|
||||
from packs.naming import file_name_part, pack_narrowings, selection_digest
|
||||
from packs.paths import resolve_destination
|
||||
from packs.paths import platform_destination, resolve_destination, under_base
|
||||
from resolve.packfiles import resolve_file, sha1_for_hash
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -168,10 +168,14 @@ def _md5_destination(entry: dict, layout: _Md5Layout, opts: _Md5Settings) -> str
|
||||
# its standalone_path, which --standalone has to reach.
|
||||
dest = resolve_destination(matched_fe, opts.standalone)
|
||||
else:
|
||||
dest = matched_fe.get("destination", matched_fe.get("name", name))
|
||||
# Where the platform pack and the installer put the declaration.
|
||||
_dest, full_dest = platform_destination(matched_fe, layout.base_dest)
|
||||
if full_dest:
|
||||
return full_dest
|
||||
|
||||
if layout.base_dest and not dest.startswith(layout.base_dest):
|
||||
return f"{layout.base_dest}/{dest}"
|
||||
base = layout.base_dest
|
||||
if base and dest != base and not dest.startswith(f"{base}/"):
|
||||
return under_base(dest, base)
|
||||
return dest
|
||||
|
||||
|
||||
|
||||
+20
-1
@@ -9,10 +9,29 @@ from __future__ import annotations
|
||||
from collections.abc import Iterable
|
||||
from dataclasses import dataclass
|
||||
|
||||
from core.paths import comparable_destination, sanitize_pack_path
|
||||
from core.paths import comparable_destination, declared_destination, sanitize_pack_path
|
||||
from resolve.validation import read_from_save_dir
|
||||
|
||||
|
||||
def under_base(path: str, base_dest: str) -> str:
|
||||
"""A pack path below the platform's base destination, joined as a path."""
|
||||
return f"{base_dest}/{path}" if base_dest else path
|
||||
|
||||
|
||||
def platform_destination(entry: dict, base_dest: str) -> tuple[str, str]:
|
||||
"""(destination, pack path) of a platform declaration.
|
||||
|
||||
The destination is the declared one, else the name, made safe. The pack
|
||||
path puts it below the base destination. Both are empty for a
|
||||
declaration that names no file. The platform pack, the install manifest
|
||||
and the hash-selected pack all place a declaration here.
|
||||
"""
|
||||
dest = declared_destination(entry)
|
||||
if not dest:
|
||||
return "", ""
|
||||
return dest, under_base(dest, base_dest)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SaveLayout:
|
||||
"""Where a platform's frontend keeps the save directory it hands a core.
|
||||
|
||||
@@ -13,7 +13,7 @@ from typing import TYPE_CHECKING, TypedDict
|
||||
from model.registry import load_platform_registry
|
||||
from core.hashing import compute_hashes
|
||||
from core.options import reject_unknown
|
||||
from core.paths import EMULATORS_DIR, declared_destination, sanitize_pack_path
|
||||
from core.paths import EMULATORS_DIR, declared_destination
|
||||
from core.ziptools import is_archive_path
|
||||
from model.alternatives import core_file_spares
|
||||
from model.declarations import OUTER_ROOTS, declared_root
|
||||
@@ -50,7 +50,7 @@ from packs.extras import (
|
||||
)
|
||||
from packs.naming import file_name_part, pack_narrowings, platform_pack_name, platform_pack_stem
|
||||
from packs.packcounts import PackCounts, pack_counts
|
||||
from packs.paths import flat_arcname, save_layout
|
||||
from packs.paths import flat_arcname, platform_destination, save_layout
|
||||
from packs.platformreport import print_platform_pack, print_split_packs
|
||||
from packs.readme import build_agnostic_rename_readme, build_readme, save_place
|
||||
from resolve import packfiles as packresolve, regions as resolve_regions, slot as slot_mod
|
||||
@@ -559,13 +559,12 @@ class _PlatformPackBuild:
|
||||
plan, opts = self.plan, self.plan.opts
|
||||
if opts.required_only and file_entry.get("required") is False:
|
||||
return
|
||||
dest = sanitize_pack_path(file_entry.get("destination", file_entry["name"]))
|
||||
dest, full_dest = platform_destination(file_entry, plan.base_dest)
|
||||
if plan.region_drops and dest in plan.region_drops:
|
||||
return
|
||||
if not dest:
|
||||
self._judge_unnamed(sys_id, file_entry)
|
||||
return
|
||||
full_dest = f"{plan.base_dest}/{dest}" if plan.base_dest else dest
|
||||
already_packed = self.placed.holds(full_dest)
|
||||
|
||||
preferred = plan.preferred_entries.get(full_dest)
|
||||
|
||||
@@ -109,6 +109,29 @@ class AUserProvidedSlot(_Fixture):
|
||||
self.assertEqual(report["pack_destinations"], [])
|
||||
|
||||
|
||||
class AHashSelectedPack(_Fixture):
|
||||
"""--from-md5 placed a declaration under the base destination only when
|
||||
its path did not start with the same letters: Batocera's bios_CD_U.bin
|
||||
went to the root of the pack, scph5501.bin to bios/."""
|
||||
|
||||
def test_every_declaration_lands_under_the_base_destination(self):
|
||||
from packs.md5pack import generate_md5_pack
|
||||
|
||||
self._platform([
|
||||
{"name": "sgb.sfc", "destination": "system_sgb.sfc"},
|
||||
{"name": "program.rom", "destination": "program.rom"},
|
||||
])
|
||||
hashes = [("md5", entry["md5"]) for entry in self.db["files"].values()
|
||||
if entry["name"] != "core.bin"]
|
||||
outcome = generate_md5_pack(
|
||||
hashes, self.db, str(self.bios), str(self.root / "out"),
|
||||
platform_name="paths", platforms_dir=str(self.platforms),
|
||||
)
|
||||
with zipfile.ZipFile(outcome.zip_path) as zf:
|
||||
members = set(zf.namelist())
|
||||
self.assertEqual(members, {"system/system_sgb.sfc", "system/program.rom"})
|
||||
|
||||
|
||||
class AnEntryWithoutAFileTakesNoPath(unittest.TestCase):
|
||||
"""EmuDeck's system:md5 entries name no file. verify credited the bare
|
||||
base destination as a pack path, and the comparison failed on ''."""
|
||||
|
||||
Reference in new issue
Block a user