diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2021-06-02 16:40:24 +0300 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2021-06-02 16:40:24 +0300 |
commit | 3fdbd475202703530ca4b8f7f2a0e731d5f87f8b (patch) | |
tree | 516a9c48a004fc471fe8bc5dedd4efa72550cab9 | |
parent | 35f79da9cb99c7c0456f002829dc0fdfe55b4f8d (diff) | |
parent | 45e77c3a1eb790d89f2ded5b7fbe556ed4b5271c (diff) |
Merge remote-tracking branch 'origin/4.1'
Change-Id: I86049138466399411ba36791330f4a94faad8c52
-rw-r--r-- | Changelog | 10 | ||||
-rw-r--r-- | coin/instructions/qmake_module_build.yaml | 14 | ||||
-rw-r--r-- | doc/installerfw.qdoc | 26 | ||||
-rw-r--r-- | doc/scripting-api/packagemanagercore.qdoc | 5 | ||||
-rw-r--r-- | src/libs/installer/component.cpp | 6 | ||||
-rw-r--r-- | src/libs/installer/elevatedexecuteoperation.cpp | 4 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 21 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.h | 2 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 6 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercoredata.cpp | 20 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercoredata.h | 2 | ||||
-rw-r--r-- | src/libs/installer/scriptengine.cpp | 6 | ||||
-rw-r--r-- | src/libs/installer/scriptengine_p.h | 4 | ||||
-rw-r--r-- | src/sdk/sdkapp.h | 2 | ||||
-rw-r--r-- | tests/auto/installer/scriptengine/tst_scriptengine.cpp | 15 |
15 files changed, 113 insertions, 30 deletions
@@ -1,3 +1,13 @@ +4.1.1 +- Add possibility to filter available packages with regexp from script (QTIFW-2225) +- Add documentation for configuring and overwriting default translations (QTIFW-2217) +- Fix loading of component translations (QTIFW-2220) +- CLI: Print warning when creating over 4GB installers on Windows (QTIFW-2199) +- Remove wayland dependency from Linux binaries (QTIFW-2067) +- Fix maintenancetool overwriting installer values (QTIFW-2218) +- Fix QFile warning on rollback (QTIFW-2213) +- Fix return value for detached 'Execute' operation (QTIFW-2210) + 4.1.0 - Emit signal when components are recalculated (QTIFW-2172) - Add Arabic translation (QTIFW-1425) diff --git a/coin/instructions/qmake_module_build.yaml b/coin/instructions/qmake_module_build.yaml index 37ff0f396..3e1072d01 100644 --- a/coin/instructions/qmake_module_build.yaml +++ b/coin/instructions/qmake_module_build.yaml @@ -33,9 +33,23 @@ instructions: directory: "{{.BuildDir}}" - type: ExecuteCommand + command: ["{{.InstallDir}}/bin/qmake", "QTPLUGIN.platforms = qminimal qxcb", "INSTALL_PREFIX={{.InstallDir}}", "{{.SourceDir}}"] + maxTimeInSeconds: 1800 + maxTimeBetweenOutput: 600 + userMessageOnFailure: "Failed to run qmake, check logs." + enable_if: + condition: property + property: host.os + equals_value: Linux + + - type: ExecuteCommand command: ["{{.InstallDir}}/bin/qmake", "INSTALL_PREFIX={{.InstallDir}}", "{{.SourceDir}}"] maxTimeInSeconds: 1800 maxTimeBetweenOutput: 600 userMessageOnFailure: "Failed to run qmake, check logs." + enable_if: + condition: property + property: host.os + not_equals_value: Linux - !include "{{installer-framework/installer-framework}}/make_instructions.yaml" - !include "{{installer-framework/installer-framework}}/make_documentation.yaml" diff --git a/doc/installerfw.qdoc b/doc/installerfw.qdoc index 6f77d8850..0d60a3fca 100644 --- a/doc/installerfw.qdoc +++ b/doc/installerfw.qdoc @@ -533,9 +533,10 @@ \li Filename for the configuration file on the target. Default is components.xml. \row \li Translations - \li List of language codes to be used for translating the user interface. To add several language - variants, specify several \c <Translation> child elements that each specify the name - of a language variant. Optional. For more information, see \l{Translating Pages}. + \li List of translation files to be used for translating the user interface. To add + several translation files, specify several \c <Translation> child elements that + each specify the name of the translation. Optional. For more information, see + \l{Translating Pages} and \l{Configuring and Overwriting Default Translations}. \row \li UrlQueryString \li This string needs to be in the form "key=value" and will be appended to archive download @@ -729,6 +730,25 @@ \note The translation system can also be used to customize the UI. Use e.g. an \c en.ts file to replace any text in the installer with a custom English version. + + \section1 Configuring and Overwriting Default Translations + + The installer has been localized into several languages. System language is used to define the + loaded language. In case you want to define the used language for your installer, define the + languages in \c config.xml using the \c <Translations> element. For example, using only German + translations: + + \code + <Translations> + <Translation>ifw_de</Translation> + <Translation>qt_de</Translation> + </Translations> + \endcode + + The default translations can be also overwritten. Write your own translation file and add + it to a custom resource called \c :/translations_new. This custom resource can be added to + the installer using \c binarycreator option \c -r. For more information, see + \l{Summary of binarycreator Parameters}. */ /*! diff --git a/doc/scripting-api/packagemanagercore.qdoc b/doc/scripting-api/packagemanagercore.qdoc index f4d71ee97..918aed78d 100644 --- a/doc/scripting-api/packagemanagercore.qdoc +++ b/doc/scripting-api/packagemanagercore.qdoc @@ -33,11 +33,12 @@ */ /*! - \qmlmethod array installer::components() + \qmlmethod array installer::components(string regexp) Returns an array of all components currently available. If the repository metadata have not been fetched yet, - the array will be empty. + the array will be empty. Optionally, a \a regexp expression + can be used to further filter the listed packages. \sa component, finishAllComponentsReset(), finishUpdaterComponentsReset() */ diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 8142cd4e1..b4b96eb08 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -624,15 +624,15 @@ void Component::loadTranslations(const QDir &directory, const QStringList &qms) while (it.hasNext()) { const QString filename = it.next(); const QString basename = QFileInfo(filename).baseName(); - if (!uiLanguage.startsWith(QFileInfo(filename).baseName(), Qt::CaseInsensitive)) - continue; // do not load the file if it does not match the UI language if (!translations.isEmpty()) { bool found = false; foreach (const QString &translation, translations) - found |= translation.startsWith(basename, Qt::CaseInsensitive); + found |= translation.startsWith(QLatin1String("ifw_") + basename, Qt::CaseInsensitive); if (!found) // don't load the file if it does match the UI language but is not allowed to be used continue; + } else if (!uiLanguage.startsWith(QFileInfo(filename).baseName(), Qt::CaseInsensitive)) { + continue; // do not load the file if it does not match the UI language } QScopedPointer<QTranslator> translator(new QTranslator(this)); diff --git a/src/libs/installer/elevatedexecuteoperation.cpp b/src/libs/installer/elevatedexecuteoperation.cpp index f81377ac4..4ca9a8e59 100644 --- a/src/libs/installer/elevatedexecuteoperation.cpp +++ b/src/libs/installer/elevatedexecuteoperation.cpp @@ -151,13 +151,15 @@ int ElevatedExecuteOperation::Private::run(QStringList &arguments, const Operati // unix style: when there's an ampersand after the command, it's started detached if (args.count() >= 2 && args.last() == QLatin1String("&")) { + int returnValue = NoError; args.pop_back(); const bool success = QProcessWrapper::startDetached(args.front(), args.mid(1)); if (!success) { q->setError(UserDefinedError); q->setErrorString(tr("Cannot start detached: \"%1\"").arg(callstr)); + returnValue = Error; } - return success; + return returnValue; } process = new QProcessWrapper(); diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 663304367..61b2273af 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -897,11 +897,10 @@ void PackageManagerCore::rollBackInstallation() } d->m_localPackageHub->writeToDisk(); - if (isInstaller()) { - if (d->m_localPackageHub->packageInfoCount() == 0) { - QFile file(d->m_localPackageHub->fileName()); + if (isInstaller() && d->m_localPackageHub->packageInfoCount() == 0) { + QFile file(d->m_localPackageHub->fileName()); + if (!file.fileName().isEmpty() && file.exists()) file.remove(); - } } if (becameAdmin) @@ -1863,8 +1862,9 @@ void PackageManagerCore::appendRootComponent(Component *component) /*! Returns a list of components depending on the component types passed in \a mask. + Optionally, a \a regexp expression can be used to further filter the listed packages. */ -QList<Component *> PackageManagerCore::components(ComponentTypes mask) const +QList<Component *> PackageManagerCore::components(ComponentTypes mask, const QString ®exp) const { QList<Component *> components; @@ -1885,6 +1885,17 @@ QList<Component *> PackageManagerCore::components(ComponentTypes mask) const // No descendants here, updates are always a flat list and cannot have children! } + if (!regexp.isEmpty()) { + QRegularExpression re(regexp); + QList<Component*>::iterator iter = components.begin(); + while (iter != components.end()) { + if (!re.match(iter.i->t()->name()).hasMatch()) + iter = components.erase(iter); + else + iter++; + } + } + return components; } diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h index 2c54122f5..b5ef6304e 100644 --- a/src/libs/installer/packagemanagercore.h +++ b/src/libs/installer/packagemanagercore.h @@ -225,7 +225,7 @@ public: void appendRootComponent(Component *components); void appendUpdaterComponent(Component *components); - QList<Component *> components(ComponentTypes mask) const; + QList<Component *> components(ComponentTypes mask, const QString ®exp = QString()) const; Component *componentByName(const QString &identifier) const; Q_INVOKABLE bool calculateComponentsToInstall() const; diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index f5d3d3508..0f1bb90be 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -611,7 +611,7 @@ UninstallerCalculator *PackageManagerCorePrivate::uninstallerCalculator() const void PackageManagerCorePrivate::initialize(const QHash<QString, QString> ¶ms) { m_coreCheckedHash.clear(); - m_data = PackageManagerCoreData(params); + m_data = PackageManagerCoreData(params, isInstaller()); m_componentsToInstallCalculated = false; #ifdef Q_OS_LINUX @@ -925,8 +925,8 @@ void PackageManagerCorePrivate::readMaintenanceConfigFiles(const QString &target const QVariantHash v = cfg.value(QLatin1String("Variables")).toHash(); // Do not change to // QVariantMap! Breaks reading from existing .ini files, cause the variant types do not match. for (QVariantHash::const_iterator it = v.constBegin(); it != v.constEnd(); ++it) { - m_data.setValue(it.key(), replacePath(it.value().toString(), QLatin1String(scRelocatable), - targetDir)); + if (!m_data.contains(it.key()) || m_data.value(it.key()).isNull()) + m_data.setValue(it.key(), replacePath(it.value().toString(), QLatin1String(scRelocatable), targetDir)); } QSet<Repository> repos; const QVariantList variants = cfg.value(QLatin1String("DefaultRepositories")) diff --git a/src/libs/installer/packagemanagercoredata.cpp b/src/libs/installer/packagemanagercoredata.cpp index 3326ec65e..8f6f24a09 100644 --- a/src/libs/installer/packagemanagercoredata.cpp +++ b/src/libs/installer/packagemanagercoredata.cpp @@ -50,14 +50,13 @@ namespace QInstaller \internal */ -PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &variables) +PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &variables, const bool isInstaller) { // Add user defined variables before dynamic as user settings can affect dynamic variables. setUserDefinedVariables(variables); addDynamicPredefinedVariables(); // Set some common variables that may used e.g. as placeholder in some of the settings variables or // in a script or... - addNewVariable(scTargetConfigurationFile, QLatin1String("components.xml")); addNewVariable(QLatin1String("InstallerDirPath"), QCoreApplication::applicationDirPath()); addNewVariable(QLatin1String("InstallerFilePath"), QCoreApplication::applicationFilePath()); @@ -81,8 +80,6 @@ PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &va addNewVariable(scTitle, replaceVariables(m_settings.title())); addNewVariable(scPublisher, m_settings.publisher()); addNewVariable(QLatin1String("Url"), m_settings.url()); - addNewVariable(scStartMenuDir, m_settings.startMenuDir()); - addNewVariable(scTargetConfigurationFile, m_settings.configurationFileName()); addNewVariable(scLogo, m_settings.logo()); addNewVariable(scWatermark, m_settings.watermark()); addNewVariable(scBanner, m_settings.banner()); @@ -92,7 +89,20 @@ PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &va if (!description.isEmpty()) addNewVariable(scRunProgramDescription, description); - addNewVariable(scTargetDir, replaceVariables(m_settings.targetDir())); + // Some settings might change during install, read those settings later from + // maintenancetool if maintenancetool is used. + if (isInstaller) { + addNewVariable(scTargetDir, replaceVariables(m_settings.targetDir())); + addNewVariable(scTargetConfigurationFile, m_settings.configurationFileName()); + addNewVariable(scStartMenuDir, m_settings.startMenuDir()); + } else { +#ifdef Q_OS_MACOS + addNewVariable(scTargetDir, QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../../..")).absoluteFilePath()); +#else + addNewVariable(scTargetDir, QCoreApplication::applicationDirPath()); +#endif + + } addNewVariable(scRemoveTargetDir, replaceVariables(m_settings.removeTargetDir())); } diff --git a/src/libs/installer/packagemanagercoredata.h b/src/libs/installer/packagemanagercoredata.h index 32a848aed..3cfb77c95 100644 --- a/src/libs/installer/packagemanagercoredata.h +++ b/src/libs/installer/packagemanagercoredata.h @@ -37,7 +37,7 @@ class PackageManagerCoreData { public: PackageManagerCoreData() {} - explicit PackageManagerCoreData(const QHash<QString, QString> &variables); + explicit PackageManagerCoreData(const QHash<QString, QString> &variables, const bool isInstaller); void clear(); void addDynamicPredefinedVariables(); diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index 5dd56939c..c8fc65d34 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -75,10 +75,10 @@ namespace QInstaller { \internal */ -QJSValue InstallerProxy::components() const +QJSValue InstallerProxy::components(const QString ®exp) const { if (m_core) { - const QList<Component*> all = m_core->components(PackageManagerCore::ComponentType::All); + const QList<Component*> all = m_core->components(PackageManagerCore::ComponentType::All, regexp); QJSValue scriptComponentsObject = m_engine->newArray(all.count()); for (int i = 0; i < all.count(); ++i) { Component *const component = all.at(i); diff --git a/src/libs/installer/scriptengine_p.h b/src/libs/installer/scriptengine_p.h index c5f04c0dc..e5c39663c 100644 --- a/src/libs/installer/scriptengine_p.h +++ b/src/libs/installer/scriptengine_p.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -63,7 +63,7 @@ public: : m_engine(engine), m_core(core) {} public slots: - QJSValue components() const; + QJSValue components(const QString ®exp = QString()) const; QJSValue componentByName(const QString &componentName); private: diff --git a/src/sdk/sdkapp.h b/src/sdk/sdkapp.h index 17077c8f1..0c6c362bc 100644 --- a/src/sdk/sdkapp.h +++ b/src/sdk/sdkapp.h @@ -496,9 +496,9 @@ private: QList<QByteArray> m_resourceMappings; public: + RunOnceChecker m_runCheck; QInstaller::PackageManagerCore *m_core; CommandLineParser m_parser; - RunOnceChecker m_runCheck; }; #endif // SDKAPP_H diff --git a/tests/auto/installer/scriptengine/tst_scriptengine.cpp b/tests/auto/installer/scriptengine/tst_scriptengine.cpp index b7c602e26..105bcf5d7 100644 --- a/tests/auto/installer/scriptengine/tst_scriptengine.cpp +++ b/tests/auto/installer/scriptengine/tst_scriptengine.cpp @@ -349,6 +349,21 @@ private slots: } } + void testComponentsWithRegexp() + { + const QString script = QString::fromLatin1("var components = installer.components(\"component.test.addOperation\");" + "\n" + "for (i = 0; i < components.length; i++)" + "print(components[i].name);"); + + setExpectedScriptOutput("component.test.addOperation"); + const QJSValue value = m_scriptEngine->evaluate(script); + if (value.isError()) { + QFAIL(qPrintable(QString::fromLatin1("ScriptEngine error:\n %1").arg( + value.toString()))); + } + } + void testFindFiles() { const QString expectedOutput = QString::fromLatin1("Found file %1/tst_scriptengine.moc").arg(m_applicatonDirPath); |