summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@theqtcompany.com>2015-08-19 16:39:18 +0200
committerKai Koehne <kai.koehne@theqtcompany.com>2015-08-19 16:39:18 +0200
commitc417d953f743b8a273ea36ff7d7b1dc8b761d518 (patch)
tree4bc08bf733ba04a7846db8289ba7003a961bad82
parentc53747138d2f48138ee6e12149064344e668634d (diff)
parentd343cd20410ecb2741c85877c8203579dc7c227d (diff)
Merge remote-tracking branch 'origin/2.0'
Conflicts: Changelog dist/config/config.xml dist/packages/org.qtproject.ifw.binaries/meta/package.xml dist/packages/org.qtproject.ifw/meta/package.xml installerfw.pri src/libs/installer/component.cpp src/libs/kdtools/updatesinfo.cpp Change-Id: I0a1b4a464f7d9008b589b54dd7aed0cac71bd666
-rw-r--r--Changelog7
-rw-r--r--src/libs/installer/component.cpp38
-rw-r--r--src/libs/installer/packagemanagercore.cpp2
-rw-r--r--src/libs/installer/utils.cpp19
-rw-r--r--src/libs/installer/utils.h2
-rw-r--r--src/libs/kdtools/updatesinfo.cpp19
-rw-r--r--src/sdk/installerbase.cpp6
7 files changed, 77 insertions, 16 deletions
diff --git a/Changelog b/Changelog
index 51eb2d129..2892eb68e 100644
--- a/Changelog
+++ b/Changelog
@@ -1,5 +1,12 @@
2.1.0
+2.0.2
+- Fix .dat file that gets deleted after multiple component changes on Windows.
+- Fix maintenance tool upgrade on OS X.
+- Unify selection of language for translations. (QTIFW-390)
+- Fix return value of component.installAction() when updating. (QTIFW-727)
+- Documentation updates.
+
2.0.1
- Do not throw exception on empty translation files.
- Fix --checkupdates mode.
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index cabaa9231..688a5b928 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -42,6 +42,7 @@
#include "packagemanagercore.h"
#include "remoteclient.h"
#include "settings.h"
+#include "utils.h"
#include "updateoperationfactory.h"
@@ -595,23 +596,32 @@ void Component::loadLicenses(const QString &directory, const QHash<QString, QVar
if (!ProductKeyCheck::instance()->isValidLicenseTextFile(fileName))
continue;
- QFileInfo fileInfo(fileName);
- QFile file(QString::fromLatin1("%1%2_%3.%4").arg(directory, fileInfo.baseName(),
- QLocale().name().toLower(), fileInfo.completeSuffix()));
- if (!file.exists()) {
- file.setFileName(QString::fromLatin1("%1%2_%3.%4").arg(directory, fileInfo.baseName(),
- QLocale().name().left(2), fileInfo.completeSuffix()));
+ QFileInfo fileInfo(directory, fileName);
+ foreach (const QString &lang, QLocale().uiLanguages()) {
+ if (QLocale(lang).language() == QLocale::English) // we assume English is the default language
+ break;
+
+ QList<QFileInfo> fileCandidates;
+ foreach (const QString &locale, QInstaller::localeCandidates(lang.toLower())) {
+ fileCandidates << QFileInfo(QString::fromLatin1("%1%2_%3.%4").arg(
+ directory, fileInfo.baseName(), locale,
+ fileInfo.completeSuffix()));
+ }
+
+ auto fInfo = std::find_if(fileCandidates.constBegin(), fileCandidates.constEnd(),
+ [](const QFileInfo &file) {
+ return file.exists();
+ });
+ if (fInfo != fileCandidates.constEnd()) {
+ fileInfo = *fInfo;
+ break;
+ }
}
+ QFile file(fileInfo.filePath());
if (!file.open(QIODevice::ReadOnly)) {
- // No translated license, use untranslated file
- qDebug().nospace() << "Unable to open translated license file" << file.fileName()
- << ". Using untranslated fallback.";
- file.setFileName(directory + fileName);
- if (!file.open(QIODevice::ReadOnly)) {
- throw Error(tr("Cannot open the requested license file \"%1\": %2").arg(
- fileName, file.errorString()));
- }
+ throw Error(tr("Cannot open the requested license file \"%1\": %2").arg(
+ file.fileName(), file.errorString()));
}
QTextStream stream(&file);
stream.setCodec("UTF-8");
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 7ee6f5e06..c5cfeb5e9 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -524,7 +524,7 @@ void PackageManagerCore::componentsToInstallNeedsRecalculation()
QSet<Component *> componentsToUninstall = d->uninstallerCalculator()->componentsToUninstall();
- foreach (Component *component, components(ComponentType::Root | ComponentType::Descendants))
+ foreach (Component *component, components(ComponentType::All))
component->setInstallAction(component->isInstalled()
? ComponentModelHelper::KeepInstalled
: ComponentModelHelper::KeepUninstalled);
diff --git a/src/libs/installer/utils.cpp b/src/libs/installer/utils.cpp
index eccd1602d..199c544ed 100644
--- a/src/libs/installer/utils.cpp
+++ b/src/libs/installer/utils.cpp
@@ -114,6 +114,23 @@ bool QInstaller::startDetached(const QString &program, const QStringList &argume
return success;
}
+// Returns ["en-us", "en"] for "en-us"
+QStringList QInstaller::localeCandidates(const QString &locale_)
+{
+ QStringList candidates;
+ QString locale = locale_;
+ candidates.reserve(locale.count(QLatin1Char('-')));
+ forever {
+ candidates.append(locale);
+ int r = locale.lastIndexOf(QLatin1Char('-'));
+ if (r <= 0)
+ break;
+ locale.truncate(r);
+ }
+ return candidates;
+}
+
+
static bool verb = false;
void QInstaller::setVerbose(bool v)
@@ -400,3 +417,5 @@ QString QInstaller::windowsErrorString(int errorCode)
}
#endif
+
+
diff --git a/src/libs/installer/utils.h b/src/libs/installer/utils.h
index f0a70e11c..0fa6f2983 100644
--- a/src/libs/installer/utils.h
+++ b/src/libs/installer/utils.h
@@ -66,6 +66,8 @@ namespace QInstaller {
QString createCommandline(const QString &program, const QStringList &arguments);
#endif
+ QStringList INSTALLER_EXPORT localeCandidates(const QString &locale);
+
void INSTALLER_EXPORT setVerbose(bool v);
bool INSTALLER_EXPORT isVerbose();
diff --git a/src/libs/kdtools/updatesinfo.cpp b/src/libs/kdtools/updatesinfo.cpp
index 44539171b..9b4913f62 100644
--- a/src/libs/kdtools/updatesinfo.cpp
+++ b/src/libs/kdtools/updatesinfo.cpp
@@ -33,10 +33,13 @@
****************************************************************************/
#include "updatesinfo_p.h"
+#include "utils.h"
#include <QDomDocument>
#include <QFile>
#include <QLocale>
+#include <QPair>
+#include <QVector>
#include <QUrl>
using namespace KDUpdater;
@@ -117,6 +120,7 @@ bool UpdatesInfoData::parsePackageUpdateElement(const QDomElement &updateE)
return false;
UpdateInfo info;
+ QMap<QString, QString> localizedDescriptions;
for (int i = 0; i < updateE.childNodes().count(); i++) {
QDomElement childE = updateE.childNodes().at(i).toElement();
if (childE.isNull())
@@ -144,7 +148,10 @@ bool UpdatesInfoData::parsePackageUpdateElement(const QDomElement &updateE)
} else if (childE.tagName() == QLatin1String("DisplayName")) {
processLocalizedTag(childE, info.data);
} else if (childE.tagName() == QLatin1String("Description")) {
- processLocalizedTag(childE, info.data);
+ if (!childE.hasAttribute(QLatin1String("xml:lang")))
+ info.data[QLatin1String("Description")] = childE.text();
+ QString languageAttribute = childE.attribute(QLatin1String("xml:lang"), QLatin1String("en"));
+ localizedDescriptions.insert(languageAttribute.toLower(), childE.text());
} else if (childE.tagName() == QLatin1String("UpdateFile")) {
info.data[QLatin1String("CompressedSize")] = childE.attribute(QLatin1String("CompressedSize"));
info.data[QLatin1String("UncompressedSize")] = childE.attribute(QLatin1String("UncompressedSize"));
@@ -153,6 +160,16 @@ bool UpdatesInfoData::parsePackageUpdateElement(const QDomElement &updateE)
}
}
+ QStringList candidates;
+ foreach (const QString &lang, QLocale().uiLanguages())
+ candidates << QInstaller::localeCandidates(lang.toLower());
+ foreach (const QString &candidate, candidates) {
+ if (localizedDescriptions.contains(candidate)) {
+ info.data[QLatin1String("Description")] = localizedDescriptions.value(candidate);
+ break;
+ }
+ }
+
if (!info.data.contains(QLatin1String("Name"))) {
setInvalidContentError(tr("PackageUpdate element without Name"));
return false;
diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp
index 0557f36a2..38ff0e406 100644
--- a/src/sdk/installerbase.cpp
+++ b/src/sdk/installerbase.cpp
@@ -107,6 +107,12 @@ int InstallerBase::run()
QInstaller::BinaryContent::readBinaryContent(&binary, &oldOperations, &manager, &magicMarker,
cookie);
+ // Usually resources simply get mapped into memory and therefore the file does not need to be
+ // kept open during application runtime. Though in case of offline installers we need to access
+ // the appended binary content (packages etc.), so we close only in maintenance mode.
+ if (magicMarker != QInstaller::BinaryContent::MagicInstallerMarker)
+ binary.close();
+
CommandLineParser parser;
parser.parse(arguments());