diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-appimage-run b/tools/linuxfs/overlay/usr/local/bin/droiddeck-appimage-run index b4a1910f24..d0d33c595e 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-appimage-run +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-appimage-run @@ -45,11 +45,20 @@ if [ "$qt" = wayland ] && [ -n "$wayland" ]; then elif [ "$qt" = xcb ] && [ -n "${DISPLAY:-}" ]; then export QT_QPA_PLATFORM=xcb fi +arch=$(cat "$dir/arch" 2>/dev/null) +if [ "$arch" = arm64 ]; then + find -H "$APPDIR" -maxdepth 6 ! -type d \( -name libGL.so.1 -o -name libGLX.so.0 -o -name libEGL.so.1 -o -name libGLESv2.so.2 \ + -o -name libOpenGL.so.0 -o -name libGLdispatch.so.0 \) -print 2>/dev/null | + while IFS= read -r lib; do + kept=$dir/bundled-gl/${lib#"$APPDIR"/} + mkdir -p "${kept%/*}" && mv -f "$lib" "$kept" && echo "== appimage: the session's ${lib##*/} replaces the bundled one" + done +fi fex=$(cat "$dir/fex" 2>/dev/null) case $fex in on|off) ;; *) fex=auto ;; esac run=("$APPDIR/AppRun") if [ -x /usr/local/bin/droiddeck-fex ]; then - case $fex:$(cat "$dir/arch" 2>/dev/null) in + case $fex:$arch in auto:x86_64|auto:i386) run=(/usr/local/bin/droiddeck-fex run --mode on -- "$APPDIR/AppRun") ;; auto:arm64) ;; *) run=(/usr/local/bin/droiddeck-fex run --mode "$fex" --for "$APPDIR" -- "$APPDIR/AppRun") ;; diff --git a/tools/tests/test_appimage_run.py b/tools/tests/test_appimage_run.py index 14ac8ad676..84c92f49b8 100644 --- a/tools/tests/test_appimage_run.py +++ b/tools/tests/test_appimage_run.py @@ -146,6 +146,24 @@ class AppImageRunTest(unittest.TestCase): env, _ = self.launch(dict(RUN_MODE, TU_DEBUG="sysmem")) self.assertEqual("sysmem", env["TU_DEBUG"]) + def test_an_arm64_app_uses_the_sessions_gl_libraries(self): + (self.dir / "arch").write_text("arm64") + self.bundle("usr/lib/libGLESv2.so.2", "usr/lib/libEGL.so.1", "usr/lib/libglfw.so.3", "usr/lib/libGLESv2.so.2.1.0") + _, log = self.launch(RUN_MODE) + lib = self.dir / "app/usr/lib" + self.assertEqual(["libGLESv2.so.2.1.0", "libglfw.so.3"], sorted(p.name for p in lib.iterdir())) + self.assertEqual(["libEGL.so.1", "libGLESv2.so.2"], sorted(p.name for p in (self.dir / "bundled-gl/usr/lib").iterdir())) + self.assertIn("the session's libGLESv2.so.2 replaces the bundled one", log) + _, log = self.launch(RUN_MODE) + self.assertNotIn("replaces the bundled one", log) + + def test_other_architectures_keep_their_gl_libraries(self): + (self.dir / "arch").write_text("x86_64") + self.bundle("usr/lib/libGLESv2.so.2") + self.launch(RUN_MODE) + self.assertTrue((self.dir / "app/usr/lib/libGLESv2.so.2").exists()) + self.assertFalse((self.dir / "bundled-gl").exists()) + if __name__ == "__main__": unittest.main()