annotate ui/createinstallerdialog.cpp @ 648:e41a2537b84d

Implement root installation We now iterate over all users that do not obviously have their login shell disabled and look for NSS directories in their home directory, dropping our privileges to do so.
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 25 Jun 2014 12:44:47 +0200
parents 6c4fff146999
children 49168bcb02e2
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"
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 #include <QDebug>
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
10 #include <QTextEdit>
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 #include <QDir>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 #include <QPushButton>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 #include <QGroupBox>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 #include <QHBoxLayout>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 #include <QVBoxLayout>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 #include <QLabel>
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 #include <QFileDialog>
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
18 #include <QSettings>
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
19 #include <QStyle>
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
20 #include <QApplication>
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
21 #include <QMessageBox>
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
22 #include <QTemporaryDir>
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
23
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
24 /* Static information used in codesigning */
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
25 #ifndef SIGN_HASH
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
26 #define SIGN_HASH "sha256"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
27 #endif
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
28 #ifndef SIGN_URL
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
29 #define SIGN_URL "https://wald.intevation.org/projects/trustbridge/"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
30 #endif
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
31 #ifndef SIGN_PUBLISHER
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
32 #define SIGN_PUBLISHER "TrustBridge Test with ümlaut"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
33 #endif
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
34
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36 CreateInstallerDialog::CreateInstallerDialog(QMainWindow *parent) :
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
37 QDialog(parent),
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
38 mProgress(this),
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
39 mInstallerPath(),
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
40 mCurrentWorkingDir(NULL)
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
42 QSettings settings;
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
43 setWindowTitle(tr("Create binary installer"));
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 setupGUI();
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
45 resize(500, 250);
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
46 mCertFile->setText(settings.value("CodeSignCert", QString()).toString());
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
47 mBinaryFolder->setText(settings.value("LastBinaryFolder", QString()).toString());
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
48 mSaveFile->setText(settings.value("LastBinOutputFolder", QString()).toString());
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
49
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
50 connect(&mNSISProc, SIGNAL(finished(int, QProcess::ExitStatus)),
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
51 this, SLOT(processFinished(int, QProcess::ExitStatus)));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
52 connect(&mNSISProc, SIGNAL(error(QProcess::ProcessError)),
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
53 this, SLOT(processError(QProcess::ProcessError)));
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
56 void CreateInstallerDialog::setupGUI()
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57 {
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58 /* Top level layout / widgets */
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59 QVBoxLayout *topLayout = new QVBoxLayout;
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
60 QVBoxLayout *headerLayout = new QVBoxLayout;
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
61 QHBoxLayout *headerSubLayout = new QHBoxLayout;
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
62 QHBoxLayout *centerLayout = new QHBoxLayout;
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 QHBoxLayout *bottomLayout = new QHBoxLayout;
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
64 QVBoxLayout *labelLayout = new QVBoxLayout;
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
65 QVBoxLayout *fieldLayout = new QVBoxLayout;
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
66 QVBoxLayout *buttonLayout = new QVBoxLayout;
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
68 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
69 QLabel *description = new QLabel(
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
70 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
71 headerSubLayout->insertSpacing(0, 40);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
72 headerSubLayout->addWidget(description);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
73 QFrame *headerSeparator = new QFrame();
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
74 headerSeparator->setFrameShape(QFrame::HLine);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
75 headerSeparator->setFrameShadow(QFrame::Sunken);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
76 headerLayout->addWidget(header);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
77 headerLayout->addLayout(headerSubLayout);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
78 headerLayout->addWidget(headerSeparator);
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
79 headerLayout->insertSpacing(4, 10);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
80
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
81 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
82 QLabel *certLabel = new QLabel(tr("Select code signing certificate:"));
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
83 QLabel *saveLabel = new QLabel(tr("Select output folder:"));
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
84 labelLayout->addWidget(archiveLabel);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
85 labelLayout->addWidget(certLabel);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
86 labelLayout->addWidget(saveLabel);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
87
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
88 mBinaryFolder = new QLineEdit();
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
89 mCertFile = new QLineEdit();
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
90 mSaveFile = new QLineEdit();
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
91 fieldLayout->addWidget(mBinaryFolder);
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
92 fieldLayout->addWidget(mCertFile);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
93 fieldLayout->addWidget(mSaveFile);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
94
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95 QPushButton *archiveSelect = new QPushButton("...");
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
96 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
97 archiveSelect->setFixedWidth(30);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98 QPushButton *certSelect = new QPushButton("...");
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99 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
100 certSelect->setFixedWidth(30);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 QPushButton *saveSelect = new QPushButton("...");
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 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
103 saveSelect->setFixedWidth(30);
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
104 buttonLayout->addWidget(archiveSelect);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
105 buttonLayout->addWidget(certSelect);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
106 buttonLayout->addWidget(saveSelect);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
108 centerLayout->addLayout(labelLayout);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
109 centerLayout->addLayout(fieldLayout);
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
110 centerLayout->addLayout(buttonLayout);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
111
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
112 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
113 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
114 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
115 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
116 bottomLayout->insertStretch(0, 10);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
117 bottomLayout->addWidget(create);
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
118 bottomLayout->addWidget(cancel);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
119
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
120 QFrame *bottomSeparator = new QFrame();
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
121 bottomSeparator->setFrameShape(QFrame::HLine);
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
122 bottomSeparator->setFrameShadow(QFrame::Sunken);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
123
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
124 topLayout->addLayout(headerLayout);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
125 topLayout->addLayout(centerLayout);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
126 topLayout->insertStretch(2, 10);
428
d1819cd56dee Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
127 centerLayout->insertSpacing(3, 10);
414
3d803d383b41 Wording and layout in TrustBridge administration create binary dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
128 topLayout->addWidget(bottomSeparator);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
129 topLayout->addLayout(bottomLayout);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
130
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
131 setLayout(topLayout);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
132
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
133 mProgress.setWindowModality(Qt::WindowModal);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
134 mProgress.setCancelButton(0);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
135 mProgress.setRange(0,0);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
136 mProgress.setMinimumDuration(0);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
137
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
138 return;
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
139 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
140
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
141 void CreateInstallerDialog::openCertificateSelect()
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
142 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
143 QSettings settings;
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
144 QString certFile = QFileDialog::getOpenFileName(
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
145 this, tr("Select certificate"),
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
146 mCertFile->text().isEmpty() ? QDir::homePath() : mCertFile->text(),
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
147 "*.pem *.der *.crt");
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
148 settings.setValue("CodeSignCert", certFile);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
149 mCertFile->setText(certFile);
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
150 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
151
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
152 void CreateInstallerDialog::openFolderSelect()
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
153 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
154 QSettings settings;
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
155 QString archiveFolder = QFileDialog::getExistingDirectory(
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
156 this, tr("Select binary folder"),
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
157 mBinaryFolder->text().isEmpty() ? QDir::homePath() : mBinaryFolder->text());
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
158 mBinaryFolder->setText(archiveFolder);
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
159 settings.setValue("LastBinaryFolder", archiveFolder);
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
160 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
161
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
162 void CreateInstallerDialog::openSaveLocation()
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
163 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
164 QSettings settings;
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
165 QString saveFile = QFileDialog::getExistingDirectory(
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
166 this, tr("Select target location"),
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
167 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
168 mSaveFile->setText(saveFile);
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
169 settings.setValue("LastBinOutputFolder", saveFile);
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
170 }
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
171
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
172 void CreateInstallerDialog::showErrorMessage(const QString &msg)
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
173 {
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
174 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
175 }
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
176
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
177 void CreateInstallerDialog::processFinished(int exitCode, QProcess::ExitStatus exitStatus)
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
178 {
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
179 if (mCurrentWorkingDir) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
180 delete mCurrentWorkingDir;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
181 mCurrentWorkingDir = NULL;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
182 }
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
183 FinishedDialog *fin = new FinishedDialog(0, tr("Created installer in %1.")
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
184 .arg(mSaveFile->text()), mNSISProc.readAll(), false);
518
31e0a86f5a35 Actually set the arguments for makensis process. Fix escaping
Andre Heinecke <aheinecke@intevation.de>
parents: 516
diff changeset
185 qDebug() << "Finished: " << mNSISProc.readAll();
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
186 mProgress.setLabelText(tr("Signing installer package..."));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
187 if (!signFile(mInstallerPath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
188 showErrorMessage(tr("Failed to sign installer package."));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
189 QFile::remove(mInstallerPath);
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
190 }
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
191 mProgress.cancel();
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
192 fin->show();
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
193 close();
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
194 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
195
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
196 void CreateInstallerDialog::processError(QProcess::ProcessError error)
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
197 {
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
198 if (mCurrentWorkingDir) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
199 delete mCurrentWorkingDir;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
200 mCurrentWorkingDir = NULL;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
201 }
518
31e0a86f5a35 Actually set the arguments for makensis process. Fix escaping
Andre Heinecke <aheinecke@intevation.de>
parents: 516
diff changeset
202 qDebug() << "Error: " << mNSISProc.readAll();
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
203 mProgress.cancel();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
204 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
205
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
206 void CreateInstallerDialog::createInstaller()
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
207 {
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
208 mProgress.setLabelText(tr("Creating installer package..."));
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
209 QDir binDir(mBinaryFolder->text());
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
210 QDir outDir(mSaveFile->text());
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
211 if (mBinaryFolder->text().isEmpty() || !binDir.exists()) {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
212 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
213 return;
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 428
diff changeset
214 }
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
215 if (mCertFile->text().isEmpty()) {
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
216 showErrorMessage(tr("Please select a codesigning certificate."));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
217 return;
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
218 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
219 if (mSaveFile->text().isEmpty() || !outDir.exists()) {
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
220 showErrorMessage(tr("Please select a output folder."));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
221 return;
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
222 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
223 QSettings options(binDir.filePath("meta.ini"), QSettings::IniFormat);
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
224 options.sync();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
225 QStringList keys = options.allKeys();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
226 if (options.status() != QSettings::NoError || keys.size() < 1) {
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
227 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
228 .arg(binDir.path()));
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
229 return;
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
230 }
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
231
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
232 QTemporaryDir *signedFilesDir = codesignBinaries(binDir.path() + "/windows");
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
233
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
234 if (!signedFilesDir) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
235 /* Error messages should have been shown by the codesign function */
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
236 return;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
237 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
238
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
239 mProgress.setLabelText(tr("Creating NSIS package..."));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
240
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
241 /* Copy windows directory contents to tmpdir */
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
242 QStringList arguments;
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
243 mNSISProc.setProgram("makensis");
518
31e0a86f5a35 Actually set the arguments for makensis process. Fix escaping
Andre Heinecke <aheinecke@intevation.de>
parents: 516
diff changeset
244 mNSISProc.setProcessChannelMode(QProcess::MergedChannels);
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
245 mNSISProc.setWorkingDirectory(outDir.path());
537
522b4e28c073 Use windows argument format for nsis on windows
Andre Heinecke <aheinecke@intevation.de>
parents: 526
diff changeset
246 #ifdef Q_OS_WIN
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
247 arguments << QString::fromLatin1("/Dfiles_dir=") + signedFilesDir->path().replace("/", "\\");
541
1cddf87f8f83 ix variable path seperator
Andre Heinecke <aheinecke@intevation.de>
parents: 539
diff changeset
248 arguments << "/Dpath_sep=\\";
537
522b4e28c073 Use windows argument format for nsis on windows
Andre Heinecke <aheinecke@intevation.de>
parents: 526
diff changeset
249 foreach (const QString &key, keys) {
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
250 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
251 if (key == "setupname") {
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
252 value = value.arg(outDir.path().replace("/", "\\") + "\\");
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
253 mInstallerPath = value;
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
254 }
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
255 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
256 }
522b4e28c073 Use windows argument format for nsis on windows
Andre Heinecke <aheinecke@intevation.de>
parents: 526
diff changeset
257 #else
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
258 arguments << QString::fromLatin1("-Dfiles_dir=") + signedFilesDir->path();
541
1cddf87f8f83 ix variable path seperator
Andre Heinecke <aheinecke@intevation.de>
parents: 539
diff changeset
259 arguments << "-Dpath_sep=/";
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
260 foreach (const QString &key, keys) {
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
261 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
262 if (key == "setupname") {
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
263 value = value.arg(outDir.path() + "/");
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
264 mInstallerPath = value;
542
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
265 }
421b69eeffe3 Actually write the installer to the output folder
Andre Heinecke <aheinecke@intevation.de>
parents: 541
diff changeset
266 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
267 }
537
522b4e28c073 Use windows argument format for nsis on windows
Andre Heinecke <aheinecke@intevation.de>
parents: 526
diff changeset
268 #endif
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
269
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
270 arguments << binDir.path() + "/trustbridge.nsi";
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
271
518
31e0a86f5a35 Actually set the arguments for makensis process. Fix escaping
Andre Heinecke <aheinecke@intevation.de>
parents: 516
diff changeset
272 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
273 mNSISProc.setArguments(arguments);
516
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
274 mNSISProc.start();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
275 mProgress.show();
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
276
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
277 if (!mNSISProc.waitForStarted() ||
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
278 mNSISProc.state() == QProcess::NotRunning) {
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
279 showErrorMessage(tr("Failed to start makensis.\n"
3332db04c77d Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents: 515
diff changeset
280 "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
281 }
361
b67dd46cd4a9 Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
282 }
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
283
571
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
284 bool CreateInstallerDialog::signFile(QString filePath) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
285 QProcess signProc;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
286 signProc.setProcessChannelMode(QProcess::MergedChannels);
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
287 signProc.setProgram("osslsigncode");
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
288 QStringList arguments;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
289
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
290 QSettings mySettings;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
291
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
292 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
293 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
294 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
295
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
296 arguments << "sign" << "-certs" << mCertFile->text() << "-key"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
297 << mCertFile->text() << "-n" << publisher << "-i" <<
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
298 url << "-h" << hash << "-in" << filePath << "-out" << filePath + ".signed";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
299
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
300 qDebug() << "Starting osslsigncode with arguments: " << arguments;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
301 signProc.setArguments(arguments);
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
302 signProc.start();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
303
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
304 if (!signProc.waitForFinished(30000)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
305 qDebug() << "Signing takes longer then 30 seconds. Aborting.";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
306 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
307 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
308
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
309 if (signProc.exitStatus() != QProcess::NormalExit ||
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
310 signProc.exitCode() != 0) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
311 qDebug() << "Error process returned: " << signProc.exitCode();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
312 qDebug() << "Output: " << signProc.readAllStandardOutput();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
313 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
314 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
315
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
316 if (!QFile::remove(filePath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
317 qDebug() << "Failed to remove file.";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
318 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
319 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
320 if (!QFile::copy(filePath + ".signed", filePath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
321 qDebug() << "Failed to copy signed file in place.";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
322 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
323 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
324 if (!QFile::remove(filePath + ".signed")) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
325 qDebug() << "Failed to remove signed.";
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
326 return false;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
327 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
328 return true;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
329 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
330
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
331
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
332 QTemporaryDir *CreateInstallerDialog::codesignBinaries(const QDir& sourceDir) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
333 QTemporaryDir* target = new QTemporaryDir();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
334 /* 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
335 mProgress.setLabelText(tr("Signing binaries..."));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
336
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
337 mProgress.show();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
338 foreach (const QFileInfo& entry, sourceDir.entryInfoList()) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
339 QString targetPath = target->path() + QString::fromLatin1("/") + entry.fileName();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
340 if (entry.fileName() == "." || entry.fileName() == "..") {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
341 continue;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
342 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
343 if (!QFile::copy(entry.absoluteFilePath(), targetPath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
344 qDebug() << "Failed to copy: " << entry.absoluteFilePath() << " to: " << targetPath;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
345 showErrorMessage(tr("Failed to copy binaries to temporary location."));
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
346 mProgress.cancel();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
347 return NULL;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
348 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
349 if (entry.suffix() == "exe") {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
350 if (!signFile(targetPath)) {
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
351 showErrorMessage(tr("Failed to sign binaries with osslsigncode.\n"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
352 "Please check that %1 is a valid code signing certificate and that"
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
353 "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
354 mProgress.cancel();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
355 return NULL;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
356 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
357 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
358 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
359 mProgress.cancel();
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
360 return target;
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
361 }
6c4fff146999 Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents: 542
diff changeset
362
526
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
363 FinishedDialog::FinishedDialog(QDialog *parent,
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
364 QString msg, QString details, bool isErr):
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
365 QDialog(parent)
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
366 {
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
367 QVBoxLayout *topLayout = new QVBoxLayout;
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
368 QHBoxLayout *buttonLayout = new QHBoxLayout;
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
369 QLabel *msgLabel = new QLabel;
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
370 QTextEdit *detailsWindow = new QTextEdit;
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
371
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
372 detailsWindow->insertPlainText(details);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
373 detailsWindow->setReadOnly(true);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
374 detailsWindow->hide();
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
375
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
376 if (!isErr) {
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
377 setWindowTitle(tr("Success!"));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
378 msgLabel->setPixmap(QApplication::style()->standardIcon(
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
379 QStyle::SP_MessageBoxInformation).pixmap(16, 16));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
380 } else {
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
381 setWindowTitle(tr("Error!"));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
382 msgLabel->setPixmap(QApplication::style()->standardIcon(
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
383 QStyle::SP_MessageBoxCritical).pixmap(16, 16));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
384 }
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
385 msgLabel->setText(msg);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
386
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
387 topLayout->addWidget(msgLabel);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
388 topLayout->addWidget(detailsWindow);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
389 QPushButton *detailsBtn = new QPushButton(tr("Details"));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
390 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
391 buttonLayout->addWidget(detailsBtn);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
392
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
393 QPushButton *okBtn = new QPushButton(tr("OK"));
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
394 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
395 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
396 buttonLayout->insertStretch(0, 100);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
397 buttonLayout->addWidget(okBtn);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
398
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
399 topLayout->addLayout(buttonLayout);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
400 setLayout(topLayout);
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
401 }
f6371e9c959a Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents: 518
diff changeset
402

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