Simplified logic to detect Linux 64/32 deb/rpm #4565
This commit is contained in:
parent
e479f16705
commit
e8a43dd020
|
@ -1132,12 +1132,12 @@ void MainWindow::downloadBonjour()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
QUrl url;
|
QUrl url;
|
||||||
int arch = checkProcessorArch();
|
int arch = getProcessorArch();
|
||||||
if (arch == Win_x86) {
|
if (arch == kProcessorArchWin32) {
|
||||||
url.setUrl(bonjourBaseUrl + bonjourFilename32);
|
url.setUrl(bonjourBaseUrl + bonjourFilename32);
|
||||||
appendLogNote("downloading 32-bit Bonjour");
|
appendLogNote("downloading 32-bit Bonjour");
|
||||||
}
|
}
|
||||||
else if (arch == Win_x64) {
|
else if (arch == kProcessorArchWin64) {
|
||||||
url.setUrl(bonjourBaseUrl + bonjourFilename64);
|
url.setUrl(bonjourBaseUrl + bonjourFilename64);
|
||||||
appendLogNote("downloading 64-bit Bonjour");
|
appendLogNote("downloading 64-bit Bonjour");
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,13 +31,13 @@
|
||||||
|
|
||||||
static const char kBaseUrl[] = "http://synergy-project.org/files";
|
static const char kBaseUrl[] = "http://synergy-project.org/files";
|
||||||
static const char kDefaultVersion[] = "1.1";
|
static const char kDefaultVersion[] = "1.1";
|
||||||
static const char kWinProcessorArch32[] = "Windows-x86";
|
static const char kWinPackagePlatform32[] = "Windows-x86";
|
||||||
static const char kWinProcessorArch64[] = "Windows-x64";
|
static const char kWinPackagePlatform64[] = "Windows-x64";
|
||||||
static const char kMacProcessorArch[] = "MacOSX%1-i386";
|
static const char kMacPackagePlatform32[] = "MacOSX%1-i386";
|
||||||
static const char kLinuxProcessorArchDeb32[] = "Linux-i686-deb";
|
static const char kLinuxPackagePlatformDeb32[] = "Linux-i686-deb";
|
||||||
static const char kLinuxProcessorArchDeb64[] = "Linux-x86_64-deb";
|
static const char kLinuxPackagePlatformDeb64[] = "Linux-x86_64-deb";
|
||||||
static const char kLinuxProcessorArchRpm32[] = "Linux-i686-rpm";
|
static const char kLinuxPackagePlatformRpm32[] = "Linux-i686-rpm";
|
||||||
static const char kLinuxProcessorArchRpm64[] = "Linux-x86_64-rpm";
|
static const char kLinuxPackagePlatformRpm64[] = "Linux-x86_64-rpm";
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
static const char kWinPluginExt[] = ".dll";
|
static const char kWinPluginExt[] = ".dll";
|
||||||
|
@ -158,10 +158,10 @@ QString PluginManager::getPluginUrl(const QString& pluginName)
|
||||||
try {
|
try {
|
||||||
QString coreArch = m_CoreInterface.getArch();
|
QString coreArch = m_CoreInterface.getArch();
|
||||||
if (coreArch.startsWith("x86")) {
|
if (coreArch.startsWith("x86")) {
|
||||||
archName = kWinProcessorArch32;
|
archName = kWinPackagePlatform32;
|
||||||
}
|
}
|
||||||
else if (coreArch.startsWith("x64")) {
|
else if (coreArch.startsWith("x64")) {
|
||||||
archName = kWinProcessorArch64;
|
archName = kWinPackagePlatform64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
|
@ -181,22 +181,43 @@ QString PluginManager::getPluginUrl(const QString& pluginName)
|
||||||
return "";
|
return "";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
archName = QString(kMacProcessorArch).arg(macVersion);
|
archName = QString(kMacPackagePlatform).arg(macVersion);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int arch = checkProcessorArch();
|
QString program("dpkg");
|
||||||
if (arch == Linux_rpm_i686) {
|
QStringList args;
|
||||||
archName = kLinuxProcessorArchRpm32;
|
args << "-s" << "synergy";
|
||||||
|
|
||||||
|
QProcess process;
|
||||||
|
process.setReadChannel(QProcess::StandardOutput);
|
||||||
|
process.start(program, args);
|
||||||
|
bool success = process.waitForStarted();
|
||||||
|
|
||||||
|
if (!success || !process.waitForFinished())
|
||||||
|
{
|
||||||
|
emit error(tr("Could not get Linux package type."));
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
else if (arch == Linux_rpm_x86_64) {
|
|
||||||
archName = kLinuxProcessorArchRpm64;
|
bool isDeb = (process.exitCode() == 0);
|
||||||
|
|
||||||
|
int arch = getProcessorArch();
|
||||||
|
if (arch == kProcessorArchLinux32) {
|
||||||
|
if (isDeb) {
|
||||||
|
archName = kLinuxPackagePlatformDeb32;
|
||||||
}
|
}
|
||||||
else if (arch == Linux_deb_i686) {
|
else {
|
||||||
archName = kLinuxProcessorArchDeb32;
|
archName = kLinuxPackagePlatformRpm32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (arch == kProcessorArchLinux64) {
|
||||||
|
if (isDeb) {
|
||||||
|
archName = kLinuxPackagePlatformDeb64;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
archName = kLinuxPackagePlatformRpm64;
|
||||||
}
|
}
|
||||||
else if (arch == Linux_deb_x86_64) {
|
|
||||||
archName = kLinuxProcessorArchDeb64;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit error(tr("Could not get Linux architecture type."));
|
emit error(tr("Could not get Linux architecture type."));
|
||||||
|
|
|
@ -15,18 +15,14 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PROCESSORARCH_H
|
#pragma once
|
||||||
#define PROCESSORARCH_H
|
|
||||||
|
|
||||||
enum qProcessorArch {
|
enum qProcessorArch {
|
||||||
Win_x86,
|
kProcessorArchWin32,
|
||||||
Win_x64,
|
kProcessorArchWin64,
|
||||||
Mac_i386,
|
kProcessorArchMac32,
|
||||||
Linux_rpm_i686,
|
kProcessorArchMac64,
|
||||||
Linux_rpm_x86_64,
|
kProcessorArchLinux32,
|
||||||
Linux_deb_i686,
|
kProcessorArchLinux64,
|
||||||
Linux_deb_x86_64,
|
kProcessorArchUnknown
|
||||||
unknown
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROCESSORARCH_H
|
|
||||||
|
|
|
@ -29,12 +29,6 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
|
||||||
static const char kLinuxI686[] = "i686";
|
|
||||||
static const char kLinuxX8664[] = "x86_64";
|
|
||||||
static const char kUbuntu[] = "Ubuntu";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void setIndexFromItemData(QComboBox* comboBox, const QVariant& itemData)
|
void setIndexFromItemData(QComboBox* comboBox, const QVariant& itemData)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < comboBox->count(); ++i)
|
for (int i = 0; i < comboBox->count(); ++i)
|
||||||
|
@ -68,7 +62,7 @@ QString getFirstMacAddress()
|
||||||
return mac;
|
return mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
int checkProcessorArch()
|
qProcessorArch getProcessorArch()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
SYSTEM_INFO systemInfo;
|
SYSTEM_INFO systemInfo;
|
||||||
|
@ -76,97 +70,27 @@ int checkProcessorArch()
|
||||||
|
|
||||||
switch (systemInfo.wProcessorArchitecture) {
|
switch (systemInfo.wProcessorArchitecture) {
|
||||||
case PROCESSOR_ARCHITECTURE_INTEL:
|
case PROCESSOR_ARCHITECTURE_INTEL:
|
||||||
return Win_x86;
|
return kProcessorArchWin32;
|
||||||
case PROCESSOR_ARCHITECTURE_IA64:
|
case PROCESSOR_ARCHITECTURE_IA64:
|
||||||
return Win_x64;
|
return kProcessorArchWin64;
|
||||||
case PROCESSOR_ARCHITECTURE_AMD64:
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
||||||
return Win_x64;
|
return kProcessorArchWin64;
|
||||||
default:
|
default:
|
||||||
return unknown;
|
return kProcessorArchUnknown;
|
||||||
}
|
|
||||||
#elif defined(Q_OS_MAC)
|
|
||||||
return Mac_i386;
|
|
||||||
#else
|
|
||||||
bool version32 = false;
|
|
||||||
bool debPackaging = false;
|
|
||||||
|
|
||||||
QString program1("uname");
|
|
||||||
QStringList args1("-m");
|
|
||||||
QProcess process1;
|
|
||||||
process1.setReadChannel(QProcess::StandardOutput);
|
|
||||||
process1.start(program1, args1);
|
|
||||||
bool success = process1.waitForStarted();
|
|
||||||
|
|
||||||
QString out, error;
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
if (process1.waitForFinished()) {
|
|
||||||
out = process1.readAllStandardOutput();
|
|
||||||
error = process1.readAllStandardError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
out = out.trimmed();
|
|
||||||
error = error.trimmed();
|
|
||||||
|
|
||||||
if (out.isEmpty() ||
|
|
||||||
!error.isEmpty() ||
|
|
||||||
!success ||
|
|
||||||
process1.exitCode() != 0)
|
|
||||||
{
|
|
||||||
return unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (out == kLinuxI686) {
|
|
||||||
version32 = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString program2("python");
|
|
||||||
QStringList args2("-mplatform");
|
|
||||||
QProcess process2;
|
|
||||||
process2.setReadChannel(QProcess::StandardOutput);
|
|
||||||
process2.start(program2, args2);
|
|
||||||
success = process2.waitForStarted();
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
if (process2.waitForFinished()) {
|
|
||||||
out = process2.readAllStandardOutput();
|
|
||||||
error = process2.readAllStandardError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
out = out.trimmed();
|
|
||||||
error = error.trimmed();
|
|
||||||
|
|
||||||
if (out.isEmpty() ||
|
|
||||||
!error.isEmpty() ||
|
|
||||||
!success ||
|
|
||||||
process2.exitCode() != 0)
|
|
||||||
{
|
|
||||||
return unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (out.contains(kUbuntu)) {
|
|
||||||
debPackaging = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version32) {
|
|
||||||
if (debPackaging) {
|
|
||||||
return Linux_deb_i686;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return Linux_rpm_i686;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (debPackaging) {
|
|
||||||
return Linux_deb_x86_64;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return Linux_rpm_x86_64;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return unknown;
|
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
return kProcessorArchMac;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Q_OS_LINUX)
|
||||||
|
#ifdef __i386__
|
||||||
|
return kProcessorArchLinux32;
|
||||||
|
#else
|
||||||
|
return kProcessorArchLinux64;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return kProcessorArchUnknown;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "ProcessorArch.h"
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
@ -25,4 +27,4 @@
|
||||||
void setIndexFromItemData(QComboBox* comboBox, const QVariant& itemData);
|
void setIndexFromItemData(QComboBox* comboBox, const QVariant& itemData);
|
||||||
QString hash(const QString& string);
|
QString hash(const QString& string);
|
||||||
QString getFirstMacAddress();
|
QString getFirstMacAddress();
|
||||||
int checkProcessorArch();
|
qProcessorArch getProcessorArch();
|
||||||
|
|
Loading…
Reference in New Issue