mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-18 17:33:30 -05:00
fix: name platform and folder in the sudo advice
This commit is contained in:
1 parent
09e51c2f0a
commit
dd86124165
4 files changed
+32
-5
No files matched your search
+1
-1
@@ -8,7 +8,7 @@ param(
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py"
|
||||
$defaultInstallSha256 = "39f3864183bd67c30c5705fccf39961aac0ad2d40238398ab2a67ef329eff359"
|
||||
$defaultInstallSha256 = "b6a90d5cecf61b6bcb2a48ef440a57c56d0792ca0986c2c5dd9ba952dda3a221"
|
||||
$maximumInstallerBytes = 2MB
|
||||
$installerExit = 0
|
||||
$installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null }
|
||||
|
||||
+15
-3
@@ -2296,7 +2296,7 @@ def _write_refused(exc: OSError) -> bool:
|
||||
return isinstance(exc, PermissionError) or exc.errno == errno.EROFS
|
||||
|
||||
|
||||
def _write_advice(path: Path, assumed: bool) -> str:
|
||||
def _write_advice(path: Path, assumed: bool, plat: str = "") -> str:
|
||||
"""What to do about a folder this run could not write.
|
||||
|
||||
sudo fixes a root-owned BIOS folder on the console itself. On another
|
||||
@@ -2307,6 +2307,13 @@ def _write_advice(path: Path, assumed: bool) -> str:
|
||||
return (f" {path} is where the platform keeps its BIOS on its own system, "
|
||||
"and it was not found here. If this machine prepares its card or "
|
||||
"share, run the same command with --dest pointing at that folder.")
|
||||
if plat:
|
||||
# sudo resets HOME to root's on Debian, Ubuntu, Arch and SteamOS:
|
||||
# the same command detected nothing there, fell back to a folder
|
||||
# under /root and reported success.
|
||||
return (" This user cannot write there. Run it again with sudo, naming the "
|
||||
f"folder so root does not look in its own home: --platform {plat} "
|
||||
f"--dest '{path.absolute()}'. Or choose another folder with --dest.")
|
||||
return (" This user cannot write there: run the same command with sudo, "
|
||||
"or choose another folder with --dest.")
|
||||
|
||||
@@ -2329,6 +2336,7 @@ def _report_outcome(
|
||||
declined: int = 0,
|
||||
assumed: set[Path] | None = None,
|
||||
omitted_entries: list[dict] | None = None,
|
||||
platform_of: dict[Path, str] | None = None,
|
||||
) -> None:
|
||||
"""Close the run on what happened, and leave with a status that says so.
|
||||
|
||||
@@ -2353,7 +2361,10 @@ def _report_outcome(
|
||||
sys.exit(130)
|
||||
|
||||
refused = any(reason == NOT_WRITABLE for _dest, reason in failures or [])
|
||||
advice = [_write_advice(path, path in (assumed or set())) for path in paths] if refused else []
|
||||
advice = [
|
||||
_write_advice(path, path in (assumed or set()), (platform_of or {}).get(path, ""))
|
||||
for path in paths
|
||||
] if refused else []
|
||||
|
||||
if errors and not downloaded:
|
||||
print(f"\nNothing was installed. {_plural(errors, 'file')} failed.")
|
||||
@@ -3325,7 +3336,7 @@ def _install(args: argparse.Namespace, real_stdout: TextIO) -> None:
|
||||
sys.stdout.flush()
|
||||
print(f"\nCannot create {bios_path}.", file=sys.stderr)
|
||||
print(f" {exc.strerror}.", file=sys.stderr)
|
||||
print(_write_advice(bios_path, bios_path in assumed_dests),
|
||||
print(_write_advice(bios_path, bios_path in assumed_dests, plat_name),
|
||||
file=sys.stderr)
|
||||
# The documented code for a folder that cannot be written,
|
||||
# as when it exists read-only; 1 once an earlier platform
|
||||
@@ -3392,6 +3403,7 @@ def _install(args: argparse.Namespace, real_stdout: TextIO) -> None:
|
||||
declined=total_declined,
|
||||
assumed=assumed_dests,
|
||||
omitted_entries=omitted_seen,
|
||||
platform_of={path: plat for plat, path in platforms},
|
||||
)
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ esac
|
||||
TEMP_INSTALLER=""
|
||||
TEMP_DIRECTORY=""
|
||||
DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py"
|
||||
DEFAULT_INSTALL_SHA256="39f3864183bd67c30c5705fccf39961aac0ad2d40238398ab2a67ef329eff359"
|
||||
DEFAULT_INSTALL_SHA256="b6a90d5cecf61b6bcb2a48ef440a57c56d0792ca0986c2c5dd9ba952dda3a221"
|
||||
MAX_INSTALLER_BYTES=2097152
|
||||
|
||||
cleanup() {
|
||||
|
||||
@@ -2158,5 +2158,20 @@ class AnUnwritableFolderIsCodeTwo(unittest.TestCase):
|
||||
self.assertEqual(proc.returncode, 2, proc.stdout + proc.stderr)
|
||||
|
||||
|
||||
|
||||
class SudoAdviceNamesTheFolder(unittest.TestCase):
|
||||
""""Run the same command with sudo" re-ran detection under root's HOME,
|
||||
found nothing, installed under /root and reported success."""
|
||||
|
||||
def test_the_advice_carries_platform_and_folder(self):
|
||||
advice = install._write_advice(Path("/media/card/Emulation/bios"), False, "emudeck")
|
||||
self.assertIn("--platform emudeck", advice)
|
||||
self.assertIn("--dest '/media/card/Emulation/bios'", advice)
|
||||
|
||||
def test_the_closing_report_passes_the_platform(self):
|
||||
source = (REPO_ROOT / "install.py").read_text(encoding="utf-8")
|
||||
self.assertIn("platform_of={path: plat for plat, path in platforms}", source)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user