Rework companion installer for linux
This commit is contained in:
@@ -25,23 +25,32 @@
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
#if defined(__APPLE__)
|
||||
#define OS_SUPPORTED_INSTALLER
|
||||
#define OS_FILEPATTERN "edgetx-cpn-osx"
|
||||
#define OS_INSTALLER_EXTN "*.dmg"
|
||||
#define OS_INSTALL_QUESTION tr("Would you like to open the disk image to install the new version of Companion?")
|
||||
#elif defined(Q_OS_WIN64)
|
||||
#elif defined(_WIN64)
|
||||
#define OS_SUPPORTED_INSTALLER
|
||||
#define OS_FILEPATTERN "edgetx-cpn-win64"
|
||||
#define OS_INSTALLER_EXTN "*.exe"
|
||||
#define OS_INSTALL_QUESTION tr("Would you like to launch the Companion installer?")
|
||||
#elif defined(Q_OS_WIN32)
|
||||
#elif defined(_WIN32)
|
||||
#define OS_SUPPORTED_INSTALLER
|
||||
#define OS_FILEPATTERN "edgetx-cpn-win32"
|
||||
#define OS_INSTALLER_EXTN "*.exe"
|
||||
#define OS_INSTALL_QUESTION tr("Would you like to launch the Companion installer?")
|
||||
#else
|
||||
#elif defined(__linux__) || defined(__linux)
|
||||
#define OS_SUPPORTED_INSTALLER
|
||||
#define OS_FILEPATTERN "edgetx-cpn-linux"
|
||||
#define OS_INSTALLER_EXTN "*.AppImage"
|
||||
#define OS_INSTALL_QUESTION tr("Would you like to open the app image to install the new version of Companion?")
|
||||
#else
|
||||
#define OS_INSTALL_MSG tr("No install process support for your operating system")
|
||||
#endif
|
||||
|
||||
UpdateCompanion::UpdateCompanion(QWidget * parent) :
|
||||
@@ -60,17 +69,24 @@ UpdateCompanion::UpdateCompanion(QWidget * parent) :
|
||||
ap.flags = dfltParams->data.flags;
|
||||
}
|
||||
|
||||
#ifndef OS_SUPPORTED_INSTALLER
|
||||
bool UpdateCompanion::asyncInstall()
|
||||
{
|
||||
reportProgress(tr("Run application installer: %1").arg(g.runAppInstaller() ? tr("true") : tr("false")), QtDebugMsg);
|
||||
QMessageBox::warning(parentWidget(), CPN_STR_APP_NAME, OS_INSTALL_MSG);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
bool UpdateCompanion::asyncInstall()
|
||||
{
|
||||
//reportProgress(tr("Run application installer: %1").arg(g.runAppInstaller() ? tr("true") : tr("false")), QtDebugMsg);
|
||||
|
||||
if (!g.runAppInstaller())
|
||||
return true;
|
||||
|
||||
progressMessage(tr("Async install"));
|
||||
progressMessage(tr("Install"));
|
||||
|
||||
assets->setFilterFlags(UPDFLG_AsyncInstall);
|
||||
reportProgress(tr("Asset filter applied: %1 Assets found: %2").arg(updateFlagsToString(UPDFLG_AsyncInstall)).arg(assets->count()), QtDebugMsg);
|
||||
//reportProgress(tr("Asset filter applied: %1 Assets found: %2").arg(updateFlagsToString(UPDFLG_AsyncInstall)).arg(assets->count()), QtDebugMsg);
|
||||
|
||||
if (assets->count() != 1) {
|
||||
reportProgress(tr("Expected 1 asset for install but none found"), QtCriticalMsg);
|
||||
@@ -97,6 +113,34 @@ bool UpdateCompanion::asyncInstall()
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(__linux__) || defined(__linux)
|
||||
QFile f(installerPath);
|
||||
if (!f.setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ExeOwner)) {
|
||||
QMessageBox::critical(parentWidget(), CPN_STR_APP_NAME, tr("Unable to set file permissions on the AppImage"));
|
||||
return false;
|
||||
}
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
|
||||
QString("%1/%2").arg(QDir::currentPath()).arg(QFileInfo(f).fileName()), tr("Images (*.AppImage)"));
|
||||
if (fileName.isEmpty())
|
||||
return true;
|
||||
|
||||
QFile dest(fileName);
|
||||
|
||||
if (dest.exists()) {
|
||||
if (!dest.remove()) {
|
||||
QMessageBox::critical(parentWidget(), CPN_STR_APP_NAME, tr("Unable to delete file %1").arg(fileName));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!QFile::copy(installerPath, fileName)) {
|
||||
QMessageBox::critical(parentWidget(), CPN_STR_APP_NAME, tr("Unable to copy file to %1").arg(fileName));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
int ret = QMessageBox::question(parentWidget(), CPN_STR_APP_NAME, OS_INSTALL_QUESTION, QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
if (ret == QMessageBox::Yes) {
|
||||
@@ -105,7 +149,9 @@ bool UpdateCompanion::asyncInstall()
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
const QString UpdateCompanion::currentRelease()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user