mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
fix: one system name rule for install and remove
The removal resolved --system against the list's ids alone, so a platform name or a site title that installed the files was refused as an unknown system. Both paths now call resolve_systems.
This commit is contained in:
1 parent
475dfe0e0a
commit
80f42f0573
7 files changed
+50
-23
No files matched your search
+1
-1
@@ -16,7 +16,7 @@
|
||||
# and Invoke-WebRequest throws on a cut transfer before the hash is read:
|
||||
# the site's build rewrites this line there (scripts/sitebootstrap.py).
|
||||
$mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
|
||||
$defaultInstallSha256 = "2b5ff4827b1bce9f6b56773ead57aaeb0e3849bb59006b84a0347b6e609e37e9"
|
||||
$defaultInstallSha256 = "5f4faa860489f00b33b167c9644ce15f7b24a38a9f04b3d6e10a813426cfe41a"
|
||||
# The pin above refuses any changed byte: this cap only stops a body that
|
||||
# cannot be the installer (a sign-in portal's page) before it is hashed.
|
||||
$maximumInstallerBytes = 8MB
|
||||
|
||||
+11
-6
@@ -10713,6 +10713,15 @@ def resolve_choices(
|
||||
return chosen
|
||||
|
||||
|
||||
def resolve_systems(values: list[str], manifest: dict | None, files: list[dict],
|
||||
omitted: list[dict]) -> list[str]:
|
||||
"""The systems --system names, for an install and a removal alike: the
|
||||
list's ids, the platform's own names and the site's titles. --remove
|
||||
took the ids alone, and refused the psx that installed the files."""
|
||||
return resolve_choices(values, available_choices(files, omitted)["systems"], "system",
|
||||
system_aliases(manifest), key_file_holders(files, omitted))
|
||||
|
||||
|
||||
def parse_selection(text: str, count: int, ordered: bool = False) -> list[int]:
|
||||
"""Numbers typed at a prompt: `3`, `1,4`, `2-5`, or `all`, 1-based.
|
||||
|
||||
@@ -11010,10 +11019,7 @@ def _requested_narrowing(
|
||||
sys.exit(1)
|
||||
choices = available_choices(files, omitted)
|
||||
try:
|
||||
systems = resolve_choices(
|
||||
args.system or [], choices["systems"], "system", system_aliases(manifest),
|
||||
key_file_holders(files, omitted),
|
||||
)
|
||||
systems = resolve_systems(args.system or [], manifest, files, omitted)
|
||||
cores = resolve_choices(args.core or [], choices["cores"], "core")
|
||||
regions = resolve_regions(args.region or [])
|
||||
except ValueError as exc:
|
||||
@@ -20382,8 +20388,7 @@ def run_removal(args: argparse.Namespace) -> int:
|
||||
omitted = list(manifest.get("omitted_files") or [])
|
||||
known = available_choices(every, omitted)
|
||||
try:
|
||||
systems = resolve_choices(args.system, known["systems"], "system") \
|
||||
if args.system else []
|
||||
systems = resolve_systems(args.system or [], manifest, every, omitted)
|
||||
cores = resolve_choices(args.core, known["cores"], "core") if args.core else []
|
||||
emulators = resolve_choices(args.emulator, sorted(emulator_names(
|
||||
manifest, every, omitted)), "emulator") if args.emulator else []
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/ins
|
||||
# curl or wget stop on a cut transfer before the hash is read: the site's
|
||||
# build rewrites this line there (scripts/sitebootstrap.py).
|
||||
MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
|
||||
DEFAULT_INSTALL_SHA256="2b5ff4827b1bce9f6b56773ead57aaeb0e3849bb59006b84a0347b6e609e37e9"
|
||||
DEFAULT_INSTALL_SHA256="5f4faa860489f00b33b167c9644ce15f7b24a38a9f04b3d6e10a813426cfe41a"
|
||||
# The pin above refuses any changed byte: this cap only stops a body that
|
||||
# cannot be the installer (a sign-in portal's page) before it is hashed.
|
||||
MAX_INSTALLER_BYTES=8388608
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
{
|
||||
"dest": "roms/ports/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1463517,
|
||||
"sha256": "2b5ff4827b1bce9f6b56773ead57aaeb0e3849bb59006b84a0347b6e609e37e9",
|
||||
"size": 1461487,
|
||||
"sha256": "5f4faa860489f00b33b167c9644ce15f7b24a38a9f04b3d6e10a813426cfe41a",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -71,8 +71,8 @@
|
||||
"muos": {
|
||||
"archive": {
|
||||
"dest": "ARCHIVE/RetroBIOS.muxapp",
|
||||
"size": 1517142,
|
||||
"sha256": "49e0e307999989bacd59356939e137fcce171a1b8116c246c560259de4e921ca"
|
||||
"size": 1515112,
|
||||
"sha256": "c4892f7c93182806e795d7bcc6c0c8568670c018fde4461fdad99f1976255426"
|
||||
},
|
||||
"members": [
|
||||
{
|
||||
@@ -92,8 +92,8 @@
|
||||
{
|
||||
"name": "RetroBIOS/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1463517,
|
||||
"sha256": "2b5ff4827b1bce9f6b56773ead57aaeb0e3849bb59006b84a0347b6e609e37e9",
|
||||
"size": 1461487,
|
||||
"sha256": "5f4faa860489f00b33b167c9644ce15f7b24a38a9f04b3d6e10a813426cfe41a",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -166,8 +166,8 @@
|
||||
{
|
||||
"dest": ".config/modules/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1463517,
|
||||
"sha256": "2b5ff4827b1bce9f6b56773ead57aaeb0e3849bb59006b84a0347b6e609e37e9",
|
||||
"size": 1461487,
|
||||
"sha256": "5f4faa860489f00b33b167c9644ce15f7b24a38a9f04b3d6e10a813426cfe41a",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
|
||||
+10
-4
@@ -173,6 +173,15 @@ def resolve_choices(
|
||||
return chosen
|
||||
|
||||
|
||||
def resolve_systems(values: list[str], manifest: dict | None, files: list[dict],
|
||||
omitted: list[dict]) -> list[str]:
|
||||
"""The systems --system names, for an install and a removal alike: the
|
||||
list's ids, the platform's own names and the site's titles. --remove
|
||||
took the ids alone, and refused the psx that installed the files."""
|
||||
return resolve_choices(values, available_choices(files, omitted)["systems"], "system",
|
||||
system_aliases(manifest), key_file_holders(files, omitted))
|
||||
|
||||
|
||||
def parse_selection(text: str, count: int, ordered: bool = False) -> list[int]:
|
||||
"""Numbers typed at a prompt: `3`, `1,4`, `2-5`, or `all`, 1-based.
|
||||
|
||||
@@ -470,10 +479,7 @@ def _requested_narrowing(
|
||||
sys.exit(1)
|
||||
choices = available_choices(files, omitted)
|
||||
try:
|
||||
systems = resolve_choices(
|
||||
args.system or [], choices["systems"], "system", system_aliases(manifest),
|
||||
key_file_holders(files, omitted),
|
||||
)
|
||||
systems = resolve_systems(args.system or [], manifest, files, omitted)
|
||||
cores = resolve_choices(args.core or [], choices["cores"], "core")
|
||||
regions = resolve_regions(args.region or [])
|
||||
except ValueError as exc:
|
||||
|
||||
@@ -14,7 +14,7 @@ from collections.abc import Collection, Iterable
|
||||
from pathlib import Path, PurePosixPath
|
||||
from typing import NamedTuple
|
||||
|
||||
from installer.choices import available_choices, emulator_names, resolve_choices
|
||||
from installer.choices import available_choices, emulator_names, resolve_choices, resolve_systems
|
||||
from installer.console import QUIT_CODE, _answer_yes
|
||||
from installer.destination import card_dest
|
||||
from installer.detect_frontends import detect_platforms
|
||||
@@ -789,8 +789,7 @@ def run_removal(args: argparse.Namespace) -> int:
|
||||
omitted = list(manifest.get("omitted_files") or [])
|
||||
known = available_choices(every, omitted)
|
||||
try:
|
||||
systems = resolve_choices(args.system, known["systems"], "system") \
|
||||
if args.system else []
|
||||
systems = resolve_systems(args.system or [], manifest, every, omitted)
|
||||
cores = resolve_choices(args.core, known["cores"], "core") if args.core else []
|
||||
emulators = resolve_choices(args.emulator, sorted(emulator_names(
|
||||
manifest, every, omitted)), "emulator") if args.emulator else []
|
||||
|
||||
@@ -179,6 +179,23 @@ class RemoveOneOfTwoSystems(unittest.TestCase):
|
||||
install.record_options(repo.setup()["choice"]))
|
||||
|
||||
|
||||
class TheNamesAnInstallTakes(unittest.TestCase):
|
||||
"""--remove read --system against the list's ids alone: the psx that
|
||||
installed the PlayStation files stopped the removal on "unknown system"."""
|
||||
|
||||
def test_a_platform_name_removes_what_it_installed(self):
|
||||
with SharedRepository() as repo:
|
||||
listed = repo.root / "install" / "retroarch.json"
|
||||
manifest = json.loads(listed.read_text())
|
||||
manifest["system_names"] = {"sony-playstation": ["psx"]}
|
||||
listed.write_text(json.dumps(manifest))
|
||||
proc = repo.run("--system", "psx", "--system", "nintendo-gba", "--yes")
|
||||
self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
|
||||
proc = repo.run("--remove", "--system", "psx", "--yes")
|
||||
self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
|
||||
self.assertEqual(sorted(repo.snapshot()), sorted(GBA_ONLY + ["shared.bin"]))
|
||||
|
||||
|
||||
class NeverTouched(unittest.TestCase):
|
||||
def test_a_changed_file_and_one_added_by_hand_stay(self):
|
||||
with SharedRepository() as repo:
|
||||
|
||||
Reference in new issue
Block a user