From 24ad54c694ebd93150efb6aab64ea0b63beba452 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Mon, 9 Nov 2020 16:21:48 +0200 Subject: Repogen: Fix unite metadata when --repository switch used United metadata 7z was missing the component which had no update available. Task-number: QTIFW-2018 Change-Id: I069fd852499f157075bf28e3ccfef3e42e5f30a9 Reviewed-by: Iikka Eklund Reviewed-by: Arttu Tarkiainen --- .../2020-10-13-0958_meta.7z | Bin 217 -> 0 bytes .../2020-11-10-0816_meta.7z | Bin 0 -> 218 bytes .../repository_componentAndUnite/A/2.0.0content.7z | Bin 32 -> 200 bytes .../A/2.0.0content.7z.sha1 | 2 +- .../repository_componentAndUnite/A/2.0.0meta.7z | Bin 210 -> 215 bytes .../repository_componentAndUnite/B/1.0.0content.7z | Bin 32 -> 0 bytes .../B/1.0.0content.7z.sha1 | 1 - .../repository_componentAndUnite/B/1.0.0meta.7z | Bin 106 -> 0 bytes .../repository_componentAndUnite/C/1.0.0content.7z | Bin 0 -> 199 bytes .../C/1.0.0content.7z.sha1 | 1 + .../repository_componentAndUnite/C/1.0.0meta.7z | Bin 0 -> 106 bytes .../repository_componentAndUnite/Updates.xml | 22 ++++---- .../repository_unite/2020-10-13-0958_meta.7z | Bin 217 -> 0 bytes .../repository_unite/2020-11-10-0931_meta.7z | Bin 0 -> 217 bytes .../repotest/repository_unite/A/2.0.0content.7z | Bin 32 -> 200 bytes .../repository_unite/A/2.0.0content.7z.sha1 | 2 +- .../repotest/repository_unite/B/1.0.0content.7z | Bin 32 -> 0 bytes .../repository_unite/B/1.0.0content.7z.sha1 | 1 - .../repotest/repository_unite/C/1.0.0content.7z | Bin 0 -> 199 bytes .../repository_unite/C/1.0.0content.7z.sha1 | 1 + .../tools/repotest/repository_unite/Updates.xml | 18 +++---- tests/auto/tools/repotest/settings.qrc | 14 ++--- tests/auto/tools/repotest/tst_repotest.cpp | 45 ++++++++++++---- tools/common/repositorygen.cpp | 57 ++++++++++++++++++--- tools/common/repositorygen.h | 7 +-- tools/repogen/repogen.cpp | 6 ++- 26 files changed, 126 insertions(+), 51 deletions(-) delete mode 100644 tests/auto/tools/repotest/repository_componentAndUnite/2020-10-13-0958_meta.7z create mode 100644 tests/auto/tools/repotest/repository_componentAndUnite/2020-11-10-0816_meta.7z delete mode 100644 tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0content.7z delete mode 100644 tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0content.7z.sha1 delete mode 100644 tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0meta.7z create mode 100644 tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0content.7z create mode 100644 tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0content.7z.sha1 create mode 100644 tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0meta.7z delete mode 100644 tests/auto/tools/repotest/repository_unite/2020-10-13-0958_meta.7z create mode 100644 tests/auto/tools/repotest/repository_unite/2020-11-10-0931_meta.7z delete mode 100644 tests/auto/tools/repotest/repository_unite/B/1.0.0content.7z delete mode 100644 tests/auto/tools/repotest/repository_unite/B/1.0.0content.7z.sha1 create mode 100644 tests/auto/tools/repotest/repository_unite/C/1.0.0content.7z create mode 100644 tests/auto/tools/repotest/repository_unite/C/1.0.0content.7z.sha1 diff --git a/tests/auto/tools/repotest/repository_componentAndUnite/2020-10-13-0958_meta.7z b/tests/auto/tools/repotest/repository_componentAndUnite/2020-10-13-0958_meta.7z deleted file mode 100644 index b8e560fed..000000000 Binary files a/tests/auto/tools/repotest/repository_componentAndUnite/2020-10-13-0958_meta.7z and /dev/null differ diff --git a/tests/auto/tools/repotest/repository_componentAndUnite/2020-11-10-0816_meta.7z b/tests/auto/tools/repotest/repository_componentAndUnite/2020-11-10-0816_meta.7z new file mode 100644 index 000000000..6a17ac028 Binary files /dev/null and b/tests/auto/tools/repotest/repository_componentAndUnite/2020-11-10-0816_meta.7z differ diff --git a/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0content.7z b/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0content.7z index 46e2c9124..ef8741d32 100644 Binary files a/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0content.7z and b/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0content.7z differ diff --git a/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0content.7z.sha1 b/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0content.7z.sha1 index 53010cea2..d5e23fd53 100644 --- a/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0content.7z.sha1 +++ b/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0content.7z.sha1 @@ -1 +1 @@ -059e5ed8cd3a1fbca08cccfa4075265192603e3f \ No newline at end of file +c7cca768ebfe60c4295a79762d4e19e63f2c21d2 \ No newline at end of file diff --git a/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0meta.7z b/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0meta.7z index 3cda3cdc4..c3cf7f7fa 100644 Binary files a/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0meta.7z and b/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0meta.7z differ diff --git a/tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0content.7z b/tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0content.7z deleted file mode 100644 index 46e2c9124..000000000 Binary files a/tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0content.7z.sha1 b/tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0content.7z.sha1 deleted file mode 100644 index 53010cea2..000000000 --- a/tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0content.7z.sha1 +++ /dev/null @@ -1 +0,0 @@ -059e5ed8cd3a1fbca08cccfa4075265192603e3f \ No newline at end of file diff --git a/tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0meta.7z b/tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0meta.7z deleted file mode 100644 index e2867c1ee..000000000 Binary files a/tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0meta.7z and /dev/null differ diff --git a/tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0content.7z b/tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0content.7z new file mode 100644 index 000000000..de70ee790 Binary files /dev/null and b/tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0content.7z differ diff --git a/tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0content.7z.sha1 b/tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0content.7z.sha1 new file mode 100644 index 000000000..c290ccf6c --- /dev/null +++ b/tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0content.7z.sha1 @@ -0,0 +1 @@ +0e995c11dc35bd2b4ac04d408eb7091f8322ea49 \ No newline at end of file diff --git a/tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0meta.7z b/tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0meta.7z new file mode 100644 index 000000000..8b389f955 Binary files /dev/null and b/tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0meta.7z differ diff --git a/tests/auto/tools/repotest/repository_componentAndUnite/Updates.xml b/tests/auto/tools/repotest/repository_componentAndUnite/Updates.xml index 653c0e91e..802f0a53e 100644 --- a/tests/auto/tools/repotest/repository_componentAndUnite/Updates.xml +++ b/tests/auto/tools/repotest/repository_componentAndUnite/Updates.xml @@ -1,9 +1,7 @@ {AnyApplication} 1.0.0 - true - 815dc9afb48774335e468956fa2e1208a239dc06 - 2020-10-13-0958_meta.7z + false A A @@ -12,19 +10,21 @@ 2020-01-01 true - + content.7z - f02d025098d76673f3a848e5d5f0421ffa5ee82d + 11f74e8fbc7d6c155dd6503c460c2c1955340cc1 - B - B - Example component B + C + C + Example component C 1.0.0 - 2020-01-01 + 2015-01-01 true - + content.7z - c520ba1bbde7eb1adf4b274c869a8df0a5efa5b8 + 4558f31428ef88eb23521b4f119465967945e2f7 + d674e6574895c02d3a02fb97a46b159d35f17c68 + 2020-11-10-0816_meta.7z diff --git a/tests/auto/tools/repotest/repository_unite/2020-10-13-0958_meta.7z b/tests/auto/tools/repotest/repository_unite/2020-10-13-0958_meta.7z deleted file mode 100644 index 4ff34ad9f..000000000 Binary files a/tests/auto/tools/repotest/repository_unite/2020-10-13-0958_meta.7z and /dev/null differ diff --git a/tests/auto/tools/repotest/repository_unite/2020-11-10-0931_meta.7z b/tests/auto/tools/repotest/repository_unite/2020-11-10-0931_meta.7z new file mode 100644 index 000000000..4008dc656 Binary files /dev/null and b/tests/auto/tools/repotest/repository_unite/2020-11-10-0931_meta.7z differ diff --git a/tests/auto/tools/repotest/repository_unite/A/2.0.0content.7z b/tests/auto/tools/repotest/repository_unite/A/2.0.0content.7z index 46e2c9124..ef8741d32 100644 Binary files a/tests/auto/tools/repotest/repository_unite/A/2.0.0content.7z and b/tests/auto/tools/repotest/repository_unite/A/2.0.0content.7z differ diff --git a/tests/auto/tools/repotest/repository_unite/A/2.0.0content.7z.sha1 b/tests/auto/tools/repotest/repository_unite/A/2.0.0content.7z.sha1 index 53010cea2..d5e23fd53 100644 --- a/tests/auto/tools/repotest/repository_unite/A/2.0.0content.7z.sha1 +++ b/tests/auto/tools/repotest/repository_unite/A/2.0.0content.7z.sha1 @@ -1 +1 @@ -059e5ed8cd3a1fbca08cccfa4075265192603e3f \ No newline at end of file +c7cca768ebfe60c4295a79762d4e19e63f2c21d2 \ No newline at end of file diff --git a/tests/auto/tools/repotest/repository_unite/B/1.0.0content.7z b/tests/auto/tools/repotest/repository_unite/B/1.0.0content.7z deleted file mode 100644 index 46e2c9124..000000000 Binary files a/tests/auto/tools/repotest/repository_unite/B/1.0.0content.7z and /dev/null differ diff --git a/tests/auto/tools/repotest/repository_unite/B/1.0.0content.7z.sha1 b/tests/auto/tools/repotest/repository_unite/B/1.0.0content.7z.sha1 deleted file mode 100644 index 53010cea2..000000000 --- a/tests/auto/tools/repotest/repository_unite/B/1.0.0content.7z.sha1 +++ /dev/null @@ -1 +0,0 @@ -059e5ed8cd3a1fbca08cccfa4075265192603e3f \ No newline at end of file diff --git a/tests/auto/tools/repotest/repository_unite/C/1.0.0content.7z b/tests/auto/tools/repotest/repository_unite/C/1.0.0content.7z new file mode 100644 index 000000000..de70ee790 Binary files /dev/null and b/tests/auto/tools/repotest/repository_unite/C/1.0.0content.7z differ diff --git a/tests/auto/tools/repotest/repository_unite/C/1.0.0content.7z.sha1 b/tests/auto/tools/repotest/repository_unite/C/1.0.0content.7z.sha1 new file mode 100644 index 000000000..c290ccf6c --- /dev/null +++ b/tests/auto/tools/repotest/repository_unite/C/1.0.0content.7z.sha1 @@ -0,0 +1 @@ +0e995c11dc35bd2b4ac04d408eb7091f8322ea49 \ No newline at end of file diff --git a/tests/auto/tools/repotest/repository_unite/Updates.xml b/tests/auto/tools/repotest/repository_unite/Updates.xml index c9bcc93cd..0b0a8987b 100644 --- a/tests/auto/tools/repotest/repository_unite/Updates.xml +++ b/tests/auto/tools/repotest/repository_unite/Updates.xml @@ -1,9 +1,7 @@ {AnyApplication} 1.0.0 - true - 4a494d033d3092b392ba775b17a7e4776ccf4777 - 2020-10-13-0958_meta.7z + false A A @@ -12,17 +10,19 @@ 2020-01-01 true - + content.7z - B - B - Example component B + C + C + Example component C 1.0.0 - 2020-01-01 + 2015-01-01 true - + content.7z + 3b46ef65a751d9498205412fc22de43ce29e5d8a + 2020-11-10-0931_meta.7z diff --git a/tests/auto/tools/repotest/settings.qrc b/tests/auto/tools/repotest/settings.qrc index 77d250b20..e731af222 100644 --- a/tests/auto/tools/repotest/settings.qrc +++ b/tests/auto/tools/repotest/settings.qrc @@ -20,16 +20,16 @@ repository_componentAndUnite/A/2.0.0content.7z repository_componentAndUnite/A/2.0.0content.7z.sha1 repository_componentAndUnite/A/2.0.0meta.7z - repository_componentAndUnite/B/1.0.0content.7z - repository_componentAndUnite/B/1.0.0content.7z.sha1 - repository_componentAndUnite/B/1.0.0meta.7z - repository_componentAndUnite/2020-10-13-0958_meta.7z + repository_componentAndUnite/C/1.0.0content.7z + repository_componentAndUnite/C/1.0.0content.7z.sha1 + repository_componentAndUnite/C/1.0.0meta.7z + repository_componentAndUnite/2020-11-10-0816_meta.7z repository_componentAndUnite/Updates.xml repository_unite/A/2.0.0content.7z repository_unite/A/2.0.0content.7z.sha1 - repository_unite/B/1.0.0content.7z - repository_unite/B/1.0.0content.7z.sha1 - repository_unite/2020-10-13-0958_meta.7z + repository_unite/C/1.0.0content.7z + repository_unite/C/1.0.0content.7z.sha1 + repository_unite/2020-11-10-0931_meta.7z repository_unite/Updates.xml diff --git a/tests/auto/tools/repotest/tst_repotest.cpp b/tests/auto/tools/repotest/tst_repotest.cpp index 2f5ca2cbb..5aa614454 100644 --- a/tests/auto/tools/repotest/tst_repotest.cpp +++ b/tests/auto/tools/repotest/tst_repotest.cpp @@ -65,8 +65,13 @@ private: } if (updateNewComponents) { //Verify that component B exists as that is not updated - VerifyInstaller::verifyFileExistence(m_repositoryDir + "/B", QStringList() << "1.0.0content.7z" - << "1.0.0content.7z.sha1" << "1.0.0meta.7z"); + if (createSplitMetadata) { + VerifyInstaller::verifyFileExistence(m_repositoryDir + "/B", QStringList() << "1.0.0content.7z" + << "1.0.0content.7z.sha1" << "1.0.0meta.7z"); + } else { + VerifyInstaller::verifyFileExistence(m_repositoryDir + "/B", QStringList() << "1.0.0content.7z" + << "1.0.0content.7z.sha1"); + } } else { QDir dir(m_repositoryDir + "/B"); QVERIFY(!dir.exists()); @@ -88,7 +93,10 @@ private: QInstallerTools::copyComponentData(directories, m_repositoryDir, &m_packages); QInstallerTools::copyMetaData(m_tmpMetaDir, m_repositoryDir, m_packages, QLatin1String("{AnyApplication}"), QLatin1String("1.0.0"), unite7zFiles); - QInstallerTools::compressMetaDirectories(m_tmpMetaDir, m_tmpMetaDir, pathToVersionMapping, + QString existing7z = QInstallerTools::existingUniteMeta7z(m_repositoryDir); + if (!existing7z.isEmpty()) + existing7z = m_repositoryDir + QDir::separator() + existing7z; + QInstallerTools::compressMetaDirectories(m_tmpMetaDir, existing7z, pathToVersionMapping, createSplitMetadata, createUnifiedMetadata); QDirIterator it(m_repositoryDir, QStringList(QLatin1String("Updates*.xml")) << QLatin1String("*_meta.7z"), QDir::Files | QDir::CaseSensitive); @@ -135,7 +143,9 @@ private: + "Updates.xml"); QRegularExpression re("(.*)<.MetadataName>"); QStringList matches = re.match(fileContent).capturedTexts(); + QString existingUniteMeta7z = QInstallerTools::existingUniteMeta7z(m_repositoryDir); QCOMPARE(2, matches.count()); + QCOMPARE(existingUniteMeta7z, matches.at(1)); QFile file(m_repositoryDir + QDir::separator() + matches.at(1)); QVERIFY(file.open(QIODevice::ReadOnly)); @@ -217,7 +227,6 @@ private: QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(repository))); QTest::ignoreMessage(QtDebugMsg, "Collecting information about available packages..."); QTest::ignoreMessage(QtDebugMsg, "No available packages found at the specified location."); - QTest::ignoreMessage(QtDebugMsg, "- it provides the package \"B\" - \"1.0.0\""); QTest::ignoreMessage(QtDebugMsg, "- it provides the package \"A\" - \"2.0.0\""); } @@ -291,6 +300,14 @@ private: ignoreMessagesForCopyMetadata("B", false, true); } + void ignoreMessageForUpdateComponent() + { + QString message = "Update component \"A\" in \"%1\" ."; + QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(m_repositoryDir))); + message = "Update component \"C\" in \"%1\" ."; + QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(m_repositoryDir))); + } + private slots: void init() { @@ -413,6 +430,8 @@ private slots: initRepoUpdateFromRepository(":///repository_component"); ignoreMessageForCollectingRepository("repository_component"); + QTest::ignoreMessage(QtDebugMsg, "- it provides the package \"B\" - \"1.0.0\""); + ignoreMessagesForCopyRepository("B", "1.0.0", "repository_component"); ignoreMessagesForCopyRepository("A", "2.0.0", "repository_component"); ignoreMessagesForComponentSha(QStringList() << "A" << "B", true); @@ -430,12 +449,16 @@ private slots: initRepoUpdateFromRepository(":///repository_componentAndUnite"); ignoreMessageForCollectingRepository("repository_componentAndUnite"); + QTest::ignoreMessage(QtDebugMsg, "- it provides the package \"C\" - \"1.0.0\""); + ignoreMessageForUpdateComponent(); ignoreMessagesForCopyRepository("A", "2.0.0", "repository_componentAndUnite"); - ignoreMessagesForCopyRepository("B", "1.0.0", "repository_componentAndUnite"); + ignoreMessagesForCopyRepository("C", "1.0.0", "repository_componentAndUnite"); ignoreMessagesForUniteMeta(true); - ignoreMessagesForComponentSha(QStringList() << "A" << "B", true); - generateRepo(true, true, false); + ignoreMessagesForComponentSha(QStringList() << "A" << "C", true); + + generateRepo(true, true, true); verifyComponentRepository("2.0.0", true); + VerifyInstaller::verifyFileExistence(m_repositoryDir + "/C", QStringList() << "1.0.0content.7z" << "1.0.0content.7z.sha1" << "1.0.0meta.7z"); verifyUniteMetadata("2.0.0"); } @@ -447,11 +470,15 @@ private slots: initRepoUpdateFromRepository(":///repository_unite"); ignoreMessageForCollectingRepository("repository_unite"); + QTest::ignoreMessage(QtDebugMsg, "- it provides the package \"C\" - \"1.0.0\""); + ignoreMessageForUpdateComponent(); ignoreMessagesForCopyRepository("A", "2.0.0", "repository_unite"); - ignoreMessagesForCopyRepository("B", "1.0.0", "repository_unite"); + ignoreMessagesForCopyRepository("C", "1.0.0", "repository_unite"); ignoreMessagesForUniteMeta(true); - generateRepo(false, true, false); + + generateRepo(false, true, true); verifyComponentRepository("2.0.0", false); + VerifyInstaller::verifyFileExistence(m_repositoryDir + "/C", QStringList() << "1.0.0content.7z" << "1.0.0content.7z.sha1"); verifyUniteMetadata("2.0.0"); } diff --git a/tools/common/repositorygen.cpp b/tools/common/repositorygen.cpp index 6f17ad5ac..94d1638eb 100644 --- a/tools/common/repositorygen.cpp +++ b/tools/common/repositorygen.cpp @@ -47,6 +47,7 @@ #include #include +#include #include @@ -678,7 +679,7 @@ static void writeSHA1ToNodeWithName(QDomDocument &doc, QDomNodeList &list, const } } -void QInstallerTools::compressMetaDirectories(const QString &repoDir, const QString &baseDir, +void QInstallerTools::compressMetaDirectories(const QString &repoDir, const QString &existingUnite7zUrl, const QHash &versionMapping, bool createSplitMetadata, bool createUnifiedMetadata) { QDomDocument doc; @@ -697,10 +698,11 @@ void QInstallerTools::compressMetaDirectories(const QString &repoDir, const QStr QStringList absPaths; if (createUnifiedMetadata) { - absPaths = unifyMetadata(entryList, repoDir, doc); + absPaths = unifyMetadata(repoDir, existingUnite7zUrl, doc); } + if (createSplitMetadata) { - splitMetadata(entryList, repoDir, doc, baseDir, versionMapping); + splitMetadata(entryList, repoDir, doc, versionMapping); } else { // remove the files that got compressed foreach (const QString path, absPaths) @@ -712,10 +714,12 @@ void QInstallerTools::compressMetaDirectories(const QString &repoDir, const QStr existingUpdatesXml.close(); } -QStringList QInstallerTools::unifyMetadata(const QStringList &entryList, const QString &repoDir, QDomDocument doc) +QStringList QInstallerTools::unifyMetadata(const QString &repoDir, const QString &existingRepoDir, QDomDocument doc) { QStringList absPaths; QDir dir(repoDir); + const QStringList entryList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + foreach (const QString &i, entryList) { dir.cd(i); const QString absPath = dir.absolutePath(); @@ -723,6 +727,26 @@ QStringList QInstallerTools::unifyMetadata(const QStringList &entryList, const Q dir.cdUp(); } + QTemporaryDir existingRepoTempDir; + QString existingRepoTemp = existingRepoTempDir.path(); + if (!existingRepoDir.isEmpty()) { + existingRepoTempDir.setAutoRemove(false); + QFile archiveFile(existingRepoDir); + QInstaller::openForRead(&archiveFile); + Lib7z::extractArchive(&archiveFile, existingRepoTemp); + QDir dir(existingRepoTemp); + QStringList existingRepoEntries = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + foreach (const QString existingRepoEntry, existingRepoEntries) { + if (entryList.contains(existingRepoEntry)) { + continue; + } else { + dir.cd(existingRepoEntry); + const QString absPath = dir.absolutePath(); + absPaths.append(absPath); + } + } + } + // Compress all metadata from repository to one single 7z const QString metadataFilename = QDateTime::currentDateTime(). toString(QLatin1String("yyyy-MM-dd-hhmm")) + QLatin1String("_meta.7z"); @@ -749,12 +773,12 @@ QStringList QInstallerTools::unifyMetadata(const QStringList &entryList, const Q else node.replaceChild(newNodeTag, nameTag); } + QInstaller::removeDirectory(existingRepoTemp, true); return absPaths; } void QInstallerTools::splitMetadata(const QStringList &entryList, const QString &repoDir, - QDomDocument doc, const QString &baseDir, - const QHash &versionMapping) + QDomDocument doc, const QHash &versionMapping) { QStringList absPaths; QDomNodeList elements = doc.elementsByTagName(QLatin1String("PackageUpdate")); @@ -762,7 +786,7 @@ void QInstallerTools::splitMetadata(const QStringList &entryList, const QString foreach (const QString &i, entryList) { dir.cd(i); const QString absPath = dir.absolutePath(); - const QString path = QString(i).remove(baseDir); + const QString path = QString(i).remove(repoDir); if (path.isNull()) continue; const QString versionPrefix = versionMapping[path]; @@ -924,3 +948,22 @@ void QInstallerTools::filterNewComponents(const QString &repositoryDir, QInstall } } } + +QString QInstallerTools::existingUniteMeta7z(const QString &repositoryDir) +{ + QString uniteMeta7z = QString(); + QFile file(repositoryDir + QLatin1String("/Updates.xml")); + QDomDocument doc; + if (file.open(QFile::ReadOnly) && doc.setContent(&file)) { + QDomNodeList elements = doc.elementsByTagName(QLatin1String("MetadataName")); + if (elements.count() > 0 && elements.at(0).isElement()) { + uniteMeta7z = elements.at(0).toElement().text(); + QFile metaFile(repositoryDir + QDir::separator() + uniteMeta7z); + if (!metaFile.exists()) { + throw QInstaller::Error(QString::fromLatin1("Unite meta7z \"%1\" does not exist in repository \"%2\"") + .arg(QDir::toNativeSeparators(metaFile.fileName()), repositoryDir)); + } + } + } + return uniteMeta7z; +} diff --git a/tools/common/repositorygen.h b/tools/common/repositorygen.h index eb2d23275..f5202c1fc 100644 --- a/tools/common/repositorygen.h +++ b/tools/common/repositorygen.h @@ -67,11 +67,11 @@ PackageInfoVector createListOfRepositoryPackages(const QStringList &repositoryDi QHash buildPathToVersionMapping(const PackageInfoVector &info); -void compressMetaDirectories(const QString &repoDir, const QString &baseDir, +void compressMetaDirectories(const QString &repoDir, const QString &existingUnite7zUrl, const QHash &versionMapping, bool createSplitMetadata, bool createUnifiedMetadata); -QStringList unifyMetadata(const QStringList &entryList, const QString &repoDir, QDomDocument doc); -void splitMetadata(const QStringList &entryList, const QString &repoDir, QDomDocument doc, const QString &baseDir, +QStringList unifyMetadata(const QString &repoDir, const QString &existingRepoDir, QDomDocument doc); +void splitMetadata(const QStringList &entryList, const QString &repoDir, QDomDocument doc, const QHash &versionMapping); void copyMetaData(const QString &outDir, const QString &dataDir, const PackageInfoVector &packages, @@ -80,6 +80,7 @@ void copyComponentData(const QStringList &packageDir, const QString &repoDir, Pa void filterNewComponents(const QString &repositoryDir, QInstallerTools::PackageInfoVector &packages); +QString existingUniteMeta7z(const QString &repositoryDir); } // namespace QInstallerTools diff --git a/tools/repogen/repogen.cpp b/tools/repogen/repogen.cpp index 76d4f676a..5c67cbc1c 100644 --- a/tools/repogen/repogen.cpp +++ b/tools/repogen/repogen.cpp @@ -279,7 +279,11 @@ int main(int argc, char** argv) QInstallerTools::copyComponentData(directories, repositoryDir, &packages); QInstallerTools::copyMetaData(tmpMetaDir, repositoryDir, packages, QLatin1String("{AnyApplication}"), QLatin1String(QUOTE(IFW_REPOSITORY_FORMAT_VERSION)), unite7zFiles); - QInstallerTools::compressMetaDirectories(tmpMetaDir, tmpMetaDir, pathToVersionMapping, + + QString existing7z = QInstallerTools::existingUniteMeta7z(repositoryDir); + if (!existing7z.isEmpty()) + existing7z = repositoryDir + QDir::separator() + existing7z; + QInstallerTools::compressMetaDirectories(tmpMetaDir, existing7z, pathToVersionMapping, createComponentMetadata, createUnifiedMetadata); QDirIterator it(repositoryDir, QStringList(QLatin1String("Updates*.xml")) -- cgit v1.2.3