From 0062230bd8456863ba16b8d7a16cee168038fd91 Mon Sep 17 00:00:00 2001 From: probonopd Date: Sat, 19 Aug 2023 11:24:08 +0200 Subject: [PATCH] Temporary workaround for runappimage --- src/launcher.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/launcher.cpp b/src/launcher.cpp index 6858982..9e2ce8c 100644 --- a/src/launcher.cpp +++ b/src/launcher.cpp @@ -367,16 +367,6 @@ int Launcher::launch(QStringList args) env.insert("LAUNCHED_EXECUTABLE", executable); QFileInfo info = QFileInfo(executable); - /* - // Hackish workaround; TODO: Replace by something cleaner - if (executable.toLower().endsWith(".appimage")) { - if (!info.isExecutable()) { - p.setProgram("runappimage"); - args.insert(0, executable); - } - } - */ - p.setArguments(args); // Hint: LAUNCHED_EXECUTABLE and LAUNCHED_BUNDLE environment variables @@ -602,6 +592,26 @@ int Launcher::open(QStringList args) QString firstArg = args.first(); qDebug() << "open firstArg:" << firstArg; + // Workaround for FreeBSD not being able to properly mount all AppImages + // by using the "runappimage" helper that mounts the AppImage and then + // executes its payload. + // FIXME: This should go away as soon as possible. + + if (QSysInfo::kernelType() == "freebsd") { + // Check if we have the "runappimage" helper + QString runappimage = QStandardPaths::findExecutable("runappimage"); + qDebug() << "runappimage:" << runappimage; + if (! runappimage.isEmpty()) { + if (firstArg.toLower().endsWith(".appimage")) { + QFileInfo info = QFileInfo(firstArg); + if (!info.isExecutable()) { + args.insert(0, runappimage); + firstArg = args.first(); + } + } + } + } + QString appToBeLaunched = nullptr; QStringList removalCandidates = {}; // For applications that possibly don't exist on disk anymore