mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
fix: appimages cached in the main checkout
This commit is contained in:
1 parent
eddb26f104
commit
472b06a3e0
4 files changed
+27
-9
No files matched your search
@@ -11,12 +11,15 @@ from pathlib import Path
|
||||
|
||||
import core_probe as cp
|
||||
from core import upstream
|
||||
from core.paths import REPO_ROOT
|
||||
from core.statefile import now_iso
|
||||
from probes.host import main_cache
|
||||
from probes.standaloneemulators import Emulator
|
||||
from scraper.base_scraper import github_json
|
||||
|
||||
CACHE = REPO_ROOT / ".cache" / "standalone"
|
||||
|
||||
def cache_root() -> Path:
|
||||
"""Where fetched AppImages live: the main checkout's .cache, shared by every worktree."""
|
||||
return main_cache() / "standalone"
|
||||
|
||||
|
||||
def select_asset(releases: Sequence[dict], endswith: str, contains: str) -> dict | None:
|
||||
@@ -51,12 +54,12 @@ def github_releases(repo: str) -> list[dict]:
|
||||
f"cannot list the releases of {repo}", timeout=60, error=cp.ProbeError)
|
||||
|
||||
|
||||
def fetch(emu: Emulator, cache: Path = CACHE) -> dict:
|
||||
def fetch(emu: Emulator, cache: Path | None = None) -> dict:
|
||||
"""Download the asset the platform picks, unpack it, and describe it."""
|
||||
asset = select_asset(github_releases(emu.repo), emu.asset_endswith, emu.asset_contains)
|
||||
if not asset:
|
||||
raise cp.ProbeError(f"{emu.repo}: no release asset matches the {emu.platform} rule")
|
||||
folder = cache / emu.name
|
||||
folder = (cache or cache_root()) / emu.name
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
partial = folder / f"{asset['name']}.part"
|
||||
# Whole or absent, retried on a cut stream (core.upstream.download).
|
||||
@@ -90,9 +93,9 @@ def unpack(appimage: Path) -> Path:
|
||||
return tree
|
||||
|
||||
|
||||
def installed(emu: Emulator, sha256: str | None, cache: Path = CACHE) -> tuple[dict, Path]:
|
||||
def installed(emu: Emulator, sha256: str | None, cache: Path | None = None) -> tuple[dict, Path]:
|
||||
"""The fetched asset to run: the one named by sha256, else the newest."""
|
||||
folder = cache / emu.name
|
||||
folder = (cache or cache_root()) / emu.name
|
||||
metas = sorted(folder.glob("*/asset.json"), key=lambda p: p.stat().st_mtime, reverse=True)
|
||||
for path in metas:
|
||||
meta = json.loads(path.read_text(encoding="utf-8"))
|
||||
|
||||
@@ -230,14 +230,15 @@ class ContentChecked(unittest.TestCase):
|
||||
self.assertEqual(code, 0)
|
||||
self.assertEqual(len(runs), len(regioncheck.VARIANTS))
|
||||
|
||||
def test_default_content_and_cores_are_the_main_checkout_cache(self) -> None:
|
||||
def test_default_caches_are_the_main_checkout_cache(self) -> None:
|
||||
"""A linked worktree holds no .cache: the default reads the main checkout's."""
|
||||
from probes import content
|
||||
from probes import appimage, content
|
||||
from unattended import worktree
|
||||
|
||||
cache = worktree.main_checkout() / ".cache"
|
||||
self.assertEqual(content.content_root(), cache / "test-content")
|
||||
self.assertEqual(host.Paths.default().content, content.content_root())
|
||||
self.assertEqual(appimage.cache_root(), cache / "standalone")
|
||||
|
||||
|
||||
class ContentList(unittest.TestCase):
|
||||
|
||||
@@ -67,6 +67,20 @@ class AppImage(unittest.TestCase):
|
||||
with self.assertRaises(cp.ProbeError):
|
||||
appimage.appimage_offset(b"hsqs" + bytes(60))
|
||||
|
||||
def test_default_cache_is_resolved_at_each_call(self) -> None:
|
||||
"""fetch and run share one cache: the root is read when called, not
|
||||
fixed at import to the checkout the module was loaded from."""
|
||||
from unittest import mock
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as scratch, \
|
||||
mock.patch.object(appimage, "cache_root", return_value=Path(scratch)):
|
||||
asset = Path(scratch) / "duckstation" / "abc" / "asset.json"
|
||||
asset.parent.mkdir(parents=True)
|
||||
asset.write_text('{"sha256": "abc", "name": "x.AppImage"}', encoding="utf-8")
|
||||
(asset.parent / "tree").mkdir()
|
||||
meta, tree = appimage.installed(emus.EMULATORS["duckstation"], None)
|
||||
self.assertEqual((meta["sha256"], tree), ("abc", asset.parent / "tree"))
|
||||
|
||||
|
||||
class Framebuffer(unittest.TestCase):
|
||||
def test_reads_rgb_and_skips_colormap_and_padding(self) -> None:
|
||||
|
||||
+1
-1
@@ -1286,7 +1286,7 @@ python scripts/standalone_probe.py check pcsx2 \
|
||||
|
||||
| Step | What happens |
|
||||
|------|--------------|
|
||||
| Binary | The release asset the platform installs, chosen by its installer's own rule. EmuDeck's `getReleaseURLGH` takes the first asset, over GitHub's release list in its order, pre-releases included, whose name matches: `DuckStation-x64.AppImage` and `pcsx2-*-Qt.AppImage`. It is downloaded into `.cache/standalone/<emulator>/<sha256>/` and unpacked with `unsquashfs` at the offset the AppImage runtime computes, so the runtime is never run. The record names the asset, its release tag, its URL and its sha256 |
|
||||
| Binary | The release asset the platform installs, chosen by its installer's own rule. EmuDeck's `getReleaseURLGH` takes the first asset, over GitHub's release list in its order, pre-releases included, whose name matches: `DuckStation-x64.AppImage` and `pcsx2-*-Qt.AppImage`. It is downloaded into `.cache/standalone/<emulator>/<sha256>/` of the main checkout and unpacked with `unsquashfs` at the offset the AppImage runtime computes, so the runtime is never run. The record names the asset, its release tag, its URL and its sha256 |
|
||||
| Settings | Written before each repetition in a scratch data folder, `$XDG_CONFIG_HOME/duckstation/settings.ini` and `$XDG_CONFIG_HOME/PCSX2/inis/PCSX2.ini`, the places the emulators read on Linux. The BIOS folder setting names the staged BIOS folder, as EmuDeck points it at `Emulation/bios`. Software rendering, no update check, no setup wizard. `--setting SECTION.KEY=VALUE` adds one. The record lists every setting |
|
||||
| Sandbox | The allowlist bubblewrap sandbox of `core_probe.py`: the unpacked emulator, the content folder and the staged BIOS folder read-only, the repetition's scratch folder the one writable path, no network. Xvfb runs inside it, on the sandbox's own `/tmp`, so the display is private to the run. `--require-sandbox` refuses to run without bubblewrap |
|
||||
| Screen | Xvfb keeps its screen as a file (`-fbdir`). The probe reads it every `--interval` seconds, `--samples` times, and hashes each sample's pixels. `--png-dir` writes each distinct sample as PNG for review |
|
||||
|
||||
Reference in new issue
Block a user