diff --git a/install.ps1 b/install.ps1 index 4446ee2f..0f02b749 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 = "84b6a006895a34929d99cfd890f028c2ae09e134385dfd10cc955288daaf4260" +$defaultInstallSha256 = "2db3ce4cf58905d34d45633e7d955ba106b343f8348c8bd81ece5731560d331c" $maximumInstallerBytes = 2MB $installerExit = 0 $installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null } diff --git a/install.py b/install.py index a1da727c..35d5bc22 100644 --- a/install.py +++ b/install.py @@ -550,8 +550,9 @@ def _windows_retroarch_dirs() -> list[Path]: """Folders holding retroarch.exe where its installers put it. C:/RetroArch-Win64 by default, C:/RetroArch for 32-bit builds, the same - names under Program Files, every Steam library, and the Emulators folder - of an installed ES-DE (es_find_rules.xml lists all of them). + names under Program Files, every Steam library, the Emulators folder of + an installed ES-DE (es_find_rules.xml lists all of them), and a Scoop + install, user or global. """ candidates = [_host_path("C:/RetroArch-Win64"), _host_path("C:/RetroArch")] for var in ("ProgramFiles", "ProgramFiles(x86)"): @@ -565,6 +566,21 @@ def _windows_retroarch_dirs() -> list[Path]: candidates += [ library / "steamapps" / "common" / "RetroArch" for library in _steam_libraries() ] + # Scoop's Extras bucket: \apps\retroarch\current, the root being + # %SCOOP% or ~\scoop for a user install, %SCOOP_GLOBAL% or + # %ProgramData%\scoop for a global one. Its system folder is persisted + # through a junction, so the folder beside retroarch.exe is the real one. + scoop_roots = [ + os.environ.get("SCOOP") or ( + str(Path(os.environ["USERPROFILE"]) / "scoop") if os.environ.get("USERPROFILE") else "" + ), + os.environ.get("SCOOP_GLOBAL") or ( + str(Path(os.environ["ProgramData"]) / "scoop") if os.environ.get("ProgramData") else "" + ), + ] + candidates += [ + Path(root) / "apps" / "retroarch" / "current" for root in scoop_roots if root + ] return [folder for folder in candidates if (folder / "retroarch.exe").is_file()] diff --git a/install.sh b/install.sh index eb6b30aa..a15a8ec1 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="84b6a006895a34929d99cfd890f028c2ae09e134385dfd10cc955288daaf4260" +DEFAULT_INSTALL_SHA256="2db3ce4cf58905d34d45633e7d955ba106b343f8348c8bd81ece5731560d331c" MAX_INSTALLER_BYTES=2097152 cleanup() { diff --git a/tests/test_install.py b/tests/test_install.py index 7c5eb0af..d7817856 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -1133,6 +1133,17 @@ class RetroArchIsFoundWhereWindowsInstallsPutIt(unittest.TestCase): found = self._exe(program_files / "RetroArch-Win64") self.assertIn(found, install._windows_retroarch_dirs()) + def test_a_scoop_install(self): + # `scoop install retroarch` puts it under ~/scoop/apps/retroarch/current, + # which none of the searched folders covered. + program_files = Path(_tempdir(self)) + self._env(program_files) + home = Path(_tempdir(self)) + found = self._exe(home / "scoop" / "apps" / "retroarch" / "current") + with unittest.mock.patch.dict(os.environ, {"USERPROFILE": str(home)}): + os.environ.pop("SCOOP", None) + self.assertIn(found, install._windows_retroarch_dirs()) + def test_a_steam_library_on_another_drive(self): program_files = Path(_tempdir(self)) library = Path(_tempdir(self))