diff --git a/_installer_import/install.sh b/_installer_import/install.sh index ae43f40..f9fc334 100755 --- a/_installer_import/install.sh +++ b/_installer_import/install.sh @@ -60,8 +60,11 @@ ensure_libibus() { echo "missing: libibus -- run: sudo pacman -S --needed libibus" >&2 return 1 fi - sudo -n pacman -S --needed --noconfirm libibus || + sudo -n true 2>/dev/null || die "libibus is missing and sudo needs a password. Run: sudo pacman -S --needed libibus" + # No -y: syncing the db without upgrading is a partial upgrade on Arch. + sudo -n pacman -S --needed --noconfirm libibus || + die "pacman could not install libibus (a stale package db 404s). Run: sudo pacman -Syu libibus" } # Never runs the package's .INSTALL; see steam_installer/proton_native.py. diff --git a/_installer_import/steam_installer/proton_native.py b/_installer_import/steam_installer/proton_native.py index c8e42d1..14529af 100644 --- a/_installer_import/steam_installer/proton_native.py +++ b/_installer_import/steam_installer/proton_native.py @@ -55,7 +55,9 @@ def in_use(tool: Path) -> list[int]: def _download(url: str, dest: Path) -> None: - with urllib.request.urlopen(url, timeout=60) as response, dest.open("wb") as out: + # A generic agent: the mirror answers 403 to urllib's default one. + request = urllib.request.Request(url, headers={"User-Agent": "steam-game-installer"}) + with urllib.request.urlopen(request, timeout=60) as response, dest.open("wb") as out: shutil.copyfileobj(response, out, 1 << 20) diff --git a/_installer_import/tests/test_proton_native_cli.py b/_installer_import/tests/test_proton_native_cli.py index eae936d..e80dee7 100644 --- a/_installer_import/tests/test_proton_native_cli.py +++ b/_installer_import/tests/test_proton_native_cli.py @@ -56,3 +56,26 @@ def test_module_runs_as_a_script(tmp_path, coverage_subprocess_env): ) assert result.returncode == 0 assert "skipped" in result.stdout + + +def test_downloads_send_a_user_agent(monkeypatch, tmp_path): + """The CachyOS mirror answers 403 to urllib's default agent (2026-11-22).""" + import io + + seen = {} + + class _Response(io.BytesIO): + def __enter__(self): + return self + + def __exit__(self, *a): + return False + + def fake_urlopen(request, timeout): + seen["agent"] = request.get_header("User-agent") + return _Response(b"data") + + monkeypatch.setattr(proton_native.urllib.request, "urlopen", fake_urlopen) + proton_native._download("https://m/x", tmp_path / "x") + assert (tmp_path / "x").read_bytes() == b"data" + assert seen["agent"] == "steam-game-installer"