diff options
author | Katja Marttila <katja.marttila@qt.io> | 2020-11-09 16:21:48 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2020-11-10 12:30:03 +0200 |
commit | 24ad54c694ebd93150efb6aab64ea0b63beba452 (patch) | |
tree | b537c4f53768292484d21056139452580f2405af | |
parent | a5025ddb30b6ae6423a41ac2323e1b902ae0dd8f (diff) |
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 <iikka.eklund@qt.io>
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
26 files changed, 126 insertions, 51 deletions
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 Binary files differdeleted file mode 100644 index b8e560fed..000000000 --- a/tests/auto/tools/repotest/repository_componentAndUnite/2020-10-13-0958_meta.7z +++ /dev/null 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 Binary files differnew file mode 100644 index 000000000..6a17ac028 --- /dev/null +++ b/tests/auto/tools/repotest/repository_componentAndUnite/2020-11-10-0816_meta.7z 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 Binary files differindex 46e2c9124..ef8741d32 100644 --- a/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0content.7z +++ b/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0content.7z 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 Binary files differindex 3cda3cdc4..c3cf7f7fa 100644 --- a/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0meta.7z +++ b/tests/auto/tools/repotest/repository_componentAndUnite/A/2.0.0meta.7z 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 Binary files differdeleted file mode 100644 index 46e2c9124..000000000 --- a/tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0content.7z +++ /dev/null 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 Binary files differdeleted file mode 100644 index e2867c1ee..000000000 --- a/tests/auto/tools/repotest/repository_componentAndUnite/B/1.0.0meta.7z +++ /dev/null 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 Binary files differnew file mode 100644 index 000000000..de70ee790 --- /dev/null +++ b/tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..8b389f955 --- /dev/null +++ b/tests/auto/tools/repotest/repository_componentAndUnite/C/1.0.0meta.7z 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 @@ <Updates> <ApplicationName>{AnyApplication}</ApplicationName> <ApplicationVersion>1.0.0</ApplicationVersion> - <Checksum>true</Checksum> - <SHA1>815dc9afb48774335e468956fa2e1208a239dc06</SHA1> - <MetadataName>2020-10-13-0958_meta.7z</MetadataName> + <Checksum>false</Checksum> <PackageUpdate> <Name>A</Name> <DisplayName>A</DisplayName> @@ -12,19 +10,21 @@ <ReleaseDate>2020-01-01</ReleaseDate> <Default>true</Default> <Script>script2.0.0.qs</Script> - <UpdateFile UncompressedSize="40" CompressedSize="72" OS="Any"/> + <UpdateFile OS="Any" CompressedSize="240" UncompressedSize="74"/> <DownloadableArchives>content.7z</DownloadableArchives> - <SHA1>f02d025098d76673f3a848e5d5f0421ffa5ee82d</SHA1> + <SHA1>11f74e8fbc7d6c155dd6503c460c2c1955340cc1</SHA1> </PackageUpdate> <PackageUpdate> - <Name>B</Name> - <DisplayName>B</DisplayName> - <Description>Example component B</Description> + <Name>C</Name> + <DisplayName>C</DisplayName> + <Description>Example component C</Description> <Version>1.0.0</Version> - <ReleaseDate>2020-01-01</ReleaseDate> + <ReleaseDate>2015-01-01</ReleaseDate> <Default>true</Default> - <UpdateFile UncompressedSize="40" CompressedSize="72" OS="Any"/> + <UpdateFile OS="Any" CompressedSize="239" UncompressedSize="89"/> <DownloadableArchives>content.7z</DownloadableArchives> - <SHA1>c520ba1bbde7eb1adf4b274c869a8df0a5efa5b8</SHA1> + <SHA1>4558f31428ef88eb23521b4f119465967945e2f7</SHA1> </PackageUpdate> + <SHA1>d674e6574895c02d3a02fb97a46b159d35f17c68</SHA1> + <MetadataName>2020-11-10-0816_meta.7z</MetadataName> </Updates> 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 Binary files differdeleted file mode 100644 index 4ff34ad9f..000000000 --- a/tests/auto/tools/repotest/repository_unite/2020-10-13-0958_meta.7z +++ /dev/null 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 Binary files differnew file mode 100644 index 000000000..4008dc656 --- /dev/null +++ b/tests/auto/tools/repotest/repository_unite/2020-11-10-0931_meta.7z 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 Binary files differindex 46e2c9124..ef8741d32 100644 --- a/tests/auto/tools/repotest/repository_unite/A/2.0.0content.7z +++ b/tests/auto/tools/repotest/repository_unite/A/2.0.0content.7z 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 Binary files differdeleted file mode 100644 index 46e2c9124..000000000 --- a/tests/auto/tools/repotest/repository_unite/B/1.0.0content.7z +++ /dev/null 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 Binary files differnew file mode 100644 index 000000000..de70ee790 --- /dev/null +++ b/tests/auto/tools/repotest/repository_unite/C/1.0.0content.7z 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 @@ <Updates> <ApplicationName>{AnyApplication}</ApplicationName> <ApplicationVersion>1.0.0</ApplicationVersion> - <Checksum>true</Checksum> - <SHA1>4a494d033d3092b392ba775b17a7e4776ccf4777</SHA1> - <MetadataName>2020-10-13-0958_meta.7z</MetadataName> + <Checksum>false</Checksum> <PackageUpdate> <Name>A</Name> <DisplayName>A</DisplayName> @@ -12,17 +10,19 @@ <ReleaseDate>2020-01-01</ReleaseDate> <Default>true</Default> <Script>script2.0.0.qs</Script> - <UpdateFile UncompressedSize="40" CompressedSize="72" OS="Any"/> + <UpdateFile CompressedSize="240" UncompressedSize="74" OS="Any"/> <DownloadableArchives>content.7z</DownloadableArchives> </PackageUpdate> <PackageUpdate> - <Name>B</Name> - <DisplayName>B</DisplayName> - <Description>Example component B</Description> + <Name>C</Name> + <DisplayName>C</DisplayName> + <Description>Example component C</Description> <Version>1.0.0</Version> - <ReleaseDate>2020-01-01</ReleaseDate> + <ReleaseDate>2015-01-01</ReleaseDate> <Default>true</Default> - <UpdateFile UncompressedSize="40" CompressedSize="72" OS="Any"/> + <UpdateFile CompressedSize="239" UncompressedSize="89" OS="Any"/> <DownloadableArchives>content.7z</DownloadableArchives> </PackageUpdate> + <SHA1>3b46ef65a751d9498205412fc22de43ce29e5d8a</SHA1> + <MetadataName>2020-11-10-0931_meta.7z</MetadataName> </Updates> 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 @@ <file>repository_componentAndUnite/A/2.0.0content.7z</file> <file>repository_componentAndUnite/A/2.0.0content.7z.sha1</file> <file>repository_componentAndUnite/A/2.0.0meta.7z</file> - <file>repository_componentAndUnite/B/1.0.0content.7z</file> - <file>repository_componentAndUnite/B/1.0.0content.7z.sha1</file> - <file>repository_componentAndUnite/B/1.0.0meta.7z</file> - <file>repository_componentAndUnite/2020-10-13-0958_meta.7z</file> + <file>repository_componentAndUnite/C/1.0.0content.7z</file> + <file>repository_componentAndUnite/C/1.0.0content.7z.sha1</file> + <file>repository_componentAndUnite/C/1.0.0meta.7z</file> + <file>repository_componentAndUnite/2020-11-10-0816_meta.7z</file> <file>repository_componentAndUnite/Updates.xml</file> <file>repository_unite/A/2.0.0content.7z</file> <file>repository_unite/A/2.0.0content.7z.sha1</file> - <file>repository_unite/B/1.0.0content.7z</file> - <file>repository_unite/B/1.0.0content.7z.sha1</file> - <file>repository_unite/2020-10-13-0958_meta.7z</file> + <file>repository_unite/C/1.0.0content.7z</file> + <file>repository_unite/C/1.0.0content.7z.sha1</file> + <file>repository_unite/2020-11-10-0931_meta.7z</file> <file>repository_unite/Updates.xml</file> </qresource> </RCC> 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>(.*)<.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 <QtCore/QRegExp> #include <QtXml/QDomDocument> +#include <QTemporaryDir> #include <iostream> @@ -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<QString, QString> &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<QString, QString> &versionMapping) + QDomDocument doc, const QHash<QString, QString> &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<QString, QString> buildPathToVersionMapping(const PackageInfoVector &info); -void compressMetaDirectories(const QString &repoDir, const QString &baseDir, +void compressMetaDirectories(const QString &repoDir, const QString &existingUnite7zUrl, const QHash<QString, QString> &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<QString, QString> &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")) |