Ant*_*ine 41 qt install ubuntu-server
我想知道是否有办法在Ubuntu Server上静默安装Qt运行安装程序?
我的意思是绕过安装程序的选项并进行默认安装?
noc*_*neo 58
Qt工具包使用Qt安装程序框架(QtIFW)打包.QtIFW安装程序支持一个--script选项,允许您通过Controller Scripting API以编程方式控制安装.这qt-installer-noninteractive.qs是以非交互方式安装Qt 5 的文件:
// Emacs mode hint: -*- mode: JavaScript -*-
function Controller() {
installer.autoRejectMessageBoxes();
installer.installationFinished.connect(function() {
gui.clickButton(buttons.NextButton);
})
}
Controller.prototype.WelcomePageCallback = function() {
// click delay here because the next button is initially disabled for ~1 second
gui.clickButton(buttons.NextButton, 3000);
}
Controller.prototype.CredentialsPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.IntroductionPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.TargetDirectoryPageCallback = function()
{
gui.currentPageWidget().TargetDirectoryLineEdit.setText(installer.value("HomeDir") + "/Qt");
gui.clickButton(buttons.NextButton);
}
Controller.prototype.ComponentSelectionPageCallback = function() {
var widget = gui.currentPageWidget();
widget.deselectAll();
widget.selectComponent("qt.55.gcc_64");
widget.selectComponent("qt.55.qtquickcontrols");
// widget.deselectComponent("qt.tools.qtcreator");
// widget.deselectComponent("qt.55.qt3d");
// widget.deselectComponent("qt.55.qtcanvas3d");
// widget.deselectComponent("qt.55.qtlocation");
// widget.deselectComponent("qt.55.qtquick1");
// widget.deselectComponent("qt.55.qtscript");
// widget.deselectComponent("qt.55.qtwebengine");
// widget.deselectComponent("qt.extras");
// widget.deselectComponent("qt.tools.doc");
// widget.deselectComponent("qt.tools.examples");
gui.clickButton(buttons.NextButton);
}
Controller.prototype.LicenseAgreementPageCallback = function() {
gui.currentPageWidget().AcceptLicenseRadioButton.setChecked(true);
gui.clickButton(buttons.NextButton);
}
Controller.prototype.StartMenuDirectoryPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.ReadyForInstallationPageCallback = function()
{
gui.clickButton(buttons.NextButton);
}
Controller.prototype.FinishedPageCallback = function() {
var checkBoxForm = gui.currentPageWidget().LaunchQtCreatorCheckBoxForm;
if (checkBoxForm && checkBoxForm.launchQtCreatorCheckBox) {
checkBoxForm.launchQtCreatorCheckBox.checked = false;
}
gui.clickButton(buttons.FinishButton);
}
Run Code Online (Sandbox Code Playgroud)
此脚本演示了如何选择/取消选择某些组件.根据您的需求进行自定义,或者仅为默认安装完全删除行.同样,您可能想要自定义或删除该TargetDirectoryLineEdit行.运行Qt安装程序,如:
qt-opensource-linux-x64-5.5.1.run --script qt-installer-noninteractive.qs
Run Code Online (Sandbox Code Playgroud)
添加-platform minimal无头安装.基于较新版本的QtIFW的未来安装程序应该能够使用一个--silent选项(参见QTIFW-166).
添加--verbose更详细的控制台输出(有助于收集组件名称,向导页面名称等).此链接也有助于计算组件名称.
从安装程序3.0.2-online29-11-2017开始,您必须在JS脚本中添加延迟,因为"欢迎"页面中的"下一步"按钮被禁用一秒钟左右.
Controller.prototype.WelcomePageCallback = function() {
gui.clickButton(buttons.NextButton, 3000);
}
Run Code Online (Sandbox Code Playgroud)
对于不同类型的Qt,回答向导的问题几乎没有什么不同.为了使它更简单,我打包了一个通用脚本来从离线/在线安装程序中提取Qt.
脚本: qtci/extract-qt-installer在master·benlau/qtci
用法示例:
extract-qt-installer qt-opensource-linux-x64-android-5.5.1.run ~/Qt
Run Code Online (Sandbox Code Playgroud)
环境变量"
VERBOSE [Optional] Set to "true" will enable VERBOSE output
QT_CI_PAGEAGES [Optional] Select the components to be installed instead of using default (eg. QT_CI_PAGEAGES="qt.59.gcc_64")
Run Code Online (Sandbox Code Playgroud)
此外,它有很少的脚本可以下载和安装不同版本的Qt.
qtci/recipes at master·benlau/qtci
自2019年10月8日起,Windows上已添加一个额外的屏幕,这将导致安装挂起。您可以单击它,并在.qs文件中添加以下内容:
Controller.prototype.DynamicTelemetryPluginFormCallback = function() {
var widget = gui.currentPageWidget();
widget.TelemetryPluginForm.statisticGroupBox.disableStatisticRadioButton.checked = true;
gui.clickButton(buttons.NextButton);
}
Run Code Online (Sandbox Code Playgroud)
最近的另一项更改是包装类别。LTS现在是默认情况下唯一选择的版本,这意味着您必须先在软件包类别中选择“最新发行版”,才能安装最新的Qt版本。
这样做的方法如下:
Controller.prototype.ComponentSelectionPageCallback = function() {
var page = gui.pageWidgetByObjectName("ComponentSelectionPage");
var archiveCheckBox = gui.findChild(page, "Archive");
var latestCheckBox = gui.findChild(page, "Latest releases");
var fetchButton = gui.findChild(page, "FetchCategoryButton");
archiveCheckBox.click();
latestCheckBox.click();
fetchButton.click();
// ...
}
Run Code Online (Sandbox Code Playgroud)
有关Windows的更完整示例,请参见此处。
上面的脚本很旧。这应该工作(并且我添加了重试下载错误)
function Controller() {
installer.autoRejectMessageBoxes();
installer.setMessageBoxAutomaticAnswer("installationError", QMessageBox.Retry);
installer.setMessageBoxAutomaticAnswer("installationErrorWithRetry", QMessageBox.Retry);
installer.setMessageBoxAutomaticAnswer("DownloadError", QMessageBox.Retry);
installer.setMessageBoxAutomaticAnswer("archiveDownloadError", QMessageBox.Retry);
installer.installationFinished.connect(function() {
gui.clickButton(buttons.NextButton);
})
}
Controller.prototype.WelcomePageCallback = function() {
// click delay here because the next button is initially disabled for ~1 second
gui.clickButton(buttons.NextButton, 3000);
}
Controller.prototype.CredentialsPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.IntroductionPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.TargetDirectoryPageCallback = function()
{
//dev is the user in our docker image
gui.currentPageWidget().TargetDirectoryLineEdit.setText(installer.value("HomeDir") + "/Qt");
gui.clickButton(buttons.NextButton);
}
Controller.prototype.PerformInstallationPageCallback = function() {
gui.clickButton(buttons.CommitButton);
}
Controller.prototype.ComponentSelectionPageCallback = function() {
function list_packages() {
var components = installer.components();
console.log("Available components: " + components.length);
var packages = ["Packages: "];
for (var i = 0 ; i < components.length ;i++) {
packages.push(components[i].name);
}
console.log(packages.join(" "));
}
list_packages();
var widget = gui.currentPageWidget();
console.log(widget);
widget.deselectAll();
widget.selectComponent("qt.qt5.5130");
widget.selectComponent("qt.qt5.5130.gcc_64");
// widget.deselectComponent("");
gui.clickButton(buttons.NextButton);
}
Controller.prototype.LicenseAgreementPageCallback = function() {
gui.currentPageWidget().AcceptLicenseRadioButton.setChecked(true);
gui.clickButton(buttons.NextButton);
}
Controller.prototype.StartMenuDirectoryPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.ReadyForInstallationPageCallback = function()
{
gui.clickButton(buttons.NextButton);
}
Controller.prototype.FinishedPageCallback = function() {
var checkBoxForm = gui.currentPageWidget().LaunchQtCreatorCheckBoxForm;
if (checkBoxForm && checkBoxForm.launchQtCreatorCheckBox) {
checkBoxForm.launchQtCreatorCheckBox.checked = false;
}
gui.clickButton(buttons.FinishButton);
}
Run Code Online (Sandbox Code Playgroud)
以冗长的方式运行,因此您无需等待太多时间就无需输出
qt.run -platform minimal --verbose --script ./qt-installer-noninteractive.qs
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17354 次 |
| 最近记录: |