diff --git a/install.ps1 b/install.ps1 index a4f26313..4d971fd1 100644 --- a/install.ps1 +++ b/install.ps1 @@ -8,7 +8,7 @@ param( $ErrorActionPreference = "Stop" $defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -$defaultInstallSha256 = "1cb76eb63b57e1390bfb4b6c2b24a5991819541414150aa88edc76d1d1188cd6" +$defaultInstallSha256 = "7dbb5c48a834d31a470b1952a9b8659b4c1f49f8d37c709a4032a56abe495f27" $maximumInstallerBytes = 2MB $installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null } $temporary = $null diff --git a/install.py b/install.py index 873e1d27..2a2b5f13 100644 --- a/install.py +++ b/install.py @@ -106,7 +106,15 @@ DEFAULT_DESTS = { def detect_os() -> str: - """Return normalized OS identifier.""" + """Return normalized OS identifier. + + RETROBIOS_OS names the platform outright (linux, wsl, windows, darwin), + for a run that has to behave like another host: the PowerShell wrapper + tests drive a Windows layout on a Linux runner. + """ + forced = os.environ.get("RETROBIOS_OS", "").strip().lower() + if forced in ("linux", "wsl", "windows", "darwin"): + return forced system = platform.system().lower() if system == "linux": proc_version = Path("/proc/version") diff --git a/install.sh b/install.sh index 96ff02bf..6d9750a6 100755 --- a/install.sh +++ b/install.sh @@ -18,7 +18,7 @@ esac TEMP_INSTALLER="" TEMP_DIRECTORY="" DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -DEFAULT_INSTALL_SHA256="1cb76eb63b57e1390bfb4b6c2b24a5991819541414150aa88edc76d1d1188cd6" +DEFAULT_INSTALL_SHA256="7dbb5c48a834d31a470b1952a9b8659b4c1f49f8d37c709a4032a56abe495f27" MAX_INSTALLER_BYTES=2097152 cleanup() { diff --git a/tests/test_install.py b/tests/test_install.py index ac3ee4db..379d7d90 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -852,6 +852,8 @@ class TestLaunchboxDetectionPowershell(unittest.TestCase): USERPROFILE=str(userprofile), APPDATA=str(tempfile.mkdtemp()), RETROBIOS_BASE_URL=f"http://127.0.0.1:{httpd.server_address[1]}", + # A LaunchBox layout is a Windows layout: the runner is Linux. + RETROBIOS_OS="wsl", ) proc = subprocess.run( [ @@ -953,6 +955,18 @@ class TestLaunchboxDetectionPowershell(unittest.TestCase): self.assertTrue(landed.exists(), proc.stdout) +class TestForcedOs(unittest.TestCase): + """RETROBIOS_OS overrides detection with a known name only.""" + + def test_known_name_wins(self): + with unittest.mock.patch.dict(os.environ, {"RETROBIOS_OS": "Windows"}): + self.assertEqual(install.detect_os(), "windows") + + def test_unknown_name_is_ignored(self): + with unittest.mock.patch.dict(os.environ, {"RETROBIOS_OS": "amiga"}): + self.assertIn(install.detect_os(), ("linux", "wsl", "windows", "darwin")) + + class TestDetectFrontends(unittest.TestCase): """Frontends have no BIOS directory of their own but hint at the setup."""