mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
fix: a removal drops the system name it recorded
The record keeps --system as typed (psx). Removing that system compared the recorded name to the id, kept psx in the choice, and the next update installed the PlayStation files again.
This commit is contained in:
1 parent
80f42f0573
commit
ced68a9135
7 files changed
+72
-24
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 = "5f4faa860489f00b33b167c9644ce15f7b24a38a9f04b3d6e10a813426cfe41a"
|
||||
$defaultInstallSha256 = "f0ecb3333aecd54fd0195ff5735f68e17da2979abc142dfdeafecde6cfe89201"
|
||||
# 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
|
||||
|
||||
+29
-6
@@ -10722,6 +10722,23 @@ def resolve_systems(values: list[str], manifest: dict | None, files: list[dict],
|
||||
system_aliases(manifest), key_file_holders(files, omitted))
|
||||
|
||||
|
||||
def system_ids(names: Iterable[str], manifest: dict | None, files: list[dict],
|
||||
omitted: list[dict]) -> dict[str, str]:
|
||||
"""Each of names that --system takes, with the system id it stands for:
|
||||
a record keeps the psx typed at the install."""
|
||||
known = available_choices(files, omitted)["systems"]
|
||||
aliases, holders = system_aliases(manifest), key_file_holders(files, omitted)
|
||||
ids: dict[str, str] = {}
|
||||
for name in names:
|
||||
try:
|
||||
picked = resolve_choices([name], known, "system", aliases, holders)
|
||||
except ValueError:
|
||||
continue
|
||||
if len(picked) == 1:
|
||||
ids[name] = picked[0]
|
||||
return ids
|
||||
|
||||
|
||||
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.
|
||||
|
||||
@@ -19735,14 +19752,15 @@ def _choice_names(options: list[tuple[str, str | None]], flag: str) -> list[str]
|
||||
|
||||
|
||||
def _choice_without(choice: list[str], flag: str, names: Collection[str],
|
||||
left: list[str]) -> list[str]:
|
||||
left: list[str], ids: Mapping[str, str] | None = None) -> list[str]:
|
||||
"""A recorded choice once names of flag are taken out: those it named
|
||||
go, and a choice that named none gets the names left. A flag left with
|
||||
no name is dropped."""
|
||||
no name is dropped. ids gives a recorded name the id it stands for."""
|
||||
options = [option for option in record_options(choice) if option[0] != "--all-files"]
|
||||
gone = {name.casefold() for name in names}
|
||||
same = ids or {}
|
||||
remaining = [name for name in (_choice_names(options, flag) or left)
|
||||
if name.casefold() not in gone]
|
||||
if same.get(name, name).casefold() not in gone]
|
||||
kept = [option for option in options if option[0] != flag]
|
||||
if remaining:
|
||||
kept.append((flag, ",".join(remaining)))
|
||||
@@ -19762,6 +19780,7 @@ class _RemovalScope(NamedTuple):
|
||||
named_cores: list[str]
|
||||
others: dict[tuple[str, str], str]
|
||||
wanted: set[str]
|
||||
system_ids: dict[str, str]
|
||||
|
||||
def norm(self, dest: str) -> str:
|
||||
"""dest as the drive compares it, folded where it folds case."""
|
||||
@@ -19788,7 +19807,10 @@ def _removal_scope(
|
||||
wanted = {_drive_key(dest, fold) for dest in files}
|
||||
# What stays chosen once the removal is done, as an install names it:
|
||||
# the systems or cores the record named, else every one of the list.
|
||||
named_systems = {name.casefold() for name in _choice_names(options, "--system")}
|
||||
recorded_systems = _choice_names(options, "--system")
|
||||
ids = system_ids(recorded_systems, manifest, list(manifest.get("files") or []),
|
||||
list(manifest.get("omitted_files") or []))
|
||||
named_systems = {ids.get(name, name).casefold() for name in recorded_systems}
|
||||
staying_systems = {name for name in known["systems"] if not named_systems
|
||||
or name.casefold() in named_systems} - chosen_systems
|
||||
named_cores = _choice_names(options, "--core")
|
||||
@@ -19796,7 +19818,7 @@ def _removal_scope(
|
||||
else set(known["cores"]) | set(manifest.get("core_names") or {})
|
||||
) - chosen_cores
|
||||
return _RemovalScope(fold, known, options, chosen_systems, chosen_cores,
|
||||
staying_systems, staying_cores, named_cores, others, wanted)
|
||||
staying_systems, staying_cores, named_cores, others, wanted, ids)
|
||||
|
||||
|
||||
def _removal_takes(scope: _RemovalScope, found: tuple, dest: str) -> bool:
|
||||
@@ -19857,7 +19879,8 @@ def _removal_choice(scope: _RemovalScope, recorded: list[str], *, files: Collect
|
||||
return recorded
|
||||
if scope.chosen_systems:
|
||||
choice = _choice_without(recorded, "--system", scope.chosen_systems,
|
||||
sorted(scope.staying_systems | scope.chosen_systems))
|
||||
sorted(scope.staying_systems | scope.chosen_systems),
|
||||
scope.system_ids)
|
||||
if not _choice_names(record_options(choice), "--system"):
|
||||
return None
|
||||
return choice
|
||||
|
||||
+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="5f4faa860489f00b33b167c9644ce15f7b24a38a9f04b3d6e10a813426cfe41a"
|
||||
DEFAULT_INSTALL_SHA256="f0ecb3333aecd54fd0195ff5735f68e17da2979abc142dfdeafecde6cfe89201"
|
||||
# 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": 1461487,
|
||||
"sha256": "5f4faa860489f00b33b167c9644ce15f7b24a38a9f04b3d6e10a813426cfe41a",
|
||||
"size": 1462574,
|
||||
"sha256": "f0ecb3333aecd54fd0195ff5735f68e17da2979abc142dfdeafecde6cfe89201",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -71,8 +71,8 @@
|
||||
"muos": {
|
||||
"archive": {
|
||||
"dest": "ARCHIVE/RetroBIOS.muxapp",
|
||||
"size": 1515112,
|
||||
"sha256": "c4892f7c93182806e795d7bcc6c0c8568670c018fde4461fdad99f1976255426"
|
||||
"size": 1516199,
|
||||
"sha256": "69accbadbd356f458ef29ae77bbea45697a361e62c6b9ede5e157271058919f4"
|
||||
},
|
||||
"members": [
|
||||
{
|
||||
@@ -92,8 +92,8 @@
|
||||
{
|
||||
"name": "RetroBIOS/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1461487,
|
||||
"sha256": "5f4faa860489f00b33b167c9644ce15f7b24a38a9f04b3d6e10a813426cfe41a",
|
||||
"size": 1462574,
|
||||
"sha256": "f0ecb3333aecd54fd0195ff5735f68e17da2979abc142dfdeafecde6cfe89201",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -166,8 +166,8 @@
|
||||
{
|
||||
"dest": ".config/modules/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1461487,
|
||||
"sha256": "5f4faa860489f00b33b167c9644ce15f7b24a38a9f04b3d6e10a813426cfe41a",
|
||||
"size": 1462574,
|
||||
"sha256": "f0ecb3333aecd54fd0195ff5735f68e17da2979abc142dfdeafecde6cfe89201",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
|
||||
@@ -182,6 +182,23 @@ def resolve_systems(values: list[str], manifest: dict | None, files: list[dict],
|
||||
system_aliases(manifest), key_file_holders(files, omitted))
|
||||
|
||||
|
||||
def system_ids(names: Iterable[str], manifest: dict | None, files: list[dict],
|
||||
omitted: list[dict]) -> dict[str, str]:
|
||||
"""Each of names that --system takes, with the system id it stands for:
|
||||
a record keeps the psx typed at the install."""
|
||||
known = available_choices(files, omitted)["systems"]
|
||||
aliases, holders = system_aliases(manifest), key_file_holders(files, omitted)
|
||||
ids: dict[str, str] = {}
|
||||
for name in names:
|
||||
try:
|
||||
picked = resolve_choices([name], known, "system", aliases, holders)
|
||||
except ValueError:
|
||||
continue
|
||||
if len(picked) == 1:
|
||||
ids[name] = picked[0]
|
||||
return ids
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
+14
-8
@@ -10,11 +10,11 @@ import re
|
||||
import stat
|
||||
import sys
|
||||
import urllib.error
|
||||
from collections.abc import Collection, Iterable
|
||||
from collections.abc import Collection, Iterable, Mapping
|
||||
from pathlib import Path, PurePosixPath
|
||||
from typing import NamedTuple
|
||||
|
||||
from installer.choices import available_choices, emulator_names, resolve_choices, resolve_systems
|
||||
from installer.choices import available_choices, emulator_names, resolve_choices, resolve_systems, system_ids
|
||||
from installer.console import QUIT_CODE, _answer_yes
|
||||
from installer.destination import card_dest
|
||||
from installer.detect_frontends import detect_platforms
|
||||
@@ -136,14 +136,15 @@ def _choice_names(options: list[tuple[str, str | None]], flag: str) -> list[str]
|
||||
|
||||
|
||||
def _choice_without(choice: list[str], flag: str, names: Collection[str],
|
||||
left: list[str]) -> list[str]:
|
||||
left: list[str], ids: Mapping[str, str] | None = None) -> list[str]:
|
||||
"""A recorded choice once names of flag are taken out: those it named
|
||||
go, and a choice that named none gets the names left. A flag left with
|
||||
no name is dropped."""
|
||||
no name is dropped. ids gives a recorded name the id it stands for."""
|
||||
options = [option for option in record_options(choice) if option[0] != "--all-files"]
|
||||
gone = {name.casefold() for name in names}
|
||||
same = ids or {}
|
||||
remaining = [name for name in (_choice_names(options, flag) or left)
|
||||
if name.casefold() not in gone]
|
||||
if same.get(name, name).casefold() not in gone]
|
||||
kept = [option for option in options if option[0] != flag]
|
||||
if remaining:
|
||||
kept.append((flag, ",".join(remaining)))
|
||||
@@ -163,6 +164,7 @@ class _RemovalScope(NamedTuple):
|
||||
named_cores: list[str]
|
||||
others: dict[tuple[str, str], str]
|
||||
wanted: set[str]
|
||||
system_ids: dict[str, str]
|
||||
|
||||
def norm(self, dest: str) -> str:
|
||||
"""dest as the drive compares it, folded where it folds case."""
|
||||
@@ -189,7 +191,10 @@ def _removal_scope(
|
||||
wanted = {_drive_key(dest, fold) for dest in files}
|
||||
# What stays chosen once the removal is done, as an install names it:
|
||||
# the systems or cores the record named, else every one of the list.
|
||||
named_systems = {name.casefold() for name in _choice_names(options, "--system")}
|
||||
recorded_systems = _choice_names(options, "--system")
|
||||
ids = system_ids(recorded_systems, manifest, list(manifest.get("files") or []),
|
||||
list(manifest.get("omitted_files") or []))
|
||||
named_systems = {ids.get(name, name).casefold() for name in recorded_systems}
|
||||
staying_systems = {name for name in known["systems"] if not named_systems
|
||||
or name.casefold() in named_systems} - chosen_systems
|
||||
named_cores = _choice_names(options, "--core")
|
||||
@@ -197,7 +202,7 @@ def _removal_scope(
|
||||
else set(known["cores"]) | set(manifest.get("core_names") or {})
|
||||
) - chosen_cores
|
||||
return _RemovalScope(fold, known, options, chosen_systems, chosen_cores,
|
||||
staying_systems, staying_cores, named_cores, others, wanted)
|
||||
staying_systems, staying_cores, named_cores, others, wanted, ids)
|
||||
|
||||
|
||||
def _removal_takes(scope: _RemovalScope, found: tuple, dest: str) -> bool:
|
||||
@@ -258,7 +263,8 @@ def _removal_choice(scope: _RemovalScope, recorded: list[str], *, files: Collect
|
||||
return recorded
|
||||
if scope.chosen_systems:
|
||||
choice = _choice_without(recorded, "--system", scope.chosen_systems,
|
||||
sorted(scope.staying_systems | scope.chosen_systems))
|
||||
sorted(scope.staying_systems | scope.chosen_systems),
|
||||
scope.system_ids)
|
||||
if not _choice_names(record_options(choice), "--system"):
|
||||
return None
|
||||
return choice
|
||||
|
||||
@@ -194,6 +194,8 @@ class TheNamesAnInstallTakes(unittest.TestCase):
|
||||
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"]))
|
||||
# The record no longer names psx, or the next update put it back.
|
||||
self.assertEqual(repo.setup()["choice"], ["--system", "nintendo-gba"])
|
||||
|
||||
|
||||
class NeverTouched(unittest.TestCase):
|
||||
|
||||
Reference in new issue
Block a user