summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2021-02-24 11:31:45 +0200
committerKatja Marttila <katja.marttila@qt.io>2021-03-02 10:57:35 +0200
commit92b00db08fa6b9fb8f818cdef55c7578998c8ecf (patch)
tree9a4cbecc6ebbca9e6bf6d9af408ddb6e5c87b8bf
parent4687686a64057618e58931912b8a12997fa0f1a3 (diff)
Refactor repogen for easier testingHEADmaster
Functionality is only moved from repogen.cpp to repositorygen.cpp. This makes the repository testing much easier. Change-Id: I2078e2880955c71b9ffa0ac46501eafbd499c3ba Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
-rw-r--r--src/libs/ifwtools/repositorygen.cpp64
-rw-r--r--src/libs/ifwtools/repositorygen.h11
-rw-r--r--tests/auto/tools/repotest/tst_repotest.cpp129
-rw-r--r--tools/repogen/repogen.cpp84
4 files changed, 128 insertions, 160 deletions
diff --git a/src/libs/ifwtools/repositorygen.cpp b/src/libs/ifwtools/repositorygen.cpp
index fbcf7b9f3..c269f4931 100644
--- a/src/libs/ifwtools/repositorygen.cpp
+++ b/src/libs/ifwtools/repositorygen.cpp
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -52,6 +52,9 @@
#include <iostream>
+#define QUOTE_(x) #x
+#define QUOTE(x) QUOTE_(x)
+
using namespace QInstaller;
using namespace QInstallerTools;
@@ -987,3 +990,62 @@ QString QInstallerTools::existingUniteMeta7z(const QString &repositoryDir)
}
return uniteMeta7z;
}
+
+PackageInfoVector QInstallerTools::collectPackages(RepositoryInfo info, QStringList *filteredPackages, FilterType filterType, bool updateNewComponents)
+{
+ PackageInfoVector packages;
+ PackageInfoVector precompressedPackages = QInstallerTools::createListOfRepositoryPackages(info.repositoryPackages,
+ filteredPackages, filterType);
+ packages.append(precompressedPackages);
+
+ PackageInfoVector preparedPackages = QInstallerTools::createListOfPackages(info.packages,
+ filteredPackages, filterType);
+ packages.append(preparedPackages);
+ if (updateNewComponents) {
+ filterNewComponents(info.repositoryDir, packages);
+ }
+
+ foreach (const QInstallerTools::PackageInfo &package, packages) {
+ const QFileInfo fi(info.repositoryDir, package.name);
+ if (fi.exists())
+ removeDirectory(fi.absoluteFilePath());
+ }
+
+ return packages;
+}
+
+void QInstallerTools::createRepository(RepositoryInfo info, PackageInfoVector *packages,
+ const QString &tmpMetaDir, bool createComponentMetadata, bool createUnifiedMetadata)
+{
+ QHash<QString, QString> pathToVersionMapping = QInstallerTools::buildPathToVersionMapping(*packages);
+
+ QStringList directories;
+ directories.append(info.packages);
+ directories.append(info.repositoryPackages);
+ QStringList unite7zFiles;
+ foreach (const QString &repositoryDirectory, info.repositoryPackages) {
+ QDirIterator it(repositoryDirectory, QStringList(QLatin1String("*_meta.7z"))
+ , QDir::Files | QDir::CaseSensitive);
+ while (it.hasNext()) {
+ it.next();
+ unite7zFiles.append(it.fileInfo().absoluteFilePath());
+ }
+ }
+ QInstallerTools::copyComponentData(directories, info.repositoryDir, packages);
+ QInstallerTools::copyMetaData(tmpMetaDir, info.repositoryDir, *packages, QLatin1String("{AnyApplication}"),
+ QLatin1String(QUOTE(IFW_REPOSITORY_FORMAT_VERSION)), unite7zFiles);
+
+ QString existing7z = QInstallerTools::existingUniteMeta7z(info.repositoryDir);
+ if (!existing7z.isEmpty())
+ existing7z = info.repositoryDir + QDir::separator() + existing7z;
+ QInstallerTools::compressMetaDirectories(tmpMetaDir, existing7z, pathToVersionMapping,
+ createComponentMetadata, createUnifiedMetadata);
+
+ QDirIterator it(info.repositoryDir, QStringList(QLatin1String("Updates*.xml"))
+ << QLatin1String("*_meta.7z"), QDir::Files | QDir::CaseSensitive);
+ while (it.hasNext()) {
+ it.next();
+ QFile::remove(it.fileInfo().absoluteFilePath());
+ }
+ QInstaller::moveDirectoryContents(tmpMetaDir, info.repositoryDir);
+}
diff --git a/src/libs/ifwtools/repositorygen.h b/src/libs/ifwtools/repositorygen.h
index 49d0a51dd..7204a0e13 100644
--- a/src/libs/ifwtools/repositorygen.h
+++ b/src/libs/ifwtools/repositorygen.h
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -56,6 +56,13 @@ enum IFWTOOLS_EXPORT FilterType {
Exclude
};
+struct IFWTOOLS_EXPORT RepositoryInfo
+{
+ QStringList packages;
+ QStringList repositoryPackages;
+ QString repositoryDir;
+};
+
void IFWTOOLS_EXPORT printRepositoryGenOptions();
QString IFWTOOLS_EXPORT makePathAbsolute(const QString &path);
void IFWTOOLS_EXPORT copyWithException(const QString &source, const QString &target, const QString &kind = QString());
@@ -82,6 +89,8 @@ void IFWTOOLS_EXPORT copyComponentData(const QStringList &packageDir, const QStr
void IFWTOOLS_EXPORT filterNewComponents(const QString &repositoryDir, QInstallerTools::PackageInfoVector &packages);
QString IFWTOOLS_EXPORT existingUniteMeta7z(const QString &repositoryDir);
+PackageInfoVector IFWTOOLS_EXPORT collectPackages(RepositoryInfo info, QStringList *filteredPackages, FilterType filterType, bool updateNewComponents);
+void IFWTOOLS_EXPORT createRepository(RepositoryInfo info, PackageInfoVector *packages, const QString &tmpMetaDir, bool createComponentMetadata, bool createUnifiedMetadata);
} // namespace QInstallerTools
diff --git a/tests/auto/tools/repotest/tst_repotest.cpp b/tests/auto/tools/repotest/tst_repotest.cpp
index 5aa614454..7a8542b7e 100644
--- a/tests/auto/tools/repotest/tst_repotest.cpp
+++ b/tests/auto/tools/repotest/tst_repotest.cpp
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -39,114 +39,63 @@ class tst_repotest : public QObject
{
Q_OBJECT
private:
- // TODO generateRepo() is almost direct copy from repogen.cpp.
- // Move the needed parts of repogen.cpp to a usable function for easier maintenance.
+
void generateRepo(bool createSplitMetadata, bool createUnifiedMetadata, bool updateNewComponents)
{
QStringList filteredPackages;
- QInstallerTools::FilterType filterType = QInstallerTools::Exclude;
-
- QInstallerTools::PackageInfoVector precompressedPackages = QInstallerTools::createListOfRepositoryPackages
- (m_repositoryDirectories, &filteredPackages, filterType);
- m_packages.append(precompressedPackages);
-
- QInstallerTools::PackageInfoVector preparedPackages = QInstallerTools::createListOfPackages(m_packagesDirectories,
- &filteredPackages, filterType);
- m_packages.append(preparedPackages);
- if (updateNewComponents)
- QInstallerTools::filterNewComponents(m_repositoryDir, m_packages);
- QHash<QString, QString> pathToVersionMapping = QInstallerTools::buildPathToVersionMapping(m_packages);
-
- foreach (const QInstallerTools::PackageInfo &package, m_packages) {
- const QFileInfo fi(m_repositoryDir, package.name);
- if (fi.exists())
- removeDirectory(fi.absoluteFilePath());
- }
+ QInstallerTools::PackageInfoVector m_packages = QInstallerTools::collectPackages(m_repoInfo,
+ &filteredPackages, QInstallerTools::Exclude, updateNewComponents);
if (updateNewComponents) { //Verify that component B exists as that is not updated
if (createSplitMetadata) {
- VerifyInstaller::verifyFileExistence(m_repositoryDir + "/B", QStringList() << "1.0.0content.7z"
+ VerifyInstaller::verifyFileExistence(m_repoInfo.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"
+ VerifyInstaller::verifyFileExistence(m_repoInfo.repositoryDir + "/B", QStringList() << "1.0.0content.7z"
<< "1.0.0content.7z.sha1");
}
} else {
- QDir dir(m_repositoryDir + "/B");
+ QDir dir(m_repoInfo.repositoryDir + "/B");
QVERIFY(!dir.exists());
}
- QStringList directories;
- directories.append(m_packagesDirectories);
- directories.append(m_repositoryDirectories);
-
- QStringList unite7zFiles;
- foreach (const QString &repositoryDirectory, m_repositoryDirectories) {
- QDirIterator it(repositoryDirectory, QStringList(QLatin1String("*_meta.7z"))
- , QDir::Files | QDir::CaseSensitive);
- while (it.hasNext()) {
- it.next();
- unite7zFiles.append(it.fileInfo().absoluteFilePath());
- }
- }
-
- QInstallerTools::copyComponentData(directories, m_repositoryDir, &m_packages);
- QInstallerTools::copyMetaData(m_tmpMetaDir, m_repositoryDir, m_packages, QLatin1String("{AnyApplication}"),
- QLatin1String("1.0.0"), unite7zFiles);
- 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);
- while (it.hasNext()) {
- it.next();
- QFile::remove(it.fileInfo().absoluteFilePath());
- }
- QInstaller::moveDirectoryContents(m_tmpMetaDir, m_repositoryDir);
- }
-
- void generateTempMetaDir()
- {
- if (!m_tmpMetaDir.isEmpty())
- m_tempDirDeleter.releaseAndDelete(m_tmpMetaDir);
QTemporaryDir tmp;
tmp.setAutoRemove(false);
- m_tmpMetaDir = tmp.path();
- m_tempDirDeleter.add(m_tmpMetaDir);
+ const QString tmpMetaDir = tmp.path();
+ QInstallerTools::createRepository(m_repoInfo, &m_packages, tmpMetaDir, createSplitMetadata,
+ createUnifiedMetadata);
+ QInstaller::removeDirectory(tmpMetaDir, true);
}
void clearData()
{
- generateTempMetaDir();
- m_packagesDirectories.clear();
- m_repositoryDirectories.clear();
+ m_repoInfo.packages.clear();
+ m_repoInfo.repositoryPackages.clear();
m_packages.clear();
}
void initRepoUpdate()
{
clearData();
- m_packagesDirectories << ":///packages_update";
+ m_repoInfo.packages << ":///packages_update";
}
void initRepoUpdateFromRepository(const QString &repository)
{
clearData();
- m_repositoryDirectories << repository;
+ m_repoInfo.repositoryPackages << repository;
}
void verifyUniteMetadata(const QString &scriptVersion)
{
- QString fileContent = VerifyInstaller::fileContent(m_repositoryDir + QDir::separator()
+ QString fileContent = VerifyInstaller::fileContent(m_repoInfo.repositoryDir + QDir::separator()
+ "Updates.xml");
QRegularExpression re("<MetadataName>(.*)<.MetadataName>");
QStringList matches = re.match(fileContent).capturedTexts();
- QString existingUniteMeta7z = QInstallerTools::existingUniteMeta7z(m_repositoryDir);
+ QString existingUniteMeta7z = QInstallerTools::existingUniteMeta7z(m_repoInfo.repositoryDir);
QCOMPARE(2, matches.count());
QCOMPARE(existingUniteMeta7z, matches.at(1));
- QFile file(m_repositoryDir + QDir::separator() + matches.at(1));
+ QFile file(m_repoInfo.repositoryDir + QDir::separator() + matches.at(1));
QVERIFY(file.open(QIODevice::ReadOnly));
//We have script<version>.qs for package A in the unite metadata
@@ -159,11 +108,11 @@ private:
QCOMPARE(qPrintable(fileName.arg(scriptVersion)), fileIt->path);
}
- VerifyInstaller::verifyFileExistence(m_repositoryDir, QStringList() << "Updates.xml"
+ VerifyInstaller::verifyFileExistence(m_repoInfo.repositoryDir, QStringList() << "Updates.xml"
<< matches.at(1));
- VerifyInstaller::verifyFileContent(m_repositoryDir + QDir::separator() + "Updates.xml",
+ VerifyInstaller::verifyFileContent(m_repoInfo.repositoryDir + QDir::separator() + "Updates.xml",
"SHA1");
- VerifyInstaller::verifyFileContent(m_repositoryDir + QDir::separator() + "Updates.xml",
+ VerifyInstaller::verifyFileContent(m_repoInfo.repositoryDir + QDir::separator() + "Updates.xml",
"MetadataName");
}
@@ -180,14 +129,14 @@ private:
componentA << qPrintable(meta.arg(componentAVersion));
componentB << "1.0.0meta.7z";
}
- VerifyInstaller::verifyFileExistence(m_repositoryDir + "/A", componentA);
- VerifyInstaller::verifyFileExistence(m_repositoryDir + "/B", componentB);
+ VerifyInstaller::verifyFileExistence(m_repoInfo.repositoryDir + "/A", componentA);
+ VerifyInstaller::verifyFileExistence(m_repoInfo.repositoryDir + "/B", componentB);
}
void verifyComponentMetaUpdatesXml()
{
- VerifyInstaller::verifyFileExistence(m_repositoryDir, QStringList() << "Updates.xml");
- VerifyInstaller::verifyFileHasNoContent(m_repositoryDir + QDir::separator() + "Updates.xml",
+ VerifyInstaller::verifyFileExistence(m_repoInfo.repositoryDir, QStringList() << "Updates.xml");
+ VerifyInstaller::verifyFileHasNoContent(m_repoInfo.repositoryDir + QDir::separator() + "Updates.xml",
"MetadataName");
}
@@ -216,7 +165,7 @@ private:
foreach (const QString &fileName, contentFiles) {
message = "Copying file from \":///%5/%1/%2%4\" to \"%3/%1/%2%4\"";
QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(component).arg(version)
- .arg(m_repositoryDir).arg(fileName).arg(repository)));
+ .arg(m_repoInfo.repositoryDir).arg(fileName).arg(repository)));
}
}
@@ -303,9 +252,9 @@ private:
void ignoreMessageForUpdateComponent()
{
QString message = "Update component \"A\" in \"%1\" .";
- QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(m_repositoryDir)));
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(m_repoInfo.repositoryDir)));
message = "Update component \"C\" in \"%1\" .";
- QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(m_repositoryDir)));
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(m_repoInfo.repositoryDir)));
}
private slots:
@@ -313,11 +262,10 @@ private slots:
{
ignoreMessageForCollectingPackages("1.0.0", "1.0.0");
- m_repositoryDir = QInstallerTools::makePathAbsolute(QInstaller::generateTemporaryFileName());
- m_tempDirDeleter.add(m_repositoryDir);
- generateTempMetaDir();
+ m_repoInfo.repositoryDir = QInstallerTools::makePathAbsolute(QInstaller::generateTemporaryFileName());
+ m_tempDirDeleter.add(m_repoInfo.repositoryDir);
- m_packagesDirectories << ":///packages";
+ m_repoInfo.packages << ":///packages";
ignoreMessagesForComponentHash(QStringList() << "A" << "B", false);
ignoreMessagesForCopyMetadata("A", true, false); //Only A has metadata
@@ -371,7 +319,7 @@ private slots:
ignoreMessagesForComponentHash(QStringList() << "A", true);
ignoreMessagesForCopyMetadata("A", true, true);
const QString &message = "Update component \"A\" in \"%1\" .";
- QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(m_repositoryDir)));
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(m_repoInfo.repositoryDir)));
generateRepo(true, false, true);
verifyComponentRepository("2.0.0", true);
verifyComponentMetaUpdatesXml();
@@ -458,7 +406,7 @@ private slots:
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");
+ VerifyInstaller::verifyFileExistence(m_repoInfo.repositoryDir + "/C", QStringList() << "1.0.0content.7z" << "1.0.0content.7z.sha1" << "1.0.0meta.7z");
verifyUniteMetadata("2.0.0");
}
@@ -478,23 +426,20 @@ private slots:
generateRepo(false, true, true);
verifyComponentRepository("2.0.0", false);
- VerifyInstaller::verifyFileExistence(m_repositoryDir + "/C", QStringList() << "1.0.0content.7z" << "1.0.0content.7z.sha1");
+ VerifyInstaller::verifyFileExistence(m_repoInfo.repositoryDir + "/C", QStringList() << "1.0.0content.7z" << "1.0.0content.7z.sha1");
verifyUniteMetadata("2.0.0");
}
void cleanup()
{
m_tempDirDeleter.releaseAndDeleteAll();
- m_packagesDirectories.clear();
+ m_repoInfo.packages.clear();
m_packages.clear();
- m_repositoryDirectories.clear();
+ m_repoInfo.repositoryPackages.clear();
}
private:
- QString m_tmpMetaDir;
- QString m_repositoryDir;
- QStringList m_packagesDirectories;
- QStringList m_repositoryDirectories;
+ QInstallerTools::RepositoryInfo m_repoInfo;
QInstallerTools::PackageInfoVector m_packages;
TempDirDeleter m_tempDirDeleter;
};
diff --git a/tools/repogen/repogen.cpp b/tools/repogen/repogen.cpp
index a88867e92..33cf6a3cd 100644
--- a/tools/repogen/repogen.cpp
+++ b/tools/repogen/repogen.cpp
@@ -44,8 +44,6 @@
#include <iostream>
-#define QUOTE_(x) #x
-#define QUOTE(x) QUOTE_(x)
using namespace QInstaller;
@@ -100,8 +98,7 @@ int main(int argc, char** argv)
QStringList filteredPackages;
bool updateExistingRepository = false;
- QStringList packagesDirectories;
- QStringList repositoryDirectories;
+ QInstallerTools::RepositoryInfo repoInfo;
QInstallerTools::FilterType filterType = QInstallerTools::Exclude;
bool remove = false;
bool updateExistingRepositoryWithNewComponents = false;
@@ -168,7 +165,7 @@ int main(int argc, char** argv)
"Error: Package directory is empty"));
}
- packagesDirectories.append(args.first());
+ repoInfo.packages.append(args.first());
args.removeFirst();
} else if (args.first() == QLatin1String("--repository")) {
args.removeFirst();
@@ -181,7 +178,7 @@ int main(int argc, char** argv)
return printErrorAndUsageAndExit(QCoreApplication::translate("QInstaller",
"Error: Only local filesystem repositories now supported"));
}
- repositoryDirectories.append(args.first());
+ repoInfo.repositoryPackages.append(args.first());
args.removeFirst();
} else if (args.first() == QLatin1String("--ignore-translations")
|| args.first() == QLatin1String("--ignore-invalid-packages")) {
@@ -202,7 +199,7 @@ int main(int argc, char** argv)
}
}
- if ((packagesDirectories.isEmpty() && repositoryDirectories.isEmpty()) || (args.count() != 1)) {
+ if ((repoInfo.packages.isEmpty() && repoInfo.repositoryPackages.isEmpty()) || (args.count() != 1)) {
printUsage();
return 1;
}
@@ -213,12 +210,12 @@ int main(int argc, char** argv)
"Argument -r|--remove and --update|--update-new-components are mutually exclusive!"));
}
- const QString repositoryDir = QInstallerTools::makePathAbsolute(args.first());
+ repoInfo.repositoryDir = QInstallerTools::makePathAbsolute(args.first());
if (remove)
- QInstaller::removeDirectory(repositoryDir);
+ QInstaller::removeDirectory(repoInfo.repositoryDir);
if (updateExistingRepositoryWithNewComponents) {
- QStringList meta7z = QDir(repositoryDir).entryList(QStringList()
+ QStringList meta7z = QDir(repoInfo.repositoryDir).entryList(QStringList()
<< QLatin1String("*_meta.7z"), QDir::Files);
if (!meta7z.isEmpty()) {
throw QInstaller::Error(QCoreApplication::translate("QInstaller",
@@ -228,72 +225,27 @@ int main(int argc, char** argv)
}
}
- if (!update && QFile::exists(repositoryDir) && !QDir(repositoryDir).entryList(
+ if (!update && QFile::exists(repoInfo.repositoryDir) && !QDir(repoInfo.repositoryDir).entryList(
QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty()) {
throw QInstaller::Error(QCoreApplication::translate("QInstaller",
- "Repository target directory \"%1\" already exists.").arg(QDir::toNativeSeparators(repositoryDir)));
+ "Repository target directory \"%1\" already exists.").arg(QDir::toNativeSeparators(repoInfo.repositoryDir)));
}
- QInstallerTools::PackageInfoVector packages;
-
- QInstallerTools::PackageInfoVector precompressedPackages = QInstallerTools::createListOfRepositoryPackages(repositoryDirectories,
- &filteredPackages, filterType);
- packages.append(precompressedPackages);
-
- QInstallerTools::PackageInfoVector preparedPackages = QInstallerTools::createListOfPackages(packagesDirectories,
- &filteredPackages, filterType);
- packages.append(preparedPackages);
-
- if (updateExistingRepositoryWithNewComponents) {
- QInstallerTools::filterNewComponents(repositoryDir, packages);
- if (packages.isEmpty()) {
- std::cout << QString::fromLatin1("Cannot find new components to update \"%1\".")
- .arg(repositoryDir) << std::endl;
- return EXIT_SUCCESS;
- }
- }
-
- QHash<QString, QString> pathToVersionMapping = QInstallerTools::buildPathToVersionMapping(packages);
-
- foreach (const QInstallerTools::PackageInfo &package, packages) {
- const QFileInfo fi(repositoryDir, package.name);
- if (fi.exists())
- removeDirectory(fi.absoluteFilePath());
+ QInstallerTools::PackageInfoVector packages = QInstallerTools::collectPackages(repoInfo,
+ &filteredPackages, filterType, updateExistingRepositoryWithNewComponents);
+ if (packages.isEmpty()) {
+ std::cout << QString::fromLatin1("Cannot find components to update \"%1\".")
+ .arg(repoInfo.repositoryDir) << std::endl;
+ return EXIT_SUCCESS;
}
QTemporaryDir tmp;
tmp.setAutoRemove(false);
tmpMetaDir = tmp.path();
- QStringList directories;
- directories.append(packagesDirectories);
- directories.append(repositoryDirectories);
- QStringList unite7zFiles;
- foreach (const QString &repositoryDirectory, repositoryDirectories) {
- QDirIterator it(repositoryDirectory, QStringList(QLatin1String("*_meta.7z"))
- , QDir::Files | QDir::CaseSensitive);
- while (it.hasNext()) {
- it.next();
- unite7zFiles.append(it.fileInfo().absoluteFilePath());
- }
- }
- QInstallerTools::copyComponentData(directories, repositoryDir, &packages);
- QInstallerTools::copyMetaData(tmpMetaDir, repositoryDir, packages, QLatin1String("{AnyApplication}"),
- QLatin1String(QUOTE(IFW_REPOSITORY_FORMAT_VERSION)), unite7zFiles);
-
- 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"))
- << QLatin1String("*_meta.7z"), QDir::Files | QDir::CaseSensitive);
- while (it.hasNext()) {
- it.next();
- QFile::remove(it.fileInfo().absoluteFilePath());
- }
- QInstaller::moveDirectoryContents(tmpMetaDir, repositoryDir);
+ QInstallerTools::createRepository(repoInfo, &packages, tmpMetaDir,
+ createComponentMetadata, createUnifiedMetadata);
+
exitCode = EXIT_SUCCESS;
} catch (const Lib7z::SevenZipException &e) {
std::cerr << "Caught 7zip exception: " << e.message() << std::endl;