在 ubuntu 服务器上静默安装 Qt 运行安装程序 [英] Silent install Qt run installer on ubuntu server

查看:82
本文介绍了在 ubuntu 服务器上静默安装 Qt 运行安装程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法在 Ubuntu 服务器上静默安装 Qt 运行安装程序?
我的意思是绕过安装程序的选项并进行默认安装?

I wanted to know if there is a way to do a silent install of the Qt run installer on Ubuntu Server?
I mean by-pass the options of the installer and do a default install?

推荐答案

Qt 工具包是使用 Qt 安装程序框架 (QtIFW) 打包的.QtIFW 安装程序支持 --script 选项,允许您通过 控制器脚本 API.这是用于非交互式安装 Qt 5 的 qt-installer-noninteractive.qs 文件:

The Qt toolkit is packaged using the Qt Installer Framework (QtIFW). QtIFW installers support a --script option that allows you to programatically control the installation via the Controller Scripting API. Here's qt-installer-noninteractive.qs file to install Qt 5 non-interactively:

// 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);
}

此脚本演示了如何选择/取消选择某些组件.根据您的需要进行自定义,或者完全删除这些行以进行默认安装.同样,您可能希望自定义或删除 TargetDirectoryLineEdit 行.像这样运行 Qt 安装程序:

This script demonstrates how to select/deselect certain components. Customize for your needs or just remove the lines entirely for a default installation. Likewise, you may want to customize or remove the TargetDirectoryLineEdit line. Run the Qt installer like:

qt-opensource-linux-x64-5.5.1.run --script qt-installer-noninteractive.qs

为无头安装添加-platform minimum.基于较新版本 QtIFW 的未来安装程序应该能够使用 --silent 选项代替(请参阅 QTIFW-166).

Add -platform minimal for a headless installation. Future installers based on newer versions of QtIFW should be able to use a --silent option instead (see QTIFW-166).

添加 --verbose 以获得更详细的控制台输出(有助于收集组件名称、向导页面名称等).此链接也有助于确定组件名称.

Add --verbose for more verbose console output (helpful for gleaning component names, wizard page names, etc). This link is also helpful for figuring out component names.

这篇关于在 ubuntu 服务器上静默安装 Qt 运行安装程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆