This repository has been archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathextract-qt-installer
executable file
·340 lines (268 loc) · 8.8 KB
/
extract-qt-installer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
#!/bin/bash
# QT-CI Project
# License: Apache-2.0
# https://github.com/benlau/qtci
function usage() {
echo "Usage:"
echo "extract-qt-installer qt-installer output_path"
echo "extract-qt-installer --list-packages qt-installer"
exit -1
}
LIST_PACKAGES=0
getopt --test > /dev/null 2>&1
GETOPT_RET_CODE=$?
set -e #quit on error
if [ "$GETOPT_RET_CODE" != "4" ]
then
echo "Warning: gnu-getopt is not installed. Long parameter like '--list-package' will not be working. Please install gnu-getopt by 'brew install gnu-getopt'"
else
OPTS=`getopt -o l --long list-packages --long disable-progress-report -n "extract-qt-installer" -- "$@"`
eval set -- "$OPTS"
while true
do
case "$1" in
--list-packages)
LIST_PACKAGES=1
shift;;
--disable-progress-report)
DISABLE_PROGRESS_REPORT=1
shift;;
--) shift;break;;
*) shift;;
esac
done
fi
export PATH=$PATH:$PWD
export WORKDIR=$PWD
INSTALLER=$1
OUTPUT=$2
SCRIPT="$(mktemp /tmp/tmp.XXXXXXXXX)"
PACKAGES=$QT_CI_PACKAGES
if [ $LIST_PACKAGES -gt 0 ]
then
if [ $# -lt 1 ]
then
usage
fi
OUTPUT="/tmp/Qt"
else
if [ $# -lt 2 ]
then
usage
fi
if [[ ! "${OUTPUT:0:1}" = "/" ]]
then
echo output path must be an absolute path
exit -1
fi
fi
cat <<EOF > $SCRIPT
function abortInstaller()
{
installer.setDefaultPageVisible(QInstaller.Introduction, false);
installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
installer.setDefaultPageVisible(QInstaller.ReadyForInstallation, false);
installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false);
installer.setDefaultPageVisible(QInstaller.PerformInstallation, false);
installer.setDefaultPageVisible(QInstaller.LicenseCheck, false);
var abortText = "<font color='red' size=3>" + qsTr("Installation failed:") + "</font>";
var error_list = installer.value("component_errors").split(";;;");
abortText += "<ul>";
// ignore the first empty one
for (var i = 0; i < error_list.length; ++i) {
if (error_list[i] !== "") {
log(error_list[i]);
abortText += "<li>" + error_list[i] + "</li>"
}
}
abortText += "</ul>";
installer.setValue("FinishedText", abortText);
}
function log() {
var msg = ["QTCI: "].concat([].slice.call(arguments));
console.log(msg.join(" "));
}
function printObject(object) {
var lines = [];
for (var i in object) {
lines.push([i, object[i]].join(" "));
}
log(lines.join(","));
}
var status = {
widget: null,
finishedPageVisible: false,
installationFinished: false
}
function tryFinish() {
if (status.finishedPageVisible && status.installationFinished) {
if (status.widget.LaunchQtCreatorCheckBoxForm) {
// Disable this checkbox for minimal platform
status.widget.LaunchQtCreatorCheckBoxForm.launchQtCreatorCheckBox.setChecked(false);
}
if (status.widget.RunItCheckBox) {
// LaunchQtCreatorCheckBoxForm may not work for newer versions.
status.widget.RunItCheckBox.setChecked(false);
}
log("Press Finish Button");
gui.clickButton(buttons.FinishButton);
}
}
function Controller() {
installer.installationFinished.connect(function() {
status.installationFinished = true;
gui.clickButton(buttons.NextButton);
tryFinish();
});
installer.setMessageBoxAutomaticAnswer("OverwriteTargetDirectory", QMessageBox.Yes);
installer.setMessageBoxAutomaticAnswer("installationErrorWithRetry", QMessageBox.Ignore);
installer.setMessageBoxAutomaticAnswer("XcodeError", QMessageBox.Ok);
// Allow to cancel installation for arguments --list-packages
installer.setMessageBoxAutomaticAnswer("cancelInstallation", QMessageBox.Yes);
}
Controller.prototype.WelcomePageCallback = function() {
log("Welcome Page");
gui.clickButton(buttons.NextButton);
var widget = gui.currentPageWidget();
/*
Online installer 3.0.6
- It must disconnect the completeChanged callback after used, otherwise it will click the 'next' button on another pages
*/
var callback = function() {
gui.clickButton(buttons.NextButton);
widget.completeChanged.disconnect(callback);
}
widget.completeChanged.connect(callback);
}
Controller.prototype.CredentialsPageCallback = function() {
var login = installer.environmentVariable("QT_CI_LOGIN");
var password = installer.environmentVariable("QT_CI_PASSWORD");
if (login === "" || password === "") {
gui.clickButton(buttons.CommitButton);
}
var widget = gui.currentPageWidget();
widget.loginWidget.EmailLineEdit.setText(login);
widget.loginWidget.PasswordLineEdit.setText(password);
gui.clickButton(buttons.CommitButton);
}
Controller.prototype.ComponentSelectionPageCallback = function() {
log("ComponentSelectionPageCallback");
function list_packages() {
var components = installer.components();
log("Available components: " + components.length);
var packages = ["Packages: "];
for (var i = 0 ; i < components.length ;i++) {
packages.push(components[i].name);
}
log(packages.join(" "));
}
if ($LIST_PACKAGES) {
list_packages();
gui.clickButton(buttons.CancelButton);
return;
}
log("Select components");
function trim(str) {
return str.replace(/^ +/,"").replace(/ *$/,"");
}
var widget = gui.currentPageWidget();
var packages = trim("$PACKAGES").split(",");
if (packages.length > 0 && packages[0] !== "") {
widget.deselectAll();
var components = installer.components();
var allfound = true;
for (var i in packages) {
var pkg = trim(packages[i]);
var found = false;
for (var j in components) {
if (components[j].name === pkg) {
found = true;
break;
}
}
if (!found) {
allfound = false;
log("ERROR: Package " + pkg + " not found.");
} else {
log("Select " + pkg);
widget.selectComponent(pkg);
}
}
if (!allfound) {
list_packages();
// TODO: figure out how to set non-zero exit status.
gui.clickButton(buttons.CancelButton);
return;
}
} else {
log("Use default component list");
}
gui.clickButton(buttons.NextButton);
}
Controller.prototype.IntroductionPageCallback = function() {
log("Introduction Page");
log("Retrieving meta information from remote repository");
/*
Online installer 3.0.6
- Don't click buttons.NextButton directly. It will skip the componenet selection.
*/
if (installer.isOfflineOnly()) {
gui.clickButton(buttons.NextButton);
}
}
Controller.prototype.TargetDirectoryPageCallback = function() {
log("Set target installation page: $OUTPUT");
var widget = gui.currentPageWidget();
if (widget != null) {
widget.TargetDirectoryLineEdit.setText("$OUTPUT");
}
gui.clickButton(buttons.NextButton);
}
Controller.prototype.LicenseAgreementPageCallback = function() {
log("Accept license agreement");
var widget = gui.currentPageWidget();
if (widget != null) {
widget.AcceptLicenseRadioButton.setChecked(true);
}
gui.clickButton(buttons.NextButton);
}
Controller.prototype.ReadyForInstallationPageCallback = function() {
log("Ready to install");
// Bug? If commit button pressed too quickly finished callback might not show the checkbox to disable running qt creator
// Behaviour started around 5.10. You don't actually have to press this button at all with those versions, even though gui.isButtonEnabled() returns true.
gui.clickButton(buttons.CommitButton, 200);
}
Controller.prototype.PerformInstallationPageCallback = function() {
log("PerformInstallationPageCallback");
gui.clickButton(buttons.CommitButton);
}
Controller.prototype.FinishedPageCallback = function() {
log("FinishedPageCallback");
var widget = gui.currentPageWidget();
// Bug? Qt 5.9.5 and Qt 5.9.6 installer show finished page before the installation completed
// Don't press "finishButton" immediately
status.finishedPageVisible = true;
status.widget = widget;
tryFinish();
}
EOF
chmod u+x $1
if [ -n "$QT_CI_DEBUG" ]
then
$INSTALLER -v --script $SCRIPT | grep "\(QTCI\|operation\)"
exit 0
fi
unset DISPLAY
if [ -n "$DISABLE_PROGRESS_REPORT" ]
then
QT_QPA_PLATFORM=minimal $INSTALLER --script $SCRIPT
else
ARGS="-v"
if [ -n "$VERBOSE" ]
then
QT_QPA_PLATFORM=minimal $INSTALLER $ARGS --script $SCRIPT
else
QT_QPA_PLATFORM=minimal $INSTALLER $ARGS --script $SCRIPT | grep "\(QTCI\|operation\)"
fi
fi