From bca57674d09bd0f93800d3f52a10f787316d94c5 Mon Sep 17 00:00:00 2001 From: Adam Potolsky Date: Sat, 14 Feb 2015 19:25:22 -0800 Subject: [PATCH] Added patch that will better detect which Linux distribution is used when determining which plugins to URL to generate. --- src/gui/src/PluginManager.cpp | 20 +++++++--- src/gui/src/ProcessorArch.h | 6 ++- src/gui/src/QUtility.cpp | 74 +++++++++++++++++++++++++++++------ 3 files changed, 79 insertions(+), 21 deletions(-) diff --git a/src/gui/src/PluginManager.cpp b/src/gui/src/PluginManager.cpp index f83e29c3..9da0dd9e 100644 --- a/src/gui/src/PluginManager.cpp +++ b/src/gui/src/PluginManager.cpp @@ -30,8 +30,10 @@ static QString kPluginsBaseUrl = "http://synergy-project.org/files/plugins/"; static const char kWinProcessorArch32[] = "Windows-x86"; static const char kWinProcessorArch64[] = "Windows-x64"; static const char kMacProcessorArch[] = "MacOSX-i386"; -static const char kLinuxProcessorArch32[] = "Linux-i686"; -static const char kLinuxProcessorArch64[] = "Linux-x86_64"; +static const char kLinuxProcessorArchDeb32[] = "Linux-i686-deb"; +static const char kLinuxProcessorArchDeb64[] = "Linux-x86_64-deb"; +static const char kLinuxProcessorArchRpm32[] = "Linux-i686-rpm"; +static const char kLinuxProcessorArchRpm64[] = "Linux-x86_64-rpm"; static QString kOpenSSLBaseUrl = "http://synergy-foss.org/files/tools/"; static QString kCertificateLifetime = "365"; static QString kCertificateSubjectInfo = "/CN=Synergy"; @@ -184,11 +186,17 @@ QString PluginManager::getPluginUrl(const QString& pluginName) else if (arch == Mac_i386) { result.append(kMacProcessorArch); } - else if (arch == Linux_i686) { - result.append(kLinuxProcessorArch32); + else if (arch == Linux_rpm_i686) { + result.append(kLinuxProcessorArchRpm32); } - else if (arch == Linux_x86_64) { - result.append(kLinuxProcessorArch64); + else if (arch == Linux_rpm_x86_64) { + result.append(kLinuxProcessorArchRpm64); + } + else if (arch == Linux_deb_i686) { + result.append(kLinuxProcessorArchDeb32); + } + else if (arch == Linux_deb_x86_64) { + result.append(kLinuxProcessorArchDeb64); } else { emit error( diff --git a/src/gui/src/ProcessorArch.h b/src/gui/src/ProcessorArch.h index 61c60d65..c68465fe 100644 --- a/src/gui/src/ProcessorArch.h +++ b/src/gui/src/ProcessorArch.h @@ -22,8 +22,10 @@ enum qProcessorArch { Win_x86, Win_x64, Mac_i386, - Linux_i686, - Linux_x86_64, + Linux_rpm_i686, + Linux_rpm_x86_64, + Linux_deb_i686, + Linux_deb_x86_64, unknown }; diff --git a/src/gui/src/QUtility.cpp b/src/gui/src/QUtility.cpp index c9902cf0..7dba0752 100644 --- a/src/gui/src/QUtility.cpp +++ b/src/gui/src/QUtility.cpp @@ -32,6 +32,7 @@ #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) @@ -86,19 +87,22 @@ int checkProcessorArch() #elif defined(Q_OS_MAC) return Mac_i386; #else - QString program("uname"); - QStringList args("-m"); - QProcess process; - process.setReadChannel(QProcess::StandardOutput); - process.start(program, args); - bool success = process.waitForStarted(); + 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 (process.waitForFinished()) { - out = process.readAllStandardOutput(); - error = process.readAllStandardError(); + if (process1.waitForFinished()) { + out = process1.readAllStandardOutput(); + error = process1.readAllStandardError(); } } @@ -108,16 +112,60 @@ int checkProcessorArch() if (out.isEmpty() || !error.isEmpty() || !success || - process.exitCode() != 0) + process1.exitCode() != 0) { return unknown; } if (out == kLinuxI686) { - return Linux_i686; + version32 = true; } - else if (out == kLinuxX8664) { - return Linux_x86_64; + + 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 return unknown;