diff --git a/install.ps1 b/install.ps1 index cc2cde485..856b63076 100644 --- a/install.ps1 +++ b/install.ps1 @@ -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 diff --git a/install.py b/install.py index 7195b612a..37402c339 100644 --- a/install.py +++ b/install.py @@ -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 [] diff --git a/install.sh b/install.sh index 2fda0f85b..20a68d2d7 100755 --- a/install.sh +++ b/install.sh @@ -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 diff --git a/install/launchers/index.json b/install/launchers/index.json index e56f127fe..e522dfad2 100644 --- a/install/launchers/index.json +++ b/install/launchers/index.json @@ -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 }, { diff --git a/installer/choices.py b/installer/choices.py index 939ee9141..f8853e2f6 100644 --- a/installer/choices.py +++ b/installer/choices.py @@ -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: diff --git a/installer/removal.py b/installer/removal.py index 8e2feb60e..295ed9d20 100644 --- a/installer/removal.py +++ b/installer/removal.py @@ -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 [] diff --git a/tests/test_install_removal.py b/tests/test_install_removal.py index b4f230097..ca6964daf 100644 --- a/tests/test_install_removal.py +++ b/tests/test_install_removal.py @@ -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: