changeset 1319:137a0686de7b

(issue158) Try to find osslsigncode also in the application's directory
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 13 Oct 2014 17:56:50 +0200
parents 45082ec23e76
children 7b42b3be0899
files ui/createinstallerdialog.cpp
diffstat 1 files changed, 23 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ui/createinstallerdialog.cpp	Mon Oct 13 17:41:55 2014 +0200
+++ b/ui/createinstallerdialog.cpp	Mon Oct 13 17:56:50 2014 +0200
@@ -342,7 +342,9 @@
 bool CreateInstallerDialog::signFile(QString filePath) {
     QProcess signProc;
     signProc.setProcessChannelMode(QProcess::MergedChannels);
-    signProc.setProgram("osslsigncode");
+    QStringList candidates;
+    candidates << "osslsigncode"
+        << QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/osslsigncode");
     QStringList arguments;
 
     QSettings mySettings;
@@ -356,18 +358,29 @@
               url << "-h" << hash << "-in" << filePath << "-out" << filePath + ".signed";
 
     qDebug() << "Starting osslsigncode with arguments: " << arguments;
-    signProc.setArguments(arguments);
-    signProc.start();
 
-    if (!signProc.waitForFinished(30000)) {
-        qDebug() << "Signing takes longer then 30 seconds. Aborting.";
-        return false;
+    signProc.setArguments(arguments);
+    bool once_successful = false;
+    foreach (const QString &prog, candidates) {
+        signProc.setProgram(prog);
+        signProc.start();
+
+        if (!signProc.waitForFinished(30000)) {
+            continue;
+        }
+
+        if (signProc.exitStatus() != QProcess::NormalExit ||
+            signProc.exitCode() != 0) {
+            qDebug() << "Error process returned: " << signProc.exitCode();
+            qDebug() << "Output: " << signProc.readAllStandardOutput();
+            continue;
+        }
+        once_successful = true;
+        break;
     }
 
-    if (signProc.exitStatus() != QProcess::NormalExit ||
-        signProc.exitCode() != 0) {
-        qDebug() << "Error process returned: " << signProc.exitCode();
-        qDebug() << "Output: " << signProc.readAllStandardOutput();
+    if (!once_successful) {
+        qDebug() << "Failed to execute all osslsigncode candidates.";
         return false;
     }
 

http://wald.intevation.org/projects/trustbridge/