annotate ui/createinstallerdialog.cpp @ 930:9e2266aa1cbf

(issue64) Add 256px icon
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 22 Aug 2014 16:01:26 +0200
parents ad590fb9ab8f
children 01128d63226d
rev   line source
404
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 361
diff changeset
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 361
diff changeset
2 * Software engineering by Intevation GmbH
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 361
diff changeset
3 *
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 361
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 361
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 361
diff changeset
6 * See LICENSE.txt for details.
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 361
diff changeset
7 */
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 #include "createinstallerdialog.h"
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
9 #include "sslhelp.h"
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
10
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 #include <QDebug>
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
12 #include <QTextEdit>
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 #include <QDir>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 #include <QPushButton>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 #include <QGroupBox>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 #include <QHBoxLayout>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 #include <QVBoxLayout>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 #include <QLabel>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 #include <QFileDialog>
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
20 #include <QSaveFile>
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
21 #include <QSettings>
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
22 #include <QStyle>
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
23 #include <QApplication>
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
24 #include <QMessageBox>
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
25 #include <QTemporaryDir>
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
26
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
27 #include <polarssl/pk.h>
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
28
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
29 /* Static information used in codesigning */
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
30 #ifndef SIGN_HASH
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
31 #define SIGN_HASH "sha256"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
32 #endif
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
33 #ifndef SIGN_URL
852
637948e9e32d (issue61) Change temporary link into wald from https to http
Andre Heinecke <andre.heinecke@intevation.de>
parents: 781
diff changeset
34 #define SIGN_URL "http://wald.intevation.org/projects/trustbridge/"
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
35 #endif
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
36 #ifndef SIGN_PUBLISHER
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
37 #define SIGN_PUBLISHER "TrustBridge Test with ümlaut"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
38 #endif
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
39
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 CreateInstallerDialog::CreateInstallerDialog(QMainWindow *parent) :
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
41 QDialog(parent),
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
42 mProgress(this),
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
43 mInstallerPath(),
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
44 mCurrentWorkingDir(NULL)
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
46 QSettings settings;
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
47 setWindowTitle(tr("Create binary installer"));
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
48 setupGUI();
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
49 resize(500, 250);
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
50 mCertFile->setText(settings.value("CodeSignCert", QString()).toString());
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
51 mBinaryFolder->setText(settings.value("LastBinaryFolder", QString()).toString());
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
52 mSaveFile->setText(settings.value("LastBinOutputFolder", QString()).toString());
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
53
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
54 connect(&mNSISProc, SIGNAL(finished(int, QProcess::ExitStatus)),
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
55 this, SLOT(processFinished(int, QProcess::ExitStatus)));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
56 connect(&mNSISProc, SIGNAL(error(QProcess::ProcessError)),
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
57 this, SLOT(processError(QProcess::ProcessError)));
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 void CreateInstallerDialog::setupGUI()
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 {
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62 /* Top level layout / widgets */
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 QVBoxLayout *topLayout = new QVBoxLayout;
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
64 QVBoxLayout *headerLayout = new QVBoxLayout;
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
65 QHBoxLayout *headerSubLayout = new QHBoxLayout;
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
66 QHBoxLayout *centerLayout = new QHBoxLayout;
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67 QHBoxLayout *bottomLayout = new QHBoxLayout;
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
68 QVBoxLayout *labelLayout = new QVBoxLayout;
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
69 QVBoxLayout *fieldLayout = new QVBoxLayout;
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
70 QVBoxLayout *buttonLayout = new QVBoxLayout;
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
72 QLabel *header = new QLabel("<h3>" + tr("Create binary installer") + "</h3>");
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
73 QLabel *description = new QLabel(
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
74 tr("Create and sign a TrustBridge binary installer."));
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
75 headerSubLayout->insertSpacing(0, 40);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
76 headerSubLayout->addWidget(description);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
77 QFrame *headerSeparator = new QFrame();
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
78 headerSeparator->setFrameShape(QFrame::HLine);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
79 headerSeparator->setFrameShadow(QFrame::Sunken);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
80 headerLayout->addWidget(header);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
81 headerLayout->addLayout(headerSubLayout);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
82 headerLayout->addWidget(headerSeparator);
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
83 headerLayout->insertSpacing(4, 10);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
85 QLabel *archiveLabel = new QLabel(tr("Select binary folder:"));
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
86 QLabel *certLabel = new QLabel(tr("Select code signing certificate:"));
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
87 QLabel *saveLabel = new QLabel(tr("Select output folder:"));
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
88 labelLayout->addWidget(archiveLabel);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
89 labelLayout->addWidget(certLabel);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
90 labelLayout->addWidget(saveLabel);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
91
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
92 mBinaryFolder = new QLineEdit();
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
93 mCertFile = new QLineEdit();
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
94 mSaveFile = new QLineEdit();
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
95 fieldLayout->addWidget(mBinaryFolder);
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
96 fieldLayout->addWidget(mCertFile);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
97 fieldLayout->addWidget(mSaveFile);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
98
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99 QPushButton *archiveSelect = new QPushButton("...");
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
100 connect(archiveSelect, SIGNAL(clicked()), this, SLOT(openFolderSelect()));
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 archiveSelect->setFixedWidth(30);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 QPushButton *certSelect = new QPushButton("...");
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 connect(certSelect, SIGNAL(clicked()), this, SLOT(openCertificateSelect()));
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 certSelect->setFixedWidth(30);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 QPushButton *saveSelect = new QPushButton("...");
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 connect(saveSelect, SIGNAL(clicked()), this, SLOT(openSaveLocation()));
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 saveSelect->setFixedWidth(30);
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
108 buttonLayout->addWidget(archiveSelect);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
109 buttonLayout->addWidget(certSelect);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
110 buttonLayout->addWidget(saveSelect);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
111
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
112 centerLayout->addLayout(labelLayout);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
113 centerLayout->addLayout(fieldLayout);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
114 centerLayout->addLayout(buttonLayout);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
115
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
116 QPushButton *create = new QPushButton(tr("Create installer"));
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
117 connect(create, SIGNAL(clicked()), this, SLOT(createInstaller()));
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
118 QPushButton *cancel = new QPushButton(tr("Cancel"));
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
119 connect(cancel, SIGNAL(clicked()), this, SLOT(close()));
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
120 bottomLayout->insertStretch(0, 10);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
121 bottomLayout->addWidget(create);
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
122 bottomLayout->addWidget(cancel);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
123
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
124 QFrame *bottomSeparator = new QFrame();
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
125 bottomSeparator->setFrameShape(QFrame::HLine);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
126 bottomSeparator->setFrameShadow(QFrame::Sunken);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
127
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
128 topLayout->addLayout(headerLayout);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
129 topLayout->addLayout(centerLayout);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
130 topLayout->insertStretch(2, 10);
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
131 centerLayout->insertSpacing(3, 10);
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
132 topLayout->addWidget(bottomSeparator);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
133 topLayout->addLayout(bottomLayout);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
134
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
135 setLayout(topLayout);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
136
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
137 mProgress.setWindowModality(Qt::WindowModal);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
138 mProgress.setCancelButton(0);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
139 mProgress.setRange(0,0);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
140 mProgress.setMinimumDuration(0);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
141
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
142 return;
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
143 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
144
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
145 void CreateInstallerDialog::openCertificateSelect()
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
146 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
147 QSettings settings;
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
148 QString certFile = QFileDialog::getOpenFileName(
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
149 this, tr("Select certificate"),
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
150 mCertFile->text().isEmpty() ? QDir::homePath() : mCertFile->text(),
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
151 "*.pem *.der *.crt");
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
152 settings.setValue("CodeSignCert", certFile);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
153 mCertFile->setText(certFile);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
154 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
155
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
156 void CreateInstallerDialog::openFolderSelect()
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
157 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
158 QSettings settings;
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
159 QString archiveFolder = QFileDialog::getExistingDirectory(
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
160 this, tr("Select binary folder"),
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
161 mBinaryFolder->text().isEmpty() ? QDir::homePath() : mBinaryFolder->text());
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
162 mBinaryFolder->setText(archiveFolder);
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
163 settings.setValue("LastBinaryFolder", archiveFolder);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
164 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
165
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
166 void CreateInstallerDialog::openSaveLocation()
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
167 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
168 QSettings settings;
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
169 QString saveFile = QFileDialog::getExistingDirectory(
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
170 this, tr("Select target location"),
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
171 mSaveFile->text().isEmpty() ? QDir::homePath() : mSaveFile->text());
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
172 mSaveFile->setText(saveFile);
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
173 settings.setValue("LastBinOutputFolder", saveFile);
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
174 }
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
175
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
176 void CreateInstallerDialog::showErrorMessage(const QString &msg)
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
177 {
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
178 QMessageBox::warning(this, tr("Error!"), msg);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
179 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
180
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
181 void CreateInstallerDialog::processFinished(int exitCode, QProcess::ExitStatus exitStatus)
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
182 {
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
183 if (mCurrentWorkingDir) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
184 delete mCurrentWorkingDir;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
185 mCurrentWorkingDir = NULL;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
186 }
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
187 FinishedDialog *fin = new FinishedDialog(0, tr("Created installer in %1.")
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
188 .arg(mSaveFile->text()), mNSISProc.readAll(), false);
518
31e0a86f5a35 Actually set the arguments for makensis process. Fix escaping
Andre Heinecke <aheinecke@intevation.de>
parents: 516
diff changeset
189 qDebug() << "Finished: " << mNSISProc.readAll();
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
190 mProgress.setLabelText(tr("Signing installer package..."));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
191 if (!signFile(mInstallerPath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
192 showErrorMessage(tr("Failed to sign installer package."));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
193 QFile::remove(mInstallerPath);
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
194 }
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
195 mProgress.cancel();
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
196 fin->show();
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
197 close();
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
198 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
199
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
200 void CreateInstallerDialog::processError(QProcess::ProcessError error)
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
201 {
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
202 if (mCurrentWorkingDir) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
203 delete mCurrentWorkingDir;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
204 mCurrentWorkingDir = NULL;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
205 }
518
31e0a86f5a35 Actually set the arguments for makensis process. Fix escaping
Andre Heinecke <aheinecke@intevation.de>
parents: 516
diff changeset
206 qDebug() << "Error: " << mNSISProc.readAll();
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
207 mProgress.cancel();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
208 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
209
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
210 void CreateInstallerDialog::createInstaller()
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
211 {
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
212 mProgress.setLabelText(tr("Creating installer package..."));
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
213 QDir binDir(mBinaryFolder->text());
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
214 QDir outDir(mSaveFile->text());
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
215 if (mBinaryFolder->text().isEmpty() || !binDir.exists()) {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
216 showErrorMessage(tr("Please select an existing input folder."));
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
217 return;
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
218 }
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
219 if (mCertFile->text().isEmpty()) {
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
220 showErrorMessage(tr("Please select a codesigning certificate."));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
221 return;
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
222 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
223 if (mSaveFile->text().isEmpty() || !outDir.exists()) {
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
224 showErrorMessage(tr("Please select a output folder."));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
225 return;
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
226 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
227 QSettings options(binDir.filePath("meta.ini"), QSettings::IniFormat);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
228 options.sync();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
229 QStringList keys = options.allKeys();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
230 if (options.status() != QSettings::NoError || keys.size() < 1) {
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
231 showErrorMessage(tr("Folder %1 does not appear to contain a meta.ini")
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
232 .arg(binDir.path()));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
233 return;
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
234 }
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
235 /* Sign the linux installer */
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
236 QDir linuxDir(binDir.path() + "/linux");
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
237 if (!linuxDir.exists()) {
781
60d3f59f0803 Fix typos in translatable strings.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 772
diff changeset
238 showErrorMessage(tr("Failed to find the directory for linux binaries: %1")
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
239 .arg(linuxDir.path()));
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
240 return;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
241 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
242 QStringList nameFilter;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
243 nameFilter << "*.sh";
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
244 QStringList candidates = linuxDir.entryList(nameFilter, QDir::Files | QDir::Readable);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
245 if (candidates.isEmpty()) {
781
60d3f59f0803 Fix typos in translatable strings.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 772
diff changeset
246 showErrorMessage(tr("Failed to find a readable *.sh file in: %1")
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
247 .arg(linuxDir.path()));
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
248 return;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
249 }
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
250
885
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
251 foreach (const QString& candidate, candidates) {
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
252 mProgress.setLabelText(tr("Signing Linux package..."));
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
253 mProgress.cancel();
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
254
885
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
255 bool x86arch;
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
256 if (candidate.endsWith("-i386.sh")) {
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
257 x86arch = true;
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
258 } else if (candidate.endsWith("-amd64.sh")) {
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
259 x86arch = false;
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
260 } else {
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
261 qDebug() << "Could not detrmine architecture of " << candidate;
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
262 qDebug() << "Skipping.";
886
197c594aad2b Really skip unknown packages when creating the installer.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 885
diff changeset
263 continue;
885
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
264 }
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
265
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
266 QString outFileName = options.value("setupname", "TrustBridge-default.exe"
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
267 ).toString().replace(".exe",
890
ad590fb9ab8f Fix another error in package output names.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 889
diff changeset
268 x86arch ? "-i386.sh" : "-amd64.sh").arg(QString());
885
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
269
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
270 if (!appendTextSignatureToFile(linuxDir.path() + "/" + candidate,
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
271 outDir.path() + "/" + outFileName)) {
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
272 showErrorMessage(tr("Failed to sign linux package: %1").arg(candidate));
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
273 mProgress.close();
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
274 return;
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
275 }
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
276 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
277
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
278 /* The Windows installer */
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
279
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
280 mCurrentWorkingDir = codesignBinaries(binDir.path() + "/windows");
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
281
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
282 if (!mCurrentWorkingDir) {
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
283 /* Error messages should have been shown by the codesign function */
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
284 mProgress.close();
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
285 return;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
286 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
287
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
288 mProgress.setLabelText(tr("Creating NSIS package..."));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
289
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
290 /* Copy windows directory contents to tmpdir */
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
291 QStringList arguments;
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
292 mNSISProc.setProgram("makensis");
518
31e0a86f5a35 Actually set the arguments for makensis process. Fix escaping
Andre Heinecke <aheinecke@intevation.de>
parents: 516
diff changeset
293 mNSISProc.setProcessChannelMode(QProcess::MergedChannels);
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
294 mNSISProc.setWorkingDirectory(outDir.path());
537
522b4e28c073 Use windows argument format for nsis on windows
Andre Heinecke <aheinecke@intevation.de>
parents: 526
diff changeset
295 #ifdef Q_OS_WIN
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
296 arguments << QString::fromLatin1("/Dfiles_dir=") + mCurrentWorkingDir->path().replace("/", "\\");
541
1cddf87f8f83 ix variable path seperator
Andre Heinecke <aheinecke@intevation.de>
parents: 539
diff changeset
297 arguments << "/Dpath_sep=\\";
537
522b4e28c073 Use windows argument format for nsis on windows
Andre Heinecke <aheinecke@intevation.de>
parents: 526
diff changeset
298 foreach (const QString &key, keys) {
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
299 QString value = options.value(key, QString()).toString();
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
300 if (key == "setupname") {
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
301 value = value.arg(outDir.path().replace("/", "\\") + "\\");
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
302 mInstallerPath = value;
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
303 }
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
304 arguments << QString::fromLatin1("/D%1=%2").arg(key, value);
537
522b4e28c073 Use windows argument format for nsis on windows
Andre Heinecke <aheinecke@intevation.de>
parents: 526
diff changeset
305 }
864
45cf874221af Check for nsi file and convert slashes to backslashes on windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 852
diff changeset
306 arguments << QString(binDir.path() + "/trustbridge.nsi").replace("/", "\\");
537
522b4e28c073 Use windows argument format for nsis on windows
Andre Heinecke <aheinecke@intevation.de>
parents: 526
diff changeset
307 #else
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
308 arguments << QString::fromLatin1("-Dfiles_dir=") + mCurrentWorkingDir->path();
541
1cddf87f8f83 ix variable path seperator
Andre Heinecke <aheinecke@intevation.de>
parents: 539
diff changeset
309 arguments << "-Dpath_sep=/";
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
310 foreach (const QString &key, keys) {
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
311 QString value = options.value(key, QString()).toString();
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
312 if (key == "setupname") {
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
313 value = value.arg(outDir.path() + "/");
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
314 mInstallerPath = value;
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
315 }
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
316 arguments << QString::fromLatin1("-D%1=%2").arg(key, value);
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
317 }
864
45cf874221af Check for nsi file and convert slashes to backslashes on windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 852
diff changeset
318 arguments << binDir.path() + "/trustbridge.nsi";
537
522b4e28c073 Use windows argument format for nsis on windows
Andre Heinecke <aheinecke@intevation.de>
parents: 526
diff changeset
319 #endif
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
320
864
45cf874221af Check for nsi file and convert slashes to backslashes on windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 852
diff changeset
321
45cf874221af Check for nsi file and convert slashes to backslashes on windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 852
diff changeset
322 QFileInfo nsiFile (binDir.path() + "/trustbridge.nsi");
45cf874221af Check for nsi file and convert slashes to backslashes on windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 852
diff changeset
323 if (!nsiFile.exists()) {
45cf874221af Check for nsi file and convert slashes to backslashes on windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 852
diff changeset
324 showErrorMessage(tr("Failed to find installer script at: %1 ").arg(nsiFile.filePath()));
45cf874221af Check for nsi file and convert slashes to backslashes on windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 852
diff changeset
325 }
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
326
518
31e0a86f5a35 Actually set the arguments for makensis process. Fix escaping
Andre Heinecke <aheinecke@intevation.de>
parents: 516
diff changeset
327 qDebug() << "Starting makensis with arguments: " << arguments;
31e0a86f5a35 Actually set the arguments for makensis process. Fix escaping
Andre Heinecke <aheinecke@intevation.de>
parents: 516
diff changeset
328 mNSISProc.setArguments(arguments);
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
329 mNSISProc.start();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
330 mProgress.show();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
331
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
332 if (!mNSISProc.waitForStarted() ||
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
333 mNSISProc.state() == QProcess::NotRunning) {
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
334 showErrorMessage(tr("Failed to start makensis.\n"
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
335 "Please ensure that makensis is installed and in your PATH variable."));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
336 }
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
337 }
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
338
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
339 bool CreateInstallerDialog::signFile(QString filePath) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
340 QProcess signProc;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
341 signProc.setProcessChannelMode(QProcess::MergedChannels);
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
342 signProc.setProgram("osslsigncode");
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
343 QStringList arguments;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
344
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
345 QSettings mySettings;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
346
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
347 QString publisher = mySettings.value("sign_publisher", SIGN_PUBLISHER).toString();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
348 QString url = mySettings.value("sign_url", SIGN_URL).toString();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
349 QString hash = mySettings.value("sign_hash", SIGN_HASH).toString();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
350
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
351 arguments << "sign" << "-certs" << mCertFile->text() << "-key"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
352 << mCertFile->text() << "-n" << publisher << "-i" <<
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
353 url << "-h" << hash << "-in" << filePath << "-out" << filePath + ".signed";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
354
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
355 qDebug() << "Starting osslsigncode with arguments: " << arguments;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
356 signProc.setArguments(arguments);
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
357 signProc.start();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
358
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
359 if (!signProc.waitForFinished(30000)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
360 qDebug() << "Signing takes longer then 30 seconds. Aborting.";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
361 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
362 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
363
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
364 if (signProc.exitStatus() != QProcess::NormalExit ||
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
365 signProc.exitCode() != 0) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
366 qDebug() << "Error process returned: " << signProc.exitCode();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
367 qDebug() << "Output: " << signProc.readAllStandardOutput();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
368 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
369 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
370
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
371 if (!QFile::remove(filePath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
372 qDebug() << "Failed to remove file.";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
373 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
374 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
375 if (!QFile::copy(filePath + ".signed", filePath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
376 qDebug() << "Failed to copy signed file in place.";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
377 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
378 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
379 if (!QFile::remove(filePath + ".signed")) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
380 qDebug() << "Failed to remove signed.";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
381 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
382 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
383 return true;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
384 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
385
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
386
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
387 QTemporaryDir *CreateInstallerDialog::codesignBinaries(const QDir& sourceDir) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
388 QTemporaryDir* target = new QTemporaryDir();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
389 /* Copy all files from the source dir to a temporary location */
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
390 mProgress.setLabelText(tr("Signing binaries..."));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
391
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
392 mProgress.show();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
393 foreach (const QFileInfo& entry, sourceDir.entryInfoList()) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
394 QString targetPath = target->path() + QString::fromLatin1("/") + entry.fileName();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
395 if (entry.fileName() == "." || entry.fileName() == "..") {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
396 continue;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
397 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
398 if (!QFile::copy(entry.absoluteFilePath(), targetPath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
399 qDebug() << "Failed to copy: " << entry.absoluteFilePath() << " to: " << targetPath;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
400 showErrorMessage(tr("Failed to copy binaries to temporary location."));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
401 mProgress.cancel();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
402 return NULL;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
403 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
404 if (entry.suffix() == "exe") {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
405 if (!signFile(targetPath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
406 showErrorMessage(tr("Failed to sign binaries with osslsigncode.\n"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
407 "Please check that %1 is a valid code signing certificate and that"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
408 "osslsigncode can be found in the PATH.").arg(mCertFile->text()));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
409 mProgress.cancel();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
410 return NULL;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
411 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
412 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
413 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
414 mProgress.cancel();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
415 return target;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
416 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
417
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
418 bool CreateInstallerDialog::appendTextSignatureToFile(const QString& input,
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
419 const QString& output) {
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
420 QFile inFile(input);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
421 pk_context pk;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
422
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
423 pk_init(&pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
424 int ret = pk_parse_keyfile(&pk, mCertFile->text().toLocal8Bit().constData(), "");
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
425
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
426 if (ret != 0) {
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
427 showErrorMessage(tr("Failed to load certificate: %1")
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
428 .arg(getPolarSSLErrorMsg(ret)));
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
429 pk_free(&pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
430 return false;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
431 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
432
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
433 /* Check that it is a 3072 bit RSA key as specified */
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
434 if (!pk.pk_info || pk_get_size(&pk) != 3072 ||
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
435 pk.pk_info->type != POLARSSL_PK_RSA) {
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
436 qDebug() << pk.pk_info->type << "type";
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
437 qDebug() << POLARSSL_PK_RSA << "rsa";
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
438 qDebug() << "size " << pk_get_size(&pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
439 showErrorMessage(tr("Only 3072 bit RSA keys are supported by the current format."));
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
440 pk_free(&pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
441 return false;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
442 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
443
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
444 if (!inFile.open(QIODevice::ReadOnly)) {
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
445 showErrorMessage(tr("Failed to open input file: %1").arg(inFile.fileName()));
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
446 pk_free(&pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
447 return false;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
448 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
449
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
450 const QByteArray inputContent = inFile.readAll(); // Memory is cheap :)
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
451 inFile.close();
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
452
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
453 if (inputContent.isEmpty()) {
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
454 showErrorMessage(tr("Failed to read input file: %1").arg(inFile.fileName()));
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
455 pk_free(&pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
456 return false;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
457 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
458
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
459 const QByteArray signature = rsaSignSHA256Hash(sha256sum(inputContent), &pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
460
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
461 pk_free(&pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
462 if (signature.size() != 3072 / 8) {
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
463 qDebug() << "Signature creation returned signature of invalid size.";
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
464 return false;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
465 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
466
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
467 QSaveFile outFile(output);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
468 outFile.open(QIODevice::WriteOnly);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
469 outFile.write(inputContent);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
470 outFile.write("\r\nS:");
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
471 outFile.write(signature.toBase64());
867
ecdc279dea15 Add newline add end of file after the text signature
Andre Heinecke <andre.heinecke@intevation.de>
parents: 864
diff changeset
472 outFile.write("\n");
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
473
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
474 return outFile.commit();
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
475 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
476
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
477 FinishedDialog::FinishedDialog(QDialog *parent,
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
478 QString msg, QString details, bool isErr):
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
479 QDialog(parent)
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
480 {
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
481 QVBoxLayout *topLayout = new QVBoxLayout;
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
482 QHBoxLayout *buttonLayout = new QHBoxLayout;
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
483 QLabel *msgLabel = new QLabel;
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
484 QTextEdit *detailsWindow = new QTextEdit;
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
485
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
486 detailsWindow->insertPlainText(details);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
487 detailsWindow->setReadOnly(true);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
488 detailsWindow->hide();
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
489
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
490 if (!isErr) {
772
aec00847d86d Improve message caption for successful package creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 761
diff changeset
491 setWindowTitle(tr("Successfully created installation package"));
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
492 msgLabel->setPixmap(QApplication::style()->standardIcon(
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
493 QStyle::SP_MessageBoxInformation).pixmap(16, 16));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
494 } else {
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
495 setWindowTitle(tr("Error!"));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
496 msgLabel->setPixmap(QApplication::style()->standardIcon(
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
497 QStyle::SP_MessageBoxCritical).pixmap(16, 16));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
498 }
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
499 msgLabel->setText(msg);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
500
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
501 topLayout->addWidget(msgLabel);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
502 topLayout->addWidget(detailsWindow);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
503 QPushButton *detailsBtn = new QPushButton(tr("Details"));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
504 connect(detailsBtn, SIGNAL(clicked()), detailsWindow, SLOT(show()));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
505 buttonLayout->addWidget(detailsBtn);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
506
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
507 QPushButton *okBtn = new QPushButton(tr("OK"));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
508 okBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogOkButton));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
509 connect(okBtn, SIGNAL(clicked()), this, SLOT(close()));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
510 buttonLayout->insertStretch(0, 100);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
511 buttonLayout->addWidget(okBtn);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
512
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
513 topLayout->addLayout(buttonLayout);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
514 setLayout(topLayout);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
515 }
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
516

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