Silent install Qt run installer on ubuntu server

你离开我真会死。 提交于 2019-11-26 15:25:47

问题


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?


回答1:


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

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

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).

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.




回答2:


As of installer 3.0.2-online 29-11-2017, you must add a delay in your JS script because the "Next" button in the "Welcome" page is disabled for one second or so.

Controller.prototype.WelcomePageCallback = function() {
    gui.clickButton(buttons.NextButton, 3000);
}



回答3:


There have few minor different in answering the questions of wizard for a different kind of version of Qt. To make it more simple, I have packed a generic script to extract Qt from an offline/online installer.

The script: qtci/extract-qt-installer at master · benlau/qtci

Example Usage:

extract-qt-installer qt-opensource-linux-x64-android-5.5.1.run ~/Qt

Environment Variables"

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")

Moreover, it has few scripts to download and install Qt with different versions.

qtci/recipes at master · benlau/qtci




回答4:


Bypassing "User Data Collection" screen

As of October 8, 2019, an extra screen has been added on Windows which will cause the installation to hang. You can click through it with the following addition to your .qs file:

Controller.prototype.DynamicTelemetryPluginFormCallback = function() {
    var widget = gui.currentPageWidget();
    widget.TelemetryPluginForm.statisticGroupBox.disableStatisticRadioButton.checked = true;
    gui.clickButton(buttons.NextButton);
}

Selecting "Archive" and "Latest releases"

Another recent change is to package categories. LTS is now the only one selected by default, meaning that you cannot install the latest Qt version without first selecting "Latest releases" in the package categories.

Here's how to do that:

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();

    // ...
}

See here for a more complete example for Windows.




回答5:


The script above is old. This should work (and I added retry for download errors)

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 with verbose so you don't have to wait too much time without output

qt.run -platform minimal --verbose --script ./qt-installer-noninteractive.qs 



回答6:


I had the same problem and came up with a simple python script that basically does the same what the official Qt installer does. You can find it here.

And that's how to use it:

sudo apt install python3-requests p7zip-full wget

wget https://git.kaidan.im/lnj/qli-installer/raw/master/qli-installer.py
chmod +x qli-installer.py

./qli-installer.py 5.11.3 linux desktop

Then the Qt installation can be found at ./5.11.3/gcc_64/ in this case. With other systems/targets (i.e. mac ios or linux android android_armv7) this will differ of course.

https://lnj.gitlab.io/post/qli-installer/




回答7:


This works for me!

 export DISPLAY=:1
 Xvfb :1 -screen 0 1024x768x16 &
 fluxbox &
 x11vnc -display :1 &

Connect to server using any vnc client




回答8:


Couple of months ago, I have crafted a configurable helper script for Qt installation automation. Although it is not a truly headless installer, as it simply iterates through install wizard screens, it can be used in continuous integration servers, and in fact it is tested this way.

Notes & features:

  • Works on Linux, MacOS, and Windows.
  • Qt version, components, and install path are configurable.
  • Always uses the most recent online installer.
  • Tested in Travis CI.
  • Bash is required, but it is typically present on continuous integration servers (at least on Travis).
  • Public domain (via CC0 waiver).

Home page: https://github.com/skalee/non-interactive-qt-installer



来源:https://stackoverflow.com/questions/25105269/silent-install-qt-run-installer-on-ubuntu-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!