summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/installer/component.cpp6
-rw-r--r--src/libs/installer/elevatedexecuteoperation.cpp4
-rw-r--r--src/libs/installer/packagemanagercore.cpp21
-rw-r--r--src/libs/installer/packagemanagercore.h2
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp6
-rw-r--r--src/libs/installer/packagemanagercoredata.cpp20
-rw-r--r--src/libs/installer/packagemanagercoredata.h2
-rw-r--r--src/libs/installer/scriptengine.cpp6
-rw-r--r--src/libs/installer/scriptengine_p.h4
9 files changed, 47 insertions, 24 deletions
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 &regexp) 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 &regexp = 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> &params)
{
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 &regexp) 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 &regexp = QString()) const;
QJSValue componentByName(const QString &componentName);
private: