2 Silent installer script
4 Known to work with Qt 5.9.0 and QtIFW 2.0.5
7 $ ./qt-opensource-windows-x86-mingw530-5.9.0.exe --verbose --script ../librepilot/make/tool_install/qt-install.qs
10 - silent but not headless (QtIFW 2.1.0 should support gui.setSilent(true))
11 - cannot disable forced components (QtCreator, ...)
12 - cannot disable virtual components (doc, examples, ...)
13 - cannot disable shortcuts creation
14 - if user presses the 'Show Details' button then the installer does not end automatically
18 console.log("*** Silent Installer ***");
19 console.log("Installing on " + installer.value("os"));
21 var qtInstallTargetDir = installer.environmentVariable("QT_INSTALL_TARGET_DIR");
22 if (qtInstallTargetDir == "") {
23 qtInstallTargetDir = installer.environmentVariable("PWD") + "/tools/qt-5.9.0";
24 console.log("Environment variable QT_INSTALL_TARGET_DIR not set, using default " + qtInstallTargetDir);
26 installer.setValue("TargetDir", qtInstallTargetDir);
27 console.log("Installing to " + installer.value("TargetDir"));
29 installer.autoRejectMessageBoxes();
30 installer.setMessageBoxAutomaticAnswer("OverwriteTargetDirectory", QMessageBox.Yes);
31 installer.setMessageBoxAutomaticAnswer("stopProcessesForUpdates", QMessageBox.Ignore);
33 // pages that are not visible are actually removed from the wizard
34 // some pages must not be removed otherwise the installer starts to mishbehave
35 installer.setDefaultPageVisible(QInstaller.Welcome, false);
36 installer.setDefaultPageVisible(QInstaller.Credentials, false); // QInstaller.Credentials is 0... so this is a NOP!
37 //installer.setDefaultPageVisible(QInstaller.Introduction, false); // Fails to skip Credentials if Introduction is removed?
38 installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
39 //installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
40 //installer.setDefaultPageVisible(QInstaller.LicenseAgreementCheck, false);
41 //installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false);
42 installer.setDefaultPageVisible(QInstaller.ReadyForInstallation, false);
43 //installer.setDefaultPageVisible(QInstaller.PerformInstallation, false);
44 installer.setDefaultPageVisible(QInstaller.FinishedPage, false);
46 installer.componentAdded.connect(onComponentAdded);
47 installer.aboutCalculateComponentsToInstall.connect(onAboutCalculateComponentsToInstall);
48 installer.finishedCalculateComponentsToInstall.connect(onFinishedCalculateComponentsToInstall);
51 // installer callbacks
53 onComponentAdded = function(component)
55 console.log("Component added: " + component.name);
59 onAboutCalculateComponentsToInstall = function()
61 console.log("onAboutCalculateComponentsToInstall");
65 onFinishedCalculateComponentsToInstall = function()
67 console.log("onFinishedCalculateComponentsToInstall");
71 function disableComponent(componentName)
73 component = installer.componentByName(componentName)
74 component.enabled = false
75 component.forcedInstallation = false
76 //component.setValue("ForcedInstallation", "false");
80 // used to setup wizard pages and move the wizard forward
82 Controller.prototype.WelcomePageCallback = function()
86 gui.clickButton(buttons.NextButton);
89 Controller.prototype.CredentialsPageCallback = function()
93 gui.clickButton(buttons.NextButton);
96 Controller.prototype.IntroductionPageCallback = function()
100 gui.clickButton(buttons.NextButton);
103 Controller.prototype.ComponentSelectionPageCallback = function()
107 var page = gui.currentPageWidget();
109 if (installer.value("os") == "win") {
110 selectComponent(page, "qt.59.win32_mingw53");
111 selectComponent(page, "qt.tools.win32_mingw530");
113 else if (installer.value("os") == "x11") {
114 selectComponent(page, "qt.59.gcc");
115 selectComponent(page, "qt.59.gcc_64");
117 else if (installer.value("os") == "mac") {
118 selectComponent(page, "qt.59.clang_64");
120 //selectComponent(page, "qt.59.qtquickcontrols");
121 selectComponent(page, "qt.59.qtscript");
123 gui.clickButton(buttons.NextButton);
126 function selectComponent(page, name)
128 component = installer.componentByName(name);
130 console.log("component " + name + " : " + component);
131 page.selectComponent(name);
134 console.log("Failed to find component " + name + "!");
138 Controller.prototype.LicenseAgreementPageCallback = function()
142 setChecked("AcceptLicenseRadioButton", true);
144 gui.clickButton(buttons.NextButton);
147 Controller.prototype.StartMenuDirectoryPageCallback = function()
151 gui.clickButton(buttons.NextButton);
154 Controller.prototype.PerformInstallationPageCallback = function()
158 // show details and hide button
159 click("DetailsButton");
160 setVisible("DetailsButton", false);
162 // showing details will disable automated page switch, so re-enable it
163 installer.setAutomatedPageSwitchEnabled(true);
166 Controller.prototype.FinishedPageCallback = function()
170 setChecked("launchQtCreatorCheckBox", false);
172 gui.clickButton(buttons.FinishButton);
177 function logCallback()
179 var page = gui.currentPageWidget();
180 console.log(">>> " + page.objectName + "Callback");
183 function dumpComponents()
185 dumpComponentsArray(installer.components());
188 function dumpComponentsArray(components)
190 var arrayLength = components.length;
191 for (var i = 0; i < arrayLength; i++) {
192 dumpComponent(components[i]);
196 function dumpComponent(component)
198 console.log(component.name + " (" + component.displayName + ")");
199 console.log(" Virtual: " + component.value("Virtual", "false"));
200 console.log(" ForcedInstallation: " + component.value("ForcedInstallation", "false"));
201 console.log(" Default: " + component.default);
202 console.log(" Enabled: " + component.enabled);
209 var page = gui.currentPageWidget();
210 var button = gui.findChild(page, name);
212 console.log("button " + name + " : " + button);
216 console.log("Failed to find button " + name + "!");
220 function setVisible(name, visible)
222 var page = gui.currentPageWidget();
223 var button = gui.findChild(page, name);
225 console.log("button " + name + " : " + button);
226 button.visible = visible;
227 console.log("button " + name + " visible : " + button.visible);
230 console.log("Failed to find button " + name + "!");
234 function setEnabled(name, enabled)
236 var page = gui.currentPageWidget();
237 var button = gui.findChild(page, name);
239 console.log("button " + name + " : " + button);
240 button.enabled = enabled;
241 console.log("button " + name + " enabled : " + button.enabled);
244 console.log("Failed to find button " + name + "!");
248 function setChecked(name, checked)
250 var page = gui.currentPageWidget();
251 var button = gui.findChild(page, name);
253 console.log("button " + name + " : " + button);
254 button.checked = checked;
255 console.log("button " + name + " checked : " + button.checked);
258 console.log("Failed to find button " + name + "!");