revert: "fix(appimage): launch external processes with bundled linker"

Refs: c305ed4
Signed-off-by: Seth Flynn <getchoo@tuta.io>
This commit is contained in:
Seth Flynn
2025-12-17 04:56:32 -05:00
parent 06e99e2990
commit 1d8bf82ef8
6 changed files with 32 additions and 105 deletions

View File

@@ -26,6 +26,7 @@
#include <QDebug>
#include <QDir>
#include <QMessageBox>
#include <QProcess>
#include <QProgressDialog>
#include <QSettings>
#include <QTimer>
@@ -34,7 +35,6 @@
#include "StringUtils.h"
#include "BuildConfig.h"
#include "FileSystem.h"
#include "ui/dialogs/UpdateAvailableDialog.h"
@@ -97,9 +97,14 @@ void PrismExternalUpdater::checkForUpdates(bool triggeredByUser)
progress.show();
QCoreApplication::processEvents();
QProcess proc;
auto exe_name = QStringLiteral("%1_updater").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
#if defined Q_OS_WIN32
exe_name.append(".exe");
auto env = QProcessEnvironment::systemEnvironment();
env.insert("__COMPAT_LAYER", "RUNASINVOKER");
proc.setProcessEnvironment(env);
#else
exe_name = QString("bin/%1").arg(exe_name);
#endif
@@ -108,21 +113,15 @@ void PrismExternalUpdater::checkForUpdates(bool triggeredByUser)
if (priv->allowBeta)
args.append("--pre-release");
auto proc = FS::createProcess(priv->appDir.absoluteFilePath(exe_name), args);
#if defined Q_OS_WIN32
auto env = QProcessEnvironment::systemEnvironment();
env.insert("__COMPAT_LAYER", "RUNASINVOKER");
proc->setProcessEnvironment(env);
#endif
proc->start(proc->program(), proc->arguments());
auto result_start = proc->waitForStarted(5000);
proc.start(priv->appDir.absoluteFilePath(exe_name), args);
auto result_start = proc.waitForStarted(5000);
if (!result_start) {
auto err = proc->error();
auto err = proc.error();
qDebug() << "Failed to start updater after 5 seconds."
<< "reason:" << err << proc->errorString();
<< "reason:" << err << proc.errorString();
auto msgBox =
QMessageBox(QMessageBox::Information, tr("Update Check Failed"),
tr("Failed to start after 5 seconds\nReason: %1.").arg(proc->errorString()), QMessageBox::Ok, priv->parent);
tr("Failed to start after 5 seconds\nReason: %1.").arg(proc.errorString()), QMessageBox::Ok, priv->parent);
msgBox.setMinimumWidth(460);
msgBox.adjustSize();
msgBox.exec();
@@ -134,16 +133,16 @@ void PrismExternalUpdater::checkForUpdates(bool triggeredByUser)
}
QCoreApplication::processEvents();
auto result_finished = proc->waitForFinished(60000);
auto result_finished = proc.waitForFinished(60000);
if (!result_finished) {
proc->kill();
auto err = proc->error();
auto output = proc->readAll();
proc.kill();
auto err = proc.error();
auto output = proc.readAll();
qDebug() << "Updater failed to close after 60 seconds."
<< "reason:" << err << proc->errorString();
<< "reason:" << err << proc.errorString();
auto msgBox =
QMessageBox(QMessageBox::Information, tr("Update Check Failed"),
tr("Updater failed to close 60 seconds\nReason: %1.").arg(proc->errorString()), QMessageBox::Ok, priv->parent);
tr("Updater failed to close 60 seconds\nReason: %1.").arg(proc.errorString()), QMessageBox::Ok, priv->parent);
msgBox.setDetailedText(output);
msgBox.setMinimumWidth(460);
msgBox.adjustSize();
@@ -155,10 +154,10 @@ void PrismExternalUpdater::checkForUpdates(bool triggeredByUser)
return;
}
auto exit_code = proc->exitCode();
auto exit_code = proc.exitCode();
auto std_output = proc->readAllStandardOutput();
auto std_error = proc->readAllStandardError();
auto std_output = proc.readAllStandardOutput();
auto std_error = proc.readAllStandardError();
progress.hide();
QCoreApplication::processEvents();
@@ -336,9 +335,14 @@ void PrismExternalUpdater::offerUpdate(const QString& version_name, const QStrin
void PrismExternalUpdater::performUpdate(const QString& version_tag)
{
QProcess proc;
auto exe_name = QStringLiteral("%1_updater").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
#if defined Q_OS_WIN32
exe_name.append(".exe");
auto env = QProcessEnvironment::systemEnvironment();
env.insert("__COMPAT_LAYER", "RUNASINVOKER");
proc.setProcessEnvironment(env);
#else
exe_name = QString("bin/%1").arg(exe_name);
#endif
@@ -347,16 +351,9 @@ void PrismExternalUpdater::performUpdate(const QString& version_tag)
if (priv->allowBeta)
args.append("--pre-release");
auto proc = FS::createProcess(exe_name, args);
#if defined Q_OS_WIN32
auto env = QProcessEnvironment::systemEnvironment();
env.insert("__COMPAT_LAYER", "RUNASINVOKER");
proc->setProcessEnvironment(env);
#endif
auto result = proc->startDetached(priv->appDir.absoluteFilePath(exe_name), args);
auto result = proc.startDetached(priv->appDir.absoluteFilePath(exe_name), args);
if (!result) {
qDebug() << "Failed to start updater:" << proc->error() << proc->errorString();
qDebug() << "Failed to start updater:" << proc.error() << proc.errorString();
}
QCoreApplication::exit();
}

View File

@@ -124,19 +124,7 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar
logToConsole = parser.isSet("debug");
QString origCwdPath = QDir::currentPath();
#if defined(Q_OS_LINUX)
// NOTE(@getchoo): In order for `go-appimage` to generate self-contained AppImages, it executes apps from a bundled linker at
// <root>/lib64
// This is not the path to our actual binary, which we want
QString binPath;
if (DesktopServices::isSelfContained()) {
binPath = FS::PathCombine(applicationDirPath(), "../usr/bin");
} else {
binPath = applicationDirPath();
}
#else
QString binPath = applicationDirPath();
#endif
{ // find data director
// Root path is used for updates and portable data
@@ -819,16 +807,13 @@ QFileInfo PrismUpdaterApp::downloadAsset(const GitHubReleaseAsset& asset)
bool PrismUpdaterApp::callAppImageUpdate()
{
auto appimage_path = QProcessEnvironment::systemEnvironment().value(QStringLiteral("APPIMAGE"));
QProcess proc = QProcess();
qDebug() << "Calling: AppImageUpdate" << appimage_path;
const auto program = FS::PathCombine(m_rootPath, "bin", "AppImageUpdate.AppImage");
auto proc = FS::createProcess(program, { appimage_path });
if (!proc) {
qCritical() << "Unable to create process:" << program;
return false;
}
auto result = proc->startDetached();
proc.setProgram(FS::PathCombine(m_rootPath, "bin", "AppImageUpdate.AppImage"));
proc.setArguments({ appimage_path });
auto result = proc.startDetached();
if (!result)
qDebug() << "Failed to start AppImageUpdate reason:" << proc->errorString();
qDebug() << "Failed to start AppImageUpdate reason:" << proc.errorString();
return result;
}