4
0
mirror of https://github.com/QuasarApp/installer-framework.git synced 2025-05-09 03:29:33 +00:00

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
This commit is contained in:
Kai Koehne 2015-08-19 16:39:18 +02:00
commit c417d953f7
7 changed files with 77 additions and 16 deletions

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

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

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

@ -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

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

@ -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;

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