summaryrefslogtreecommitdiffstats
path: root/src/libs/ifwtools
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-11-26 11:43:53 +0200
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-12-08 10:14:02 +0200
commit4e7de73c260d56cf6fabd76fbb66d5b7321ca597 (patch)
tree9359b5ff5b044af030e4051a06daf629ab390336 /src/libs/ifwtools
parent64f01a16493ead69a4ae8cb3a234f20716edfc92 (diff)
Tools: fix binarycreator usage with unified meta-only repositories
Also take into account the case of using both split and unified meta repositories for the same binarycreator run. Task-number: QTIFW-2051 Change-Id: I757165f4b53cf301eb0d4bc9dbc94cacc9f3859e Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs/ifwtools')
-rw-r--r--src/libs/ifwtools/binarycreator.cpp11
-rw-r--r--src/libs/ifwtools/repositorygen.cpp38
2 files changed, 36 insertions, 13 deletions
diff --git a/src/libs/ifwtools/binarycreator.cpp b/src/libs/ifwtools/binarycreator.cpp
index b3119f5be..9c141d1a0 100644
--- a/src/libs/ifwtools/binarycreator.cpp
+++ b/src/libs/ifwtools/binarycreator.cpp
@@ -748,6 +748,7 @@ int QInstallerTools::createBinary(BinaryCreatorArgs args, QString &argumentError
// Note: the order here is important
PackageInfoVector packages;
+ QStringList unite7zFiles;
// 1; update the list of available compressed packages
if (!args.repositoryDirectories.isEmpty()) {
@@ -756,6 +757,14 @@ int QInstallerTools::createBinary(BinaryCreatorArgs args, QString &argumentError
&args.filteredPackages, args.ftype);
// 1.2; add to common vector
packages.append(precompressedPackages);
+ // 1.3; create list of unified metadata archives
+ foreach (const QString &dir, args.repositoryDirectories) {
+ QDirIterator it(dir, QStringList(QLatin1String("*_meta.7z")), QDir::Files | QDir::CaseSensitive);
+ while (it.hasNext()) {
+ it.next();
+ unite7zFiles.append(it.fileInfo().absoluteFilePath());
+ }
+ }
}
// 2; update the list of available prepared packages
@@ -773,7 +782,7 @@ int QInstallerTools::createBinary(BinaryCreatorArgs args, QString &argumentError
// 3; copy the meta data of the available packages, generate Updates.xml
copyMetaData(tmpMetaDir, tmpRepoDir, packages, settings
- .applicationName(), settings.version(), QStringList());
+ .applicationName(), settings.version(), unite7zFiles);
// 4; copy the configuration file and and icons etc.
copyConfigData(args.configFile, tmpMetaDir + QLatin1String("/installer-config"));
diff --git a/src/libs/ifwtools/repositorygen.cpp b/src/libs/ifwtools/repositorygen.cpp
index 5b7ec44a9..e30234f52 100644
--- a/src/libs/ifwtools/repositorygen.cpp
+++ b/src/libs/ifwtools/repositorygen.cpp
@@ -134,7 +134,6 @@ void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &met
if (!QFile::exists(targetDir))
QInstaller::mkpath(targetDir);
- bool componentMetaExtracted = false;
QDomDocument doc;
QDomElement root;
QFile existingUpdatesXml(QFileInfo(metaDataDir, QLatin1String("Updates.xml")).absoluteFilePath());
@@ -387,7 +386,6 @@ void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &met
QFile metaFile(info.metaFile);
QInstaller::openForRead(&metaFile);
Lib7z::extractArchive(&metaFile, targetDir);
- componentMetaExtracted = true;
}
// Restore "PackageUpdate" node;
@@ -400,12 +398,12 @@ void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &met
}
}
- if (!componentMetaExtracted) {
- foreach (const QString uniteMetadata, uniteMetadatas) {
- QFile metaFile(QFileInfo(metaDataDir, uniteMetadata).absoluteFilePath());
- QInstaller::openForRead(&metaFile);
- Lib7z::extractArchive(&metaFile, targetDir);
- }
+ // Packages can be in repositories using different meta formats,
+ // always extract unified meta if given as argument.
+ foreach (const QString uniteMetadata, uniteMetadatas) {
+ QFile metaFile(QFileInfo(metaDataDir, uniteMetadata).absoluteFilePath());
+ QInstaller::openForRead(&metaFile);
+ Lib7z::extractArchive(&metaFile, targetDir);
}
doc.appendChild(root);
@@ -572,6 +570,14 @@ PackageInfoVector QInstallerTools::createListOfRepositoryPackages(const QStringL
"Invalid content in \"%1\".").arg(QDir::toNativeSeparators(file.fileName())));
}
+ bool hasUnifiedMetaFile = false;
+ const QDomElement unifiedSha1 = root.firstChildElement(scSHA1);
+ const QDomElement unifiedMetaName = root.firstChildElement(QLatin1String("MetadataName"));
+
+ // Unified metadata takes priority over component metadata
+ if (!unifiedSha1.isNull() && !unifiedMetaName.isNull())
+ hasUnifiedMetaFile = true;
+
const QDomNodeList children = root.childNodes();
for (int i = 0; i < children.count(); ++i) {
const QDomElement el = children.at(i).toElement();
@@ -600,10 +606,18 @@ PackageInfoVector QInstallerTools::createListOfRepositoryPackages(const QStringL
continue;
info.directory = QString::fromLatin1("%1/%2").arg(it->filePath(), info.name);
- const QDomElement sha1 = el.firstChildElement(QInstaller::scSHA1);
- if (!sha1.isNull()) {
- info.metaFile = QString::fromLatin1("%1/%3%2").arg(info.directory,
- QString::fromLatin1("meta.7z"), info.version);
+ if (!hasUnifiedMetaFile) {
+ const QDomElement sha1 = el.firstChildElement(QInstaller::scSHA1);
+ if (!sha1.isNull()) {
+ QString metaFile = QString::fromLatin1("%1/%3%2").arg(info.directory,
+ QString::fromLatin1("meta.7z"), info.version);
+
+ if (!QFileInfo(metaFile).exists()) {
+ throw QInstaller::Error(QString::fromLatin1("Could not find meta archive for component "
+ "%1 %2 in repository %3.").arg(info.name, info.version, it->filePath()));
+ }
+ info.metaFile = metaFile;
+ }
}
const QDomNodeList c2 = el.childNodes();