mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
fix(desktop): catalog AppImages such as RPCS3 start from the desktop menu again (#2274)
fix(desktop): catalog AppImages start from the desktop menu through the shipped runtime RPCS3 from the desktop menu exited at once: its own AppImage runtime runs dwarfsextract from a memfd, which PRoot cannot execute (EACCES), and it has no fallback. Emulator rail launches already avoid this by starting arm64 images through the shipped uruntime (#1191); the menu entries the catalog writes did not. The rule now lives in one launcher, droiddeck-appimage-exec, used by the session and by the catalog's menu entries. Entries written by older versions are moved to it with the existing menu migration.
This commit is contained in:
1 parent
bc99cacd02
commit
45e39b7aaf
7 files changed
+89
-35
No files matched your search
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
image=${1:?usage: droiddeck-appimage-exec <AppImage> [args...]}
|
||||
shift
|
||||
export APPIMAGE_EXTRACT_AND_RUN=1
|
||||
chmod +x "$image" 2>/dev/null
|
||||
if [ -x /usr/local/bin/droiddeck-fex ]; then
|
||||
case $(od -An -tu2 -j18 -N2 "$image" 2>/dev/null | tr -d ' ') in
|
||||
3|62) exec /usr/local/bin/droiddeck-fex run --mode on -- "$image" "$@" ;;
|
||||
esac
|
||||
fi
|
||||
if [ -x /usr/local/lib/droiddeck/uruntime ]; then
|
||||
export TARGET_APPIMAGE=$image
|
||||
exec /usr/local/lib/droiddeck/uruntime "$@"
|
||||
fi
|
||||
exec "$image" "$@"
|
||||
@@ -642,13 +642,7 @@ case $mode in
|
||||
fi
|
||||
case ${target,,} in
|
||||
*.appimage)
|
||||
export APPIMAGE_EXTRACT_AND_RUN=1
|
||||
chmod +x "$target" 2>/dev/null
|
||||
if [ ${#fex[@]} -eq 0 ] && [ -x /usr/local/lib/droiddeck/uruntime ]; then
|
||||
export TARGET_APPIMAGE=$target
|
||||
run_program /usr/local/lib/droiddeck/uruntime "$@"
|
||||
fi
|
||||
run_program "${fex[@]}" "$target" "$@"
|
||||
run_program /usr/local/bin/droiddeck-appimage-exec "$target" "$@"
|
||||
;;
|
||||
*.sh)
|
||||
if [ -x /usr/local/bin/droiddeck-fex ]; then
|
||||
|
||||
@@ -6,8 +6,12 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session"
|
||||
BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin"
|
||||
SESSION = BIN / "droiddeck-session"
|
||||
EXEC = BIN / "droiddeck-appimage-exec"
|
||||
URUNTIME = "/usr/local/lib/droiddeck/uruntime"
|
||||
FEX = "/usr/local/bin/droiddeck-fex"
|
||||
REPORT = "#!/bin/sh\nprintf '%%s\\n' \"TARGET=${TARGET_APPIMAGE:-} EXTRACT=${APPIMAGE_EXTRACT_AND_RUN:-}\" %s \"$@\"\n"
|
||||
|
||||
|
||||
def target_case():
|
||||
@@ -15,34 +19,54 @@ def target_case():
|
||||
return match.group(0)
|
||||
|
||||
|
||||
class SessionAppImageTest(unittest.TestCase):
|
||||
class AppImageExecTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.dir = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.dir, True)
|
||||
self.image = self.dir / "rpcs3.AppImage"
|
||||
self.image.write_bytes(b"\x7fELF")
|
||||
self.uruntime = self.dir / "uruntime"
|
||||
self.uruntime.write_text("#!/bin/sh\n")
|
||||
self.uruntime.chmod(0o755)
|
||||
self.machine(183)
|
||||
self.uruntime = self.tool("uruntime", "uruntime")
|
||||
self.fex = self.tool("droiddeck-fex", "fex")
|
||||
|
||||
def launch(self, fex=()):
|
||||
script = ("set -u\n"
|
||||
"run_program() { printf '%%s\\n' \"TARGET=${TARGET_APPIMAGE:-} EXTRACT=${APPIMAGE_EXTRACT_AND_RUN:-}\" \"$@\"; exit 0; }\n"
|
||||
"target=%s\nfex=(%s)\nset -- --no-gui\n" % (self.image, " ".join(fex))
|
||||
+ target_case().replace(URUNTIME, str(self.uruntime)))
|
||||
def machine(self, number):
|
||||
self.image.write_bytes(b"\x7fELF" + bytes(14) + number.to_bytes(2, "little") + bytes(44))
|
||||
|
||||
def tool(self, name, label):
|
||||
path = self.dir / name
|
||||
path.write_text(REPORT % label)
|
||||
path.chmod(0o755)
|
||||
return path
|
||||
|
||||
def launch(self):
|
||||
script = self.dir / "exec"
|
||||
script.write_text(EXEC.read_text().replace(URUNTIME, str(self.uruntime)).replace(FEX, str(self.fex)))
|
||||
env = {k: v for k, v in os.environ.items() if k not in ("TARGET_APPIMAGE", "APPIMAGE_EXTRACT_AND_RUN")}
|
||||
return subprocess.run(["bash", "-c", script], env=env, capture_output=True, text=True, timeout=30).stdout.splitlines()
|
||||
return subprocess.run(["bash", str(script), str(self.image), "--no-gui"], env=env,
|
||||
capture_output=True, text=True, timeout=30).stdout.splitlines()
|
||||
|
||||
def test_an_arm64_image_runs_through_the_shipped_runtime(self):
|
||||
self.assertEqual(["TARGET=%s EXTRACT=1" % self.image, str(self.uruntime), "--no-gui"], self.launch())
|
||||
self.assertEqual(["TARGET=%s EXTRACT=1" % self.image, "uruntime", "--no-gui"], self.launch())
|
||||
|
||||
def test_without_the_shipped_runtime_the_image_runs_itself(self):
|
||||
self.uruntime.unlink()
|
||||
self.assertEqual(["TARGET= EXTRACT=1", str(self.image), "--no-gui"], self.launch())
|
||||
self.image.write_text(REPORT % "own")
|
||||
self.assertEqual(["TARGET= EXTRACT=1", "own", "--no-gui"], self.launch())
|
||||
|
||||
def test_an_x86_image_still_starts_under_fex(self):
|
||||
fex = ("/usr/local/bin/droiddeck-fex", "run", "--mode", "on", "--")
|
||||
self.assertEqual(["TARGET= EXTRACT=1", *fex, str(self.image), "--no-gui"], self.launch(fex))
|
||||
self.machine(62)
|
||||
self.assertEqual(["TARGET= EXTRACT=1", "fex", "run", "--mode", "on", "--", str(self.image), "--no-gui"], self.launch())
|
||||
|
||||
def test_an_x86_image_without_fex_uses_the_shipped_runtime(self):
|
||||
self.machine(62)
|
||||
self.fex.unlink()
|
||||
self.assertEqual(["TARGET=%s EXTRACT=1" % self.image, "uruntime", "--no-gui"], self.launch())
|
||||
|
||||
def test_the_session_starts_images_through_the_shared_launcher(self):
|
||||
script = ("set -u\n"
|
||||
"run_program() { printf '%%s\\n' \"$@\"; exit 0; }\n"
|
||||
"target=%s\nfex=()\nset -- --no-gui\n" % self.image + target_case())
|
||||
out = subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30).stdout.splitlines()
|
||||
self.assertEqual(["/usr/local/bin/droiddeck-appimage-exec", str(self.image), "--no-gui"], out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user