fix(desktop): let gamescope find its reaper when /usr/games is not on PATH (#2597)

* fix(desktop): let gamescope find its reaper when /usr/games is not on PATH

* test(desktop): keep host directories off the reaper fallback test PATH
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-16 09:33:31 -05:00
1 parent 758e7983fa
commit 6188c9ac0d
2 files changed
+56

No files matched your search

+8
View File
@@ -42,6 +42,14 @@ export BL_DESKTOP_GPU_CHILD=1
export MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink LIBGL_KOPPER_DRI2=true
[ -n "${DROIDDECK_GLTHREAD:-}" ] && export mesa_glthread=$DROIDDECK_GLTHREAD
export APPIMAGE_EXTRACT_AND_RUN=1
if ! command -v gamescopereaper >/dev/null 2>&1; then
for dir in /usr/games /usr/local/games /usr/bin; do
if [ -x "$dir/gamescopereaper" ]; then
export PATH=${PATH:+$PATH:}$dir
break
fi
done
fi
if [ "$window" = 1 ]; then
export BL_GPU_CHILD_WSI=${MESA_VK_WSI_DEBUG:-}
SDL_VIDEODRIVER=wayland MESA_VK_WSI_DEBUG=sw gamescope "${args[@]}" -- /usr/local/bin/droiddeck-gpu-window "$@"
+48
View File
@@ -1,6 +1,7 @@
import json
import os
from pathlib import Path
import shutil
import subprocess
import sys
import tempfile
@@ -100,3 +101,50 @@ class DesktopGamescopeBackendTest(unittest.TestCase):
self.assertEqual(64, result.returncode)
self.assertIn("unsupported gamescope backend: drm", result.stderr)
self.assertIsNone(capture)
class DesktopGamescopeReaperTest(unittest.TestCase):
def launch(self, reaper_on_path):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
bin_dir = root / "bin"
games = root / "games"
bin_dir.mkdir()
games.mkdir()
capture = root / "path.txt"
gamescope = bin_dir / "gamescope"
gamescope.write_text(
"#!/bin/sh\n"
"printf '%s\\n' \"$PATH\" > \"$GAMESCOPE_CAPTURE\"\n"
"command -v gamescopereaper >> \"$GAMESCOPE_CAPTURE\" || exit 3\n"
)
gamescope.chmod(0o755)
reaper = (bin_dir if reaper_on_path else games) / "gamescopereaper"
reaper.write_text("#!/bin/sh\n")
reaper.chmod(0o755)
date = bin_dir / "date"
date.write_text(f"#!/bin/sh\nexec {shutil.which('date')} \"$@\"\n")
date.chmod(0o755)
script = root / "droiddeck-gpu"
source = DESKTOP_GPU.read_text()
self.assertIn("for dir in /usr/games ", source)
script.write_text(source.replace("for dir in /usr/games ", f"for dir in {games} ", 1))
start_path = str(bin_dir)
env = {"PATH": start_path, "HOME": directory, "GAMESCOPE_CAPTURE": str(capture),
"WAYLAND_DISPLAY": "desktop-0", "BL_DESKTOP_GPU_WINDOW": "0"}
result = subprocess.run(["/bin/bash", str(script), "demo"], env=env, text=True,
capture_output=True, timeout=5)
lines = capture.read_text().splitlines() if capture.exists() else []
return result, start_path, lines, str(reaper)
def test_reaper_outside_path_is_added_for_gamescope(self):
result, start_path, lines, reaper = self.launch(reaper_on_path=False)
self.assertEqual(0, result.returncode, result.stdout + result.stderr)
self.assertEqual(start_path + os.pathsep + str(Path(reaper).parent), lines[0])
self.assertEqual(reaper, lines[1])
def test_path_with_reaper_is_left_as_it_is(self):
result, start_path, lines, reaper = self.launch(reaper_on_path=True)
self.assertEqual(0, result.returncode, result.stdout + result.stderr)
self.assertEqual(start_path, lines[0])
self.assertEqual(reaper, lines[1])