annotate ui/createinstallerdialog.cpp @ 1402:1adf72328b75 tip

Added tag 1.0 for changeset ee807f64e21e
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 27 Jan 2015 15:18:32 +0100
parents f3e2df6b49ba
children
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"
1390
f3e2df6b49ba (issue181) Fix hardcoded values for RSA codesigning key size.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1377
diff changeset
10 #include "pubkey.h"
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
11
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 #include <QDebug>
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
13 #include <QTextEdit>
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 #include <QDir>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 #include <QPushButton>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 #include <QGroupBox>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 #include <QHBoxLayout>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 #include <QVBoxLayout>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 #include <QLabel>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 #include <QFileDialog>
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
21 #include <QSaveFile>
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
22 #include <QSettings>
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
23 #include <QStyle>
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
24 #include <QApplication>
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
25 #include <QMessageBox>
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
26 #include <QTemporaryDir>
1368
41cf49df007d (issue179) Add signature timestamp in linux installer packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1319
diff changeset
27 #include <QDateTime>
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
28
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
29 #include <polarssl/pk.h>
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
30
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
31 /* Static information used in codesigning */
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
32 #ifndef SIGN_HASH
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
33 #define SIGN_HASH "sha256"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
34 #endif
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
35 #ifndef SIGN_URL
1377
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
36 #define SIGN_URL "https://www.trustbridge.de"
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
37 #endif
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
38 #ifndef SIGN_PUBLISHER
1377
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
39 #define SIGN_PUBLISHER "Bundesamt für Sicherheit in der Informationstechnik"
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
40 #endif
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
41
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 CreateInstallerDialog::CreateInstallerDialog(QMainWindow *parent) :
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
43 QDialog(parent),
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
44 mProgress(this),
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
45 mInstallerPath(),
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
46 mCurrentWorkingDir(NULL)
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
48 QSettings settings;
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
49 setWindowTitle(tr("Create binary installer"));
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
50 setupGUI();
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
51 resize(500, 250);
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
52 mCertFile->setText(settings.value("CodeSignCert", QString()).toString());
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
53 mBinaryFolder->setText(settings.value("LastBinaryFolder", QString()).toString());
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
54 mSaveFile->setText(settings.value("LastBinOutputFolder", QString()).toString());
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
55
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
56 connect(&mNSISProc, SIGNAL(finished(int, QProcess::ExitStatus)),
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
57 this, SLOT(processFinished(int, QProcess::ExitStatus)));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
58 connect(&mNSISProc, SIGNAL(error(QProcess::ProcessError)),
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
59 this, SLOT(processError(QProcess::ProcessError)));
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 }
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 void CreateInstallerDialog::setupGUI()
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 {
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 /* Top level layout / widgets */
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
65 QVBoxLayout *topLayout = new QVBoxLayout;
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
66 QVBoxLayout *headerLayout = new QVBoxLayout;
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
67 QHBoxLayout *headerSubLayout = new QHBoxLayout;
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
68 QHBoxLayout *centerLayout = new QHBoxLayout;
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 QHBoxLayout *bottomLayout = new QHBoxLayout;
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
70 QVBoxLayout *labelLayout = new QVBoxLayout;
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
71 QVBoxLayout *fieldLayout = new QVBoxLayout;
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
72 QVBoxLayout *buttonLayout = new QVBoxLayout;
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
74 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
75 QLabel *description = new QLabel(
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
76 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
77 headerSubLayout->insertSpacing(0, 40);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
78 headerSubLayout->addWidget(description);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
79 QFrame *headerSeparator = new QFrame();
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
80 headerSeparator->setFrameShape(QFrame::HLine);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
81 headerSeparator->setFrameShadow(QFrame::Sunken);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
82 headerLayout->addWidget(header);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
83 headerLayout->addLayout(headerSubLayout);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
84 headerLayout->addWidget(headerSeparator);
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
85 headerLayout->insertSpacing(4, 10);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
87 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
88 QLabel *certLabel = new QLabel(tr("Select code signing certificate:"));
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
89 QLabel *saveLabel = new QLabel(tr("Select output folder:"));
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
90 labelLayout->addWidget(archiveLabel);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
91 labelLayout->addWidget(certLabel);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
92 labelLayout->addWidget(saveLabel);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
93
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
94 mBinaryFolder = new QLineEdit();
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
95 mCertFile = new QLineEdit();
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
96 mSaveFile = new QLineEdit();
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
97 fieldLayout->addWidget(mBinaryFolder);
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
98 fieldLayout->addWidget(mCertFile);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
99 fieldLayout->addWidget(mSaveFile);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
100
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 QPushButton *archiveSelect = new QPushButton("...");
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
102 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
103 archiveSelect->setFixedWidth(30);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 QPushButton *certSelect = new QPushButton("...");
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 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
106 certSelect->setFixedWidth(30);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 QPushButton *saveSelect = new QPushButton("...");
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
108 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
109 saveSelect->setFixedWidth(30);
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
110 buttonLayout->addWidget(archiveSelect);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
111 buttonLayout->addWidget(certSelect);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
112 buttonLayout->addWidget(saveSelect);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
113
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
114 centerLayout->addLayout(labelLayout);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
115 centerLayout->addLayout(fieldLayout);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
116 centerLayout->addLayout(buttonLayout);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
117
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
118 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
119 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
120 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
121 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
122 bottomLayout->insertStretch(0, 10);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
123 bottomLayout->addWidget(create);
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
124 bottomLayout->addWidget(cancel);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
125
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
126 QFrame *bottomSeparator = new QFrame();
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
127 bottomSeparator->setFrameShape(QFrame::HLine);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
128 bottomSeparator->setFrameShadow(QFrame::Sunken);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
129
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
130 topLayout->addLayout(headerLayout);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
131 topLayout->addLayout(centerLayout);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
132 topLayout->insertStretch(2, 10);
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
133 centerLayout->insertSpacing(3, 10);
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
134 topLayout->addWidget(bottomSeparator);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
135 topLayout->addLayout(bottomLayout);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
136
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
137 setLayout(topLayout);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
138
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
139 mProgress.setWindowModality(Qt::WindowModal);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
140 mProgress.setCancelButton(0);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
141 mProgress.setRange(0,0);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
142 mProgress.setMinimumDuration(0);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
143
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
144 return;
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
145 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
146
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
147 void CreateInstallerDialog::openCertificateSelect()
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
148 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
149 QSettings settings;
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
150 QString certFile = QFileDialog::getOpenFileName(
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
151 this, tr("Select certificate"),
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
152 mCertFile->text().isEmpty() ? QDir::homePath() : mCertFile->text(),
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
153 "*.pem *.der *.crt");
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
154 settings.setValue("CodeSignCert", certFile);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
155 mCertFile->setText(certFile);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
156 }
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 void CreateInstallerDialog::openFolderSelect()
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
159 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
160 QSettings settings;
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
161 QString archiveFolder = QFileDialog::getExistingDirectory(
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
162 this, tr("Select binary folder"),
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
163 mBinaryFolder->text().isEmpty() ? QDir::homePath() : mBinaryFolder->text());
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
164 mBinaryFolder->setText(archiveFolder);
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
165 settings.setValue("LastBinaryFolder", archiveFolder);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
166 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
167
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
168 void CreateInstallerDialog::openSaveLocation()
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
169 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
170 QSettings settings;
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
171 QString saveFile = QFileDialog::getExistingDirectory(
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
172 this, tr("Select target location"),
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
173 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
174 mSaveFile->setText(saveFile);
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
175 settings.setValue("LastBinOutputFolder", saveFile);
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
176 }
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 void CreateInstallerDialog::showErrorMessage(const QString &msg)
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
179 {
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
180 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
181 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
182
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
183 void CreateInstallerDialog::processFinished(int exitCode, QProcess::ExitStatus exitStatus)
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
184 {
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
185 if (mCurrentWorkingDir) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
186 delete mCurrentWorkingDir;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
187 mCurrentWorkingDir = NULL;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
188 }
1377
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
189
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);
1377
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
194 mProgress.cancel();
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
195 } else {
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
196 mProgress.setLabelText(tr("Calculating checksums..."));
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
197 QString checksums = QString::fromLatin1("<br/><h3>") + tr("Checksums:") + "</h3>";
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
198 QDir outDir(mSaveFile->text());
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
199 bool checksumErr = false;
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
200 QStringList filters;
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
201 filters << "TrustBridge-*.sh" << "TrustBridge-*.exe";
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
202 qDebug() << "Entries: " << outDir.entryList(filters);
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
203 qDebug() << "Entries unfiltered: " << outDir.entryList();
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
204 foreach (const QString &file, outDir.entryList(filters)) {
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
205 QFile f(outDir.filePath(file));
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
206 if (!f.open(QIODevice::ReadOnly)) {
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
207 showErrorMessage (tr("Failed to open file \"%1\".").arg(file));
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
208 checksumErr = true;
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
209 break;
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
210 }
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
211 const QByteArray fileData = f.readAll();
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
212 if (fileData.isEmpty()) {
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
213 showErrorMessage (tr("Failed to read file \"%1\".").arg(file));
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
214 checksumErr = true;
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
215 break;
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
216 }
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
217 const QByteArray theSha256sum = sha256sum(fileData);
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
218 const QByteArray theSha1sum = sha1sum(fileData);
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
219 if (theSha1sum.isEmpty() || theSha256sum.isEmpty()) {
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
220 showErrorMessage (tr("Failed to calculate checksums for \"%1\".").arg(file));
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
221 checksumErr = true;
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
222 break;
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
223 }
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
224 checksums += QString::fromLatin1("<br/><b>%1:</b><br/><pre>").arg(file);
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
225 checksums += " SHA1: ";
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
226 for (int i=0; i < theSha1sum.size(); i++) {
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
227 checksums += QString("%1").arg(
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
228 (unsigned char)(theSha1sum[i]), 0, 16).rightJustified(2, '0');
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
229 }
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
230
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
231 checksums += "\n SHA256: ";
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
232 for (int i=0; i < theSha256sum.size(); i++) {
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
233 checksums += QString("%1").arg(
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
234 (unsigned char)(theSha256sum[i]), 0, 16).rightJustified(2, '0');
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
235 }
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
236 checksums += "</pre>";
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
237
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
238 }
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
239
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
240 mProgress.cancel();
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
241 if (!checksumErr) {
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
242 FinishedDialog *fin = new FinishedDialog(0, tr("Successfully created the installation packages in \"%1\".")
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
243 .arg(mSaveFile->text()) + checksums, mNSISProc.readAll(), false);
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
244 qDebug() << "Finished: " << mNSISProc.readAll();
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
245 fin->show();
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
246 }
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
247 }
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
248 close();
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
249 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
250
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
251 void CreateInstallerDialog::processError(QProcess::ProcessError error)
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
252 {
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
253 if (mCurrentWorkingDir) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
254 delete mCurrentWorkingDir;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
255 mCurrentWorkingDir = NULL;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
256 }
518
31e0a86f5a35 Actually set the arguments for makensis process. Fix escaping
Andre Heinecke <aheinecke@intevation.de>
parents: 516
diff changeset
257 qDebug() << "Error: " << mNSISProc.readAll();
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
258 mProgress.cancel();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
259 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
260
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
261 void CreateInstallerDialog::createInstaller()
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
262 {
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
263 mProgress.setLabelText(tr("Creating installer package..."));
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
264 QDir binDir(mBinaryFolder->text());
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
265 QDir outDir(mSaveFile->text());
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
266 if (mBinaryFolder->text().isEmpty() || !binDir.exists()) {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
267 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
268 return;
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
269 }
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
270 if (mCertFile->text().isEmpty()) {
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
271 showErrorMessage(tr("Please select a codesigning certificate."));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
272 return;
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
273 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
274 if (mSaveFile->text().isEmpty() || !outDir.exists()) {
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
275 showErrorMessage(tr("Please select a output folder."));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
276 return;
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
277 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
278 QSettings options(binDir.filePath("meta.ini"), QSettings::IniFormat);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
279 options.sync();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
280 QStringList keys = options.allKeys();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
281 if (options.status() != QSettings::NoError || keys.size() < 1) {
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
282 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
283 .arg(binDir.path()));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
284 return;
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
285 }
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
286 /* Sign the linux installer */
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
287 QDir linuxDir(binDir.path() + "/linux");
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
288 if (!linuxDir.exists()) {
781
60d3f59f0803 Fix typos in translatable strings.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 772
diff changeset
289 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
290 .arg(linuxDir.path()));
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
291 return;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
292 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
293 QStringList nameFilter;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
294 nameFilter << "*.sh";
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
295 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
296 if (candidates.isEmpty()) {
781
60d3f59f0803 Fix typos in translatable strings.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 772
diff changeset
297 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
298 .arg(linuxDir.path()));
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
299 return;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
300 }
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
301
885
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
302 foreach (const QString& candidate, candidates) {
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
303 mProgress.setLabelText(tr("Signing Linux package..."));
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
304 mProgress.cancel();
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
305
885
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
306 bool x86arch;
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
307 if (candidate.endsWith("-i386.sh")) {
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
308 x86arch = true;
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
309 } else if (candidate.endsWith("-amd64.sh")) {
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
310 x86arch = false;
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
311 } else {
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
312 qDebug() << "Could not detrmine architecture of " << candidate;
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
313 qDebug() << "Skipping.";
886
197c594aad2b Really skip unknown packages when creating the installer.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 885
diff changeset
314 continue;
885
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
315 }
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
316
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
317 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
318 ).toString().replace(".exe",
890
ad590fb9ab8f Fix another error in package output names.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 889
diff changeset
319 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
320
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
321 if (!appendTextSignatureToFile(linuxDir.path() + "/" + candidate,
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
322 outDir.path() + "/" + outFileName)) {
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
323 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
324 mProgress.close();
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
325 return;
1cc85fd3daa5 (issue70) Handle i386 and amd64 packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 867
diff changeset
326 }
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
327 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
328
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
329 /* The Windows installer */
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
330
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
331 mCurrentWorkingDir = codesignBinaries(binDir.path() + "/windows");
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
332
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
333 if (!mCurrentWorkingDir) {
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
334 /* 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
335 mProgress.close();
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
336 return;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
337 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
338
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
339 mProgress.setLabelText(tr("Creating NSIS package..."));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
340
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
341 /* Copy windows directory contents to tmpdir */
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
342 QStringList arguments;
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
343 mNSISProc.setProgram("makensis");
518
31e0a86f5a35 Actually set the arguments for makensis process. Fix escaping
Andre Heinecke <aheinecke@intevation.de>
parents: 516
diff changeset
344 mNSISProc.setProcessChannelMode(QProcess::MergedChannels);
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
345 mNSISProc.setWorkingDirectory(outDir.path());
537
522b4e28c073 Use windows argument format for nsis on windows
Andre Heinecke <aheinecke@intevation.de>
parents: 526
diff changeset
346 #ifdef Q_OS_WIN
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
347 arguments << QString::fromLatin1("/Dfiles_dir=") + mCurrentWorkingDir->path().replace("/", "\\");
1121
a162f4cbba75 (issue54) Handle plugin dir in create-dist-package and on installer creation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 979
diff changeset
348 QString resourcedir = binDir.path() + "/resources";
a162f4cbba75 (issue54) Handle plugin dir in create-dist-package and on installer creation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 979
diff changeset
349 arguments << QString::fromLatin1("/Dplugin_dir=") + resourcedir.replace("/", "\\");
541
1cddf87f8f83 ix variable path seperator
Andre Heinecke <aheinecke@intevation.de>
parents: 539
diff changeset
350 arguments << "/Dpath_sep=\\";
537
522b4e28c073 Use windows argument format for nsis on windows
Andre Heinecke <aheinecke@intevation.de>
parents: 526
diff changeset
351 foreach (const QString &key, keys) {
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
352 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
353 if (key == "setupname") {
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
354 value = value.arg(outDir.path().replace("/", "\\") + "\\");
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
355 mInstallerPath = value;
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
356 }
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
357 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
358 }
864
45cf874221af Check for nsi file and convert slashes to backslashes on windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 852
diff changeset
359 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
360 #else
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
361 arguments << QString::fromLatin1("-Dfiles_dir=") + mCurrentWorkingDir->path();
1121
a162f4cbba75 (issue54) Handle plugin dir in create-dist-package and on installer creation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 979
diff changeset
362 arguments << QString::fromLatin1("-Dplugin_dir=") + binDir.path() + "/resources";
541
1cddf87f8f83 ix variable path seperator
Andre Heinecke <aheinecke@intevation.de>
parents: 539
diff changeset
363 arguments << "-Dpath_sep=/";
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
364 foreach (const QString &key, keys) {
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
365 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
366 if (key == "setupname") {
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
367 value = value.arg(outDir.path() + "/");
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
368 mInstallerPath = value;
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
369 }
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
370 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
371 }
864
45cf874221af Check for nsi file and convert slashes to backslashes on windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 852
diff changeset
372 arguments << binDir.path() + "/trustbridge.nsi";
537
522b4e28c073 Use windows argument format for nsis on windows
Andre Heinecke <aheinecke@intevation.de>
parents: 526
diff changeset
373 #endif
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
374
864
45cf874221af Check for nsi file and convert slashes to backslashes on windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 852
diff changeset
375
45cf874221af Check for nsi file and convert slashes to backslashes on windows
Andre Heinecke <andre.heinecke@intevation.de>
parents: 852
diff changeset
376 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
377 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
378 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
379 }
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
380
518
31e0a86f5a35 Actually set the arguments for makensis process. Fix escaping
Andre Heinecke <aheinecke@intevation.de>
parents: 516
diff changeset
381 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
382 mNSISProc.setArguments(arguments);
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
383 mNSISProc.start();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
384 mProgress.show();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
385
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
386 if (!mNSISProc.waitForStarted() ||
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
387 mNSISProc.state() == QProcess::NotRunning) {
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
388 showErrorMessage(tr("Failed to start makensis.\n"
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
389 "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
390 }
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
391 }
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
392
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
393 bool CreateInstallerDialog::signFile(QString filePath) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
394 QProcess signProc;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
395 signProc.setProcessChannelMode(QProcess::MergedChannels);
1319
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
396 QStringList candidates;
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
397 candidates << "osslsigncode"
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
398 << QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/osslsigncode");
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
399 QStringList arguments;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
400
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
401 QSettings mySettings;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
402
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
403 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
404 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
405 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
406
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
407 arguments << "sign" << "-certs" << mCertFile->text() << "-key"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
408 << mCertFile->text() << "-n" << publisher << "-i" <<
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
409 url << "-h" << hash << "-in" << filePath << "-out" << filePath + ".signed";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
410
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
411 qDebug() << "Starting osslsigncode with arguments: " << arguments;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
412
1319
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
413 signProc.setArguments(arguments);
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
414 bool once_successful = false;
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
415 foreach (const QString &prog, candidates) {
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
416 signProc.setProgram(prog);
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
417 signProc.start();
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
418
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
419 if (!signProc.waitForFinished(30000)) {
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
420 continue;
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
421 }
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
422
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
423 if (signProc.exitStatus() != QProcess::NormalExit ||
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
424 signProc.exitCode() != 0) {
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
425 qDebug() << "Error process returned: " << signProc.exitCode();
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
426 qDebug() << "Output: " << signProc.readAllStandardOutput();
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
427 continue;
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
428 }
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
429 once_successful = true;
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
430 break;
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
431 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
432
1319
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
433 if (!once_successful) {
137a0686de7b (issue158) Try to find osslsigncode also in the application's directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1268
diff changeset
434 qDebug() << "Failed to execute all osslsigncode candidates.";
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
435 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
436 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
437
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
438 if (!QFile::remove(filePath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
439 qDebug() << "Failed to remove file.";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
440 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
441 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
442 if (!QFile::copy(filePath + ".signed", filePath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
443 qDebug() << "Failed to copy signed file in place.";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
444 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
445 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
446 if (!QFile::remove(filePath + ".signed")) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
447 qDebug() << "Failed to remove signed.";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
448 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
449 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
450 return true;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
451 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
452
979
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
453 bool copyPath(QString src, QString dst)
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
454 {
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
455 QDir dir(src);
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
456 if (! dir.exists()) {
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
457 qDebug() << "Source directory does not exist.";
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
458 return false;
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
459 }
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
460
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
461 foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
462 QString dst_path = dst + QDir::separator() + d;
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
463 dir.mkpath(dst_path);
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
464 if (!copyPath(src+ QDir::separator() + d, dst_path)) {
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
465 qDebug() << "Failed to copy subdirectory; " << d;
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
466 return false;
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
467 }
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
468 }
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
469
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
470 foreach (QString f, dir.entryList(QDir::Files)) {
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
471 if (!QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f)) {
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
472 qDebug() << "Failed to copy: " << f;
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
473 return false;
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
474 }
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
475 }
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
476 return true;
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
477 }
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
478
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
479 QTemporaryDir *CreateInstallerDialog::codesignBinaries(const QDir& sourceDir) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
480 QTemporaryDir* target = new QTemporaryDir();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
481 /* 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
482 mProgress.setLabelText(tr("Signing binaries..."));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
483
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
484 mProgress.show();
979
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
485
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
486 /* Copy the whole directory. */
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
487 if (!copyPath(sourceDir.path(), target->path())) {
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
488 qDebug() << "Copy failed.";
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
489 showErrorMessage(tr("Failed to copy binaries to temporary location."));
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
490 mProgress.cancel();
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
491 return NULL;
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
492 }
01128d63226d Copy the windows files recursively into the temporary directory
Andre Heinecke <andre.heinecke@intevation.de>
parents: 890
diff changeset
493 /* Sign the top level .exe files */
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
494 foreach (const QFileInfo& entry, sourceDir.entryInfoList()) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
495 QString targetPath = target->path() + QString::fromLatin1("/") + entry.fileName();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
496 if (entry.fileName() == "." || entry.fileName() == "..") {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
497 continue;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
498 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
499 if (entry.suffix() == "exe") {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
500 if (!signFile(targetPath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
501 showErrorMessage(tr("Failed to sign binaries with osslsigncode.\n"
1162
2a1206932f53 (issue107) Comment all TODO's and FIXME's with issues as documented in issue107
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1121
diff changeset
502 "Please check that %1 is a valid code signing certificate and that "
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
503 "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
504 mProgress.cancel();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
505 return NULL;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
506 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
507 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
508 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
509 mProgress.cancel();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
510 return target;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
511 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
512
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
513 bool CreateInstallerDialog::appendTextSignatureToFile(const QString& input,
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
514 const QString& output) {
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
515 QFile inFile(input);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
516 pk_context pk;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
517
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
518 pk_init(&pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
519 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
520
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
521 if (ret != 0) {
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
522 showErrorMessage(tr("Failed to load certificate: %1")
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
523 .arg(getPolarSSLErrorMsg(ret)));
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
524 pk_free(&pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
525 return false;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
526 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
527
1390
f3e2df6b49ba (issue181) Fix hardcoded values for RSA codesigning key size.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1377
diff changeset
528 /* Check that it is an RSA key that matches the size */
f3e2df6b49ba (issue181) Fix hardcoded values for RSA codesigning key size.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1377
diff changeset
529 if (!pk.pk_info || pk_get_size(&pk) != TRUSTBRIDGE_RSA_CODESIGN_SIZE ||
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
530 pk.pk_info->type != POLARSSL_PK_RSA) {
1268
2efdf2faf4e5 Remove dead variable and fix possible null pointer dereference
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1162
diff changeset
531 if (pk.pk_info) {
2efdf2faf4e5 Remove dead variable and fix possible null pointer dereference
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1162
diff changeset
532 qDebug() << pk.pk_info->type << "type";
2efdf2faf4e5 Remove dead variable and fix possible null pointer dereference
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1162
diff changeset
533 }
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
534 qDebug() << POLARSSL_PK_RSA << "rsa";
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
535 qDebug() << "size " << pk_get_size(&pk);
1390
f3e2df6b49ba (issue181) Fix hardcoded values for RSA codesigning key size.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1377
diff changeset
536 showErrorMessage(tr("Only %1 bit RSA keys are supported by the current format.").arg(
f3e2df6b49ba (issue181) Fix hardcoded values for RSA codesigning key size.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1377
diff changeset
537 TRUSTBRIDGE_RSA_CODESIGN_SIZE));
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
538 pk_free(&pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
539 return false;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
540 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
541
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
542 if (!inFile.open(QIODevice::ReadOnly)) {
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
543 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
544 pk_free(&pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
545 return false;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
546 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
547
1368
41cf49df007d (issue179) Add signature timestamp in linux installer packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1319
diff changeset
548 QByteArray inputContent = inFile.readAll(); // Memory is cheap :)
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
549 inFile.close();
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
550
1368
41cf49df007d (issue179) Add signature timestamp in linux installer packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1319
diff changeset
551
41cf49df007d (issue179) Add signature timestamp in linux installer packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1319
diff changeset
552 /* Append the current date time to the signed data so that it is also signed.
41cf49df007d (issue179) Add signature timestamp in linux installer packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1319
diff changeset
553 * Until 2106 qt will probably return an 64 bit int on toTime_t. If not
41cf49df007d (issue179) Add signature timestamp in linux installer packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1319
diff changeset
554 * I'm sorry. */
41cf49df007d (issue179) Add signature timestamp in linux installer packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1319
diff changeset
555 QString sign_dt = QString("%1").arg(QDateTime::currentDateTime().toTime_t());
41cf49df007d (issue179) Add signature timestamp in linux installer packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1319
diff changeset
556 inputContent.replace("###SIGNATURE_DATE###", sign_dt.toLocal8Bit().constData());
41cf49df007d (issue179) Add signature timestamp in linux installer packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1319
diff changeset
557 inputContent.append("\r\nS_DT:" + sign_dt);
41cf49df007d (issue179) Add signature timestamp in linux installer packages
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1319
diff changeset
558
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
559 if (inputContent.isEmpty()) {
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
560 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
561 pk_free(&pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
562 return false;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
563 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
564
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
565 const QByteArray signature = rsaSignSHA256Hash(sha256sum(inputContent), &pk);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
566
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
567 pk_free(&pk);
1390
f3e2df6b49ba (issue181) Fix hardcoded values for RSA codesigning key size.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1377
diff changeset
568 if (signature.size() != TRUSTBRIDGE_RSA_CODESIGN_SIZE / 8) {
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
569 qDebug() << "Signature creation returned signature of invalid size.";
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
570 return false;
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
571 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
572
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
573 QSaveFile outFile(output);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
574 outFile.open(QIODevice::WriteOnly);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
575 outFile.write(inputContent);
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
576 outFile.write("\r\nS:");
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
577 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
578 outFile.write("\n");
761
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
579
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
580 return outFile.commit();
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
581 }
49168bcb02e2 (Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 571
diff changeset
582
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
583 FinishedDialog::FinishedDialog(QDialog *parent,
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
584 QString msg, QString details, bool isErr):
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
585 QDialog(parent)
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
586 {
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
587 QVBoxLayout *topLayout = new QVBoxLayout;
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
588 QHBoxLayout *buttonLayout = new QHBoxLayout;
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
589 QLabel *msgLabel = new QLabel;
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
590 QTextEdit *detailsWindow = new QTextEdit;
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
591
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
592 detailsWindow->insertPlainText(details);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
593 detailsWindow->setReadOnly(true);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
594 detailsWindow->hide();
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
595
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
596 if (!isErr) {
772
aec00847d86d Improve message caption for successful package creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 761
diff changeset
597 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
598 msgLabel->setPixmap(QApplication::style()->standardIcon(
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
599 QStyle::SP_MessageBoxInformation).pixmap(16, 16));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
600 } else {
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
601 setWindowTitle(tr("Error!"));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
602 msgLabel->setPixmap(QApplication::style()->standardIcon(
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
603 QStyle::SP_MessageBoxCritical).pixmap(16, 16));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
604 }
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
605 msgLabel->setText(msg);
1377
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
606 msgLabel->setTextInteractionFlags(
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
607 Qt::TextSelectableByMouse |
c8a6a3e6bdeb (issue178) Show checksums after installer creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1368
diff changeset
608 Qt::TextSelectableByKeyboard);
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
609
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
610 topLayout->addWidget(msgLabel);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
611 topLayout->addWidget(detailsWindow);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
612 QPushButton *detailsBtn = new QPushButton(tr("Details"));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
613 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
614 buttonLayout->addWidget(detailsBtn);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
615
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
616 QPushButton *okBtn = new QPushButton(tr("OK"));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
617 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
618 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
619 buttonLayout->insertStretch(0, 100);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
620 buttonLayout->addWidget(okBtn);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
621
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
622 topLayout->addLayout(buttonLayout);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
623 setLayout(topLayout);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
624 }
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
625

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