From ca08541851c06aa8b9b5bebb761d17cfec2f3771 Mon Sep 17 00:00:00 2001 From: The412Banner <205237651+The412Banner@users.noreply.github.com> Date: Sun, 6 Dec 2026 15:52:54 +0000 Subject: [PATCH] fix(fex): x86-64 AppImages with a newer pango find a matching HarfBuzz --- .../overlay/usr/local/bin/droiddeck-fex | 4 +- tools/tests/test_droiddeck_fex.py | 68 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex index 1f5cc42743..32fea1fc41 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex @@ -39,7 +39,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 = 10 +ROOTFS_LAYOUT = 11 BLOB_DIRS = re.compile(r"^(?:\.ref|[0-9a-f]{2})$") ROOTFS_LIBRARY_DIRS = ("lib", "lib64") ARCH_DIRS = ("x86_64-linux-gnu", "i386-linux-gnu") @@ -51,6 +51,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", + "libharfbuzz.so.0", "libwayland-client.so.0", "libwayland-egl.so.1", "libwayland-server.so.0", "libffi.so.8", "libgbm.so.1", "libdrm.so.2", "libexpat.so.1", "libOpenGL.so.0", )) @@ -58,6 +59,7 @@ PROVIDED_NEEDS = { "libwayland-client.so.0": ("libffi.so.8",), "libwayland-server.so.0": ("libffi.so.8",), "libgbm.so.1": ("libdrm.so.2", "libexpat.so.1"), + "libharfbuzz.so.0": ("libfreetype.so.6",), } 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")) diff --git a/tools/tests/test_droiddeck_fex.py b/tools/tests/test_droiddeck_fex.py index 5bd2596b88..cd7e3ed167 100644 --- a/tools/tests/test_droiddeck_fex.py +++ b/tools/tests/test_droiddeck_fex.py @@ -640,6 +640,74 @@ class PrepareTest(FexTestCase): fixed = subprocess.run(command, env=env, capture_output=True, text=True) self.assertEqual(fixed.returncode, 0, fixed.stderr) + def test_harfbuzz_uses_the_newer_runtime_with_its_freetype_and_falls_back_per_architecture(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"): + for name in ("libharfbuzz.so.0", "libfreetype.so.6", "libgraphite2.so.3"): + self.write(sniper / "files/lib" / arch / name, b"base") + self.write(provider / "files/lib" / arch / "libfreetype.so.6", b"new") + self.write(provider / "files/lib/x86_64-linux-gnu/libharfbuzz.so.0.61020.0", b"new harfbuzz") + os.symlink("libharfbuzz.so.0.61020.0", provider / "files/lib/x86_64-linux-gnu/libharfbuzz.so.0") + fex, _ = self.quiet(FEX["prepare"]) + x86 = Path(fex["rootfs"]) / "lib/x86_64-linux-gnu" + i386 = Path(fex["rootfs"]) / "lib/i386-linux-gnu" + self.assertEqual((x86 / "libharfbuzz.so.0").read_bytes(), b"new harfbuzz") + self.assertEqual((x86 / "libgraphite2.so.3").read_bytes(), b"base") + self.assertEqual((i386 / "libharfbuzz.so.0").read_bytes(), b"base") + self.assertEqual((i386 / "libfreetype.so.6").read_bytes(), b"new") + self.assertEqual((sniper / "files/lib/x86_64-linux-gnu/libharfbuzz.so.0").read_bytes(), b"base") + + def test_harfbuzz_requires_a_usable_provider_freetype_on_both_architectures(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"): + for name in ("libharfbuzz.so.0", "libfreetype.so.6"): + self.write(sniper / "files/lib" / arch / name, b"base") + self.write(provider / "files/lib" / arch / "libharfbuzz.so.0", b"provider") + os.symlink("missing-freetype.so", provider / "files/lib" / arch / "libfreetype.so.6") + fex, _ = self.quiet(FEX["prepare"]) + for arch in ("x86_64-linux-gnu", "i386-linux-gnu"): + root = Path(fex["rootfs"]) / "lib" / arch + self.assertEqual((root / "libharfbuzz.so.0").read_bytes(), b"base") + self.assertEqual((root / "libfreetype.so.6").read_bytes(), b"base") + + @unittest.skipUnless(shutil.which("cc"), "C compiler unavailable") + def test_bundled_library_resolves_the_new_harfbuzz_symbol(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 / "harfbuzz.c" + self.write(newer / "libfreetype.so.6", b"freetype") + for folder, symbol in ((base, "hb_ot_color_has_png"), (newer, "hb_ot_color_has_paint")): + source.write_text("int %s(void *face) { return 0; }\n" % symbol) + subprocess.run(["cc", "-shared", "-fPIC", "-nostdlib", "-Wl,-soname,libharfbuzz.so.0", + "-o", str(folder / "libharfbuzz.so.0"), str(source)], check=True, capture_output=True) + fex, _ = self.quiet(FEX["prepare"]) + root = Path(fex["rootfs"]) / "lib/x86_64-linux-gnu" + source.write_text("extern int hb_ot_color_has_paint(void *face);\nint probe(void) { return hb_ot_color_has_paint(0); }\n") + probe = self.tmp / "libpangoprobe.so" + subprocess.run(["cc", "-shared", "-fPIC", "-nostdlib", "-o", str(probe), str(source), + "-L" + str(newer), "-l:libharfbuzz.so.0", "-Wl,-rpath," + str(root)], + check=True, capture_output=True) + command = [sys.executable, "-c", + "import ctypes,sys; " + "ctypes.CDLL(sys.argv[2], mode=ctypes.RTLD_GLOBAL) if len(sys.argv) > 2 else None; " + "ctypes.CDLL(sys.argv[1]).probe()", str(probe)] + env = {k: v for k, v in os.environ.items() if not k.startswith("LD_")} + broken = subprocess.run(command + [str(base / "libharfbuzz.so.0")], env=env, capture_output=True, text=True) + self.assertNotEqual(broken.returncode, 0) + self.assertIn("undefined symbol: hb_ot_color_has_paint", broken.stderr) + fixed = subprocess.run(command, env=env, capture_output=True, text=True) + self.assertEqual(fixed.returncode, 0, fixed.stderr) + def test_missing_freetype_provider_keeps_base_on_both_architectures(self): self.fex_tool() sniper = self.runtime()