fix(fex): preserve cursor compatibility and refresh runtime cache

This commit is contained in:
maxjivi05 committed 2026-11-11 06:04:13 -05:00
1 parent 8645e0f924
commit d91b26bfab
2 files changed
+67 -7

No files matched your search

@@ -37,7 +37,7 @@ RUNTIMES = {SNIPER_APPID: ("sniper_platform_", "Steam Linux Runtime 3.0 (sniper"
SLR4_APPID: ("steamrt4_platform_", "Steam Linux Runtime 4.0 (steamrt4")}
MARKER = ".droiddeck-fex"
LAYOUT = 1
ROOTFS_LAYOUT = 7
ROOTFS_LAYOUT = 8
ARCH_DIRS = ("x86_64-linux-gnu", "i386-linux-gnu")
INTERPRETERS = ("ld-linux-x86-64.so.2", "ld-linux.so.2")
PROVIDED = frozenset((
@@ -47,7 +47,7 @@ PROVIDED = frozenset((
"libmemusage.so", "libpcprofile.so", "libc_malloc_debug.so.0", "gconv", "libstdc++.so.6", "libgcc_s.so.1",
"libssl.so.3", "libcrypto.so.3",
"libfreetype.so.6", "libpng16.so.16", "libbrotlidec.so.1", "libbrotlicommon.so.1", "libbz2.so.1.0", "libz.so.1",
"libwayland-client.so.0", "libwayland-cursor.so.0", "libwayland-egl.so.1", "libwayland-server.so.0", "libffi.so.8",
"libwayland-client.so.0", "libwayland-egl.so.1", "libwayland-server.so.0", "libffi.so.8",
))
GLIBC_BUILD = re.compile(r"^(?:ld|lib[A-Za-z_]+)-2\.[0-9]+\.so$|^libSegFault\.so$")
GUEST_LIBDIRS = (("x86_64", "lib/x86_64-linux-gnu"), ("i386", "lib/i386-linux-gnu"))
@@ -313,10 +313,9 @@ def provides_newer(base, provider):
def mirror(source, provider, name, target):
wayland_needs_ffi = name in ("libwayland-client.so.0", "libwayland-server.so.0", "libwayland-cursor.so.0")
wayland_needs_ffi = name in ("libwayland-client.so.0", "libwayland-server.so.0")
usable_provider = provider and os.path.exists(os.path.join(provider, name)) and (
not wayland_needs_ffi or os.path.exists(os.path.join(provider, "libffi.so.8"))) and (
name != "libwayland-cursor.so.0" or os.path.exists(os.path.join(provider, "libwayland-client.so.0")))
not wayland_needs_ffi or os.path.exists(os.path.join(provider, "libffi.so.8")))
if name in PROVIDED and usable_provider:
os.symlink(os.path.realpath(os.path.join(provider, name)), os.path.join(target, name))
return
@@ -341,6 +340,16 @@ def build_rootfs(base, provider):
rootfs = os.path.join(STATE, "rootfs")
stamp = "%d\n%s\n%s%s\n%s" % (ROOTFS_LAYOUT, os.path.realpath(base), read_text(os.path.join(base_files, MARKER)) or "",
os.path.realpath(provider), read_text(os.path.join(provider_files, MARKER)) or "")
for top in ("lib", "lib64"):
for arch in ARCH_DIRS:
for name in sorted(PROVIDED):
path = os.path.join(provider_files, top, arch, name)
try:
info = os.stat(path)
stamp += "\n%s %s %d %d %d %d" % (path, os.path.realpath(path), info.st_ino, info.st_size,
info.st_mtime_ns, info.st_ctime_ns)
except OSError:
stamp += "\n%s missing" % path
if read_text(os.path.join(rootfs, MARKER)) == stamp:
return False
for entry in os.listdir(STATE):
+53 -2
View File
@@ -472,8 +472,9 @@ class PrepareTest(FexTestCase):
for arch in ("x86_64-linux-gnu", "i386-linux-gnu"):
for name in names:
library = root / "lib" / arch / name
self.assertEqual(library.resolve(), (provider / "files/lib" / arch / name).resolve())
self.assertEqual(library.read_bytes(), b"new ABI " + name.encode())
expected = sniper if name == "libwayland-cursor.so.0" else provider
self.assertEqual(library.resolve(), (expected / "files/lib" / arch / name).resolve())
self.assertEqual(library.read_bytes(), b"old ABI" if expected == sniper else b"new ABI " + name.encode())
self.assertEqual((root / "lib" / arch / "libffi.so.7").read_bytes(), b"old ffi")
self.assertEqual((sniper / "files/lib/x86_64-linux-gnu/libwayland-client.so.0").read_bytes(), b"old ABI")
@@ -650,6 +651,56 @@ class PrepareTest(FexTestCase):
self.assertEqual((root / "libwayland-cursor.so.0").read_bytes(), b"base cursor")
self.assertEqual((root / "libffi.so.8").read_bytes(), b"provider ffi")
def test_restored_provider_clients_rebuild_the_rootfs_without_marker_changes(self):
self.fex_tool()
sniper = self.runtime()
FEX["materialize"](str(sniper))
provider = self.graphics(sniper)
for arch in ("x86_64-linux-gnu", "i386-linux-gnu"):
self.write(sniper / "files/lib" / arch / "libwayland-client.so.0", b"base")
self.write(provider / "files/lib" / arch / "libffi.so.8", b"ffi")
os.symlink("client-real.so", provider / "files/lib" / arch / "libwayland-client.so.0")
fex, _ = self.quiet(FEX["prepare"])
for arch in ("x86_64-linux-gnu", "i386-linux-gnu"):
self.assertEqual((Path(fex["rootfs"]) / "lib" / arch / "libwayland-client.so.0").read_bytes(), b"base")
self.write(provider / "files/lib" / arch / "client-real.so", b"restored")
fex, said = self.quiet(FEX["prepare"])
self.assertIn("built the x86 runtime", said)
self.assertEqual((Path(fex["rootfs"]) / "lib" / arch / "libwayland-client.so.0").read_bytes(), b"restored")
self.assertNotIn("built the x86 runtime", self.quiet(FEX["prepare"])[1])
client = provider / "files/lib/i386-linux-gnu/client-real.so"
client.write_bytes(b"updated client")
fex, said = self.quiet(FEX["prepare"])
self.assertIn("built the x86 runtime", said)
self.assertEqual((Path(fex["rootfs"]) / "lib/i386-linux-gnu/libwayland-client.so.0").read_bytes(), b"updated client")
@unittest.skipUnless(shutil.which("cc"), "C compiler unavailable")
def test_base_cursor_works_with_guest_selected_old_client(self):
self.fex_tool()
sniper = self.runtime()
FEX["materialize"](str(sniper))
provider = self.graphics(sniper)
base = sniper / "files/lib/x86_64-linux-gnu"
newer = provider / "files/lib/x86_64-linux-gnu"
source = self.tmp / "cursor.c"
self.write(newer / "libffi.so.8", b"ffi")
for folder, symbol in ((base, "wl_proxy_marshal"), (newer, "wl_proxy_marshal_flags")):
source.write_text("void %s(void) {}\n" % symbol)
subprocess.run(["cc", "-shared", "-fPIC", "-nostdlib", "-Wl,-soname,libwayland-client.so.0",
"-o", str(folder / "libwayland-client.so.0"), str(source)], check=True, capture_output=True)
source.write_text("extern void %s(void); void probe(void) { %s(); }\n" % (symbol, symbol))
subprocess.run(["cc", "-shared", "-fPIC", "-nostdlib", "-o", str(folder / "libwayland-cursor.so.0"),
str(source), "-L" + str(folder), "-l:libwayland-client.so.0"], check=True, capture_output=True)
fex, _ = self.quiet(FEX["prepare"])
cursor = Path(fex["rootfs"]) / "lib/x86_64-linux-gnu/libwayland-cursor.so.0"
command = [sys.executable, "-c", "import ctypes,sys; ctypes.CDLL(sys.argv[1], mode=ctypes.RTLD_GLOBAL); ctypes.CDLL(sys.argv[2]).probe()", str(base / "libwayland-client.so.0")]
env = {k: v for k, v in os.environ.items() if not k.startswith("LD_")}
broken = subprocess.run(command + [str(newer / "libwayland-cursor.so.0")], env=env, capture_output=True, text=True)
self.assertNotEqual(broken.returncode, 0)
self.assertIn("undefined symbol: wl_proxy_marshal_flags", broken.stderr)
fixed = subprocess.run(command + [str(cursor)], env=env, capture_output=True, text=True)
self.assertEqual(fixed.returncode, 0, fixed.stderr)
def test_the_old_rootfs_layout_is_rebuilt(self):
self.fex_tool()
sniper = self.runtime()