diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp index dac69616d..cc28bfc1d 100644 --- a/launcher/updater/prismupdater/PrismUpdater.cpp +++ b/launcher/updater/prismupdater/PrismUpdater.cpp @@ -123,70 +123,6 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar logToConsole = parser.isSet("debug"); - auto updater_executable = QCoreApplication::applicationFilePath(); - -#ifdef Q_OS_MACOS - showFatalErrorMessage(tr("MacOS Not Supported"), tr("The updater does not support installations on MacOS")); -#endif - - if (updater_executable.startsWith("/tmp/.mount_")) { - m_isAppimage = true; - m_appimagePath = QProcessEnvironment::systemEnvironment().value(QStringLiteral("APPIMAGE")); - if (m_appimagePath.isEmpty()) { - showFatalErrorMessage(tr("Unsupported Installation"), - tr("Updater is running as misconfigured AppImage? ($APPIMAGE environment variable is missing)")); - } - } - - m_isFlatpak = DesktopServices::isFlatpak(); - - QString prism_executable = FS::PathCombine(applicationDirPath(), BuildConfig.LAUNCHER_APP_BINARY_NAME); -#if defined Q_OS_WIN32 - prism_executable.append(".exe"); -#endif - - if (!QFileInfo(prism_executable).isFile()) { - showFatalErrorMessage(tr("Unsupported Installation"), tr("The updater can not find the main executable.")); - } - - m_prismExecutable = prism_executable; - - auto prism_update_url = parser.value("update-url"); - if (prism_update_url.isEmpty()) - prism_update_url = BuildConfig.UPDATER_GITHUB_REPO; - - m_prismRepoUrl = QUrl::fromUserInput(prism_update_url); - - m_checkOnly = parser.isSet("check-only"); - m_forceUpdate = parser.isSet("force"); - m_printOnly = parser.isSet("list"); - auto user_version = parser.value("install-version"); - if (!user_version.isEmpty()) { - m_userSelectedVersion = Version(user_version); - } - m_selectUI = parser.isSet("select-ui"); - m_allowDowngrade = parser.isSet("allow-downgrade"); - - auto version = parser.value("prism-version"); - if (!version.isEmpty()) { - if (version.contains('-')) { - auto index = version.indexOf('-'); - m_prsimVersionChannel = version.mid(index + 1); - version = version.left(index); - } else { - m_prsimVersionChannel = "stable"; - } - auto version_parts = version.split('.'); - m_prismVersionMajor = version_parts.takeFirst().toInt(); - m_prismVersionMinor = version_parts.takeFirst().toInt(); - if (!version_parts.isEmpty()) - m_prismVersionPatch = version_parts.takeFirst().toInt(); - else - m_prismVersionPatch = 0; - } - - m_allowPreRelease = parser.isSet("pre-release"); - 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 @@ -375,6 +311,68 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar m_network->setProxy(proxy); } +#ifdef Q_OS_MACOS + showFatalErrorMessage(tr("MacOS Not Supported"), tr("The updater does not support installations on MacOS")); +#endif + + if (binPath.startsWith("/tmp/.mount_")) { + m_isAppimage = true; + m_appimagePath = QProcessEnvironment::systemEnvironment().value(QStringLiteral("APPIMAGE")); + if (m_appimagePath.isEmpty()) { + showFatalErrorMessage(tr("Unsupported Installation"), + tr("Updater is running as misconfigured AppImage? ($APPIMAGE environment variable is missing)")); + } + } + + m_isFlatpak = DesktopServices::isFlatpak(); + + QString prism_executable = FS::PathCombine(binPath, BuildConfig.LAUNCHER_APP_BINARY_NAME); +#if defined Q_OS_WIN32 + prism_executable.append(".exe"); +#endif + + if (!QFileInfo(prism_executable).isFile()) { + showFatalErrorMessage(tr("Unsupported Installation"), tr("The updater can not find the main executable.")); + } + + m_prismExecutable = prism_executable; + + auto prism_update_url = parser.value("update-url"); + if (prism_update_url.isEmpty()) + prism_update_url = BuildConfig.UPDATER_GITHUB_REPO; + + m_prismRepoUrl = QUrl::fromUserInput(prism_update_url); + + m_checkOnly = parser.isSet("check-only"); + m_forceUpdate = parser.isSet("force"); + m_printOnly = parser.isSet("list"); + auto user_version = parser.value("install-version"); + if (!user_version.isEmpty()) { + m_userSelectedVersion = Version(user_version); + } + m_selectUI = parser.isSet("select-ui"); + m_allowDowngrade = parser.isSet("allow-downgrade"); + + auto version = parser.value("prism-version"); + if (!version.isEmpty()) { + if (version.contains('-')) { + auto index = version.indexOf('-'); + m_prsimVersionChannel = version.mid(index + 1); + version = version.left(index); + } else { + m_prsimVersionChannel = "stable"; + } + auto version_parts = version.split('.'); + m_prismVersionMajor = version_parts.takeFirst().toInt(); + m_prismVersionMinor = version_parts.takeFirst().toInt(); + if (!version_parts.isEmpty()) + m_prismVersionPatch = version_parts.takeFirst().toInt(); + else + m_prismVersionPatch = 0; + } + + m_allowPreRelease = parser.isSet("pre-release"); + auto marker_file_path = QDir(m_rootPath).absoluteFilePath(".prism_launcher_updater_unpack.marker"); auto marker_file = QFileInfo(marker_file_path); if (marker_file.exists()) {