Send a User-Agent; libibus without partial upgrade

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-22 15:02:55 +01:00
parent c1b6fdd16f
commit c4ca111cd4
3 changed files with 30 additions and 2 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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"