summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/binarycreator/binarycreator.cpp196
-rw-r--r--tools/common/repositorygen.cpp404
-rw-r--r--tools/common/repositorygen.h18
-rw-r--r--tools/repogen/repogen.cpp40
-rw-r--r--tools/repogenfromonlinerepo/downloadmanager.h2
-rw-r--r--tools/repogenfromonlinerepo/main.cpp4
6 files changed, 290 insertions, 374 deletions
diff --git a/tools/binarycreator/binarycreator.cpp b/tools/binarycreator/binarycreator.cpp
index 594686e61..80c083208 100644
--- a/tools/binarycreator/binarycreator.cpp
+++ b/tools/binarycreator/binarycreator.cpp
@@ -46,6 +46,7 @@
#include <errors.h>
#include <fileutils.h>
#include <init.h>
+#include <repository.h>
#include <settings.h>
#include <utils.h>
@@ -113,15 +114,8 @@ static void chmod755(const QString &absolutFilePath)
}
#endif
-static int assemble(Input input, const QString &configFile)
+static int assemble(Input input, const QInstaller::Settings &settings)
{
- const QString configDir = QFileInfo(configFile).canonicalPath();
- const QInstaller::Settings &settings = QInstaller::Settings::fromFileAndPrefix(configFile, configDir);
-
-#ifdef Q_OS_LINUX
-Q_UNUSED(settings)
-#endif
-
#ifdef Q_OS_MAC
if (QFileInfo(input.installerExePath).isBundle()) {
const QString bundle = input.installerExePath;
@@ -154,8 +148,14 @@ Q_UNUSED(settings)
pkgInfoStream << QLatin1String("APPL????") << endl;
}
- const QString iconFile = QFile::exists(settings.icon()) ? settings.icon()
- : QString::fromLatin1(":/resources/default_icon_mac.icns");
+ QString iconFile;
+ if (QFile::exists(settings.installerApplicationIcon())) {
+ iconFile = settings.installerApplicationIcon();
+ } else {
+ iconFile = QFile::exists(settings.icon()) ? settings.icon()
+ : QString::fromLatin1(":/resources/default_icon_mac.icns");
+ }
+
const QString iconTargetFile = fi.completeBaseName() + QLatin1String(".icns");
QFile::copy(iconFile, fi.filePath() + QLatin1String("/Contents/Resources/") + iconTargetFile);
@@ -175,7 +175,10 @@ Q_UNUSED(settings)
plistStream << QLatin1String(" <key>CFBundleGetInfoString</key>") << endl;
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
- plistStream << QLatin1String(" <string>") << QLatin1String(QUOTE(IFW_VERSION)) << ("</string>") << endl;
+ plistStream << QLatin1String(" <string>") << QLatin1String(QUOTE(IFW_VERSION)) << ("</string>")
+ << endl;
+#undef QUOTE
+#undef QUOTE_
plistStream << QLatin1String(" <key>CFBundleSignature</key>") << endl;
plistStream << QLatin1String(" <string> ???? </string>") << endl;
plistStream << QLatin1String(" <key>CFBundleExecutable</key>") << endl;
@@ -192,6 +195,8 @@ Q_UNUSED(settings)
input.outputPath = QString::fromLatin1("%1/Contents/MacOS/%2").arg(input.outputPath)
.arg(fi.completeBaseName());
}
+#elif defined(Q_OS_LINUX)
+ Q_UNUSED(settings)
#endif
QTemporaryFile file(input.outputPath);
@@ -218,9 +223,13 @@ Q_UNUSED(settings)
#if defined(Q_OS_WIN)
// setting the windows icon must happen before we append our binary data - otherwise they get lost :-/
- if (QFile::exists(settings.icon())) {
+ if (QFile::exists(settings.installerApplicationIcon())) {
// no error handling as this is not fatal
- setApplicationIcon(tempFile, settings.icon());
+ setApplicationIcon(tempFile, settings.installerApplicationIcon());
+ } else {
+ if (QFile::exists(settings.icon())) {
+ setApplicationIcon(tempFile, settings.icon());
+ }
}
#elif defined(Q_OS_MAC)
if (isBundle) {
@@ -311,14 +320,14 @@ Q_UNUSED(settings)
} catch (const Error &e) {
qCritical("Error occurred while assembling the installer: %s", qPrintable(e.message()));
QFile::remove(tempFile);
- return 1;
+ return EXIT_FAILURE;
}
if (!out.commit(KDSaveFile::OverwriteExistingFile)) {
qCritical("Could not write installer to %s: %s", qPrintable(out.fileName()),
qPrintable(out.errorString()));
QFile::remove(tempFile);
- return 1;
+ return EXIT_FAILURE;
}
#ifndef Q_OS_WIN
chmod755(out.fileName());
@@ -342,7 +351,7 @@ Q_UNUSED(settings)
qDebug() << "done." << mkdmgscript;
}
#endif
- return 0;
+ return EXIT_SUCCESS;
}
QT_BEGIN_NAMESPACE
@@ -469,90 +478,67 @@ static void printUsage()
std::cout << std::endl;
}
-static QString createMetaDataDirectory(const QInstallerTools::PackageInfoVector &packages,
- const QString &packagesDir, const QString &configFile)
+void copyConfigData(const QString &configFile, const QString &targetDir)
{
- const QInstaller::Settings &settings = QInstaller::Settings::fromFileAndPrefix(configFile, QString());
+ qDebug() << "Begin to copy configuration file and data.";
- const QString metapath = createTemporaryDirectory();
- generateMetaDataDirectory(metapath, packagesDir, packages, settings.applicationName(),
- settings.applicationVersion());
+ const QString sourceConfigFile = QFileInfo(configFile).absoluteFilePath();
+ const QString targetConfigFile = targetDir + QLatin1String("/config.xml");
+ QInstallerTools::copyWithException(sourceConfigFile, targetConfigFile, QLatin1String("configuration"));
- const QString configCopy = metapath + QLatin1String("/installer-config");
- QInstaller::mkdir(configCopy);
- QString absoluteConfigPath = QFileInfo(configFile).absolutePath();
+ QFile configXml(targetConfigFile);
+ QInstaller::openForRead(&configXml, configXml.fileName());
- QDirIterator it(absoluteConfigPath, QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
- while (it.hasNext()) {
- const QString next = it.next();
- if (next.contains(QLatin1String("/."))) // skip files that are in directories starting with a point
+ QDomDocument dom;
+ dom.setContent(&configXml);
+ configXml.close();
+
+ // iterate over all child elements, searching for relative file names
+ const QDomNodeList children = dom.documentElement().childNodes();
+ const QString sourceConfigFilePath = QFileInfo(sourceConfigFile).absolutePath();
+ for (int i = 0; i < children.count(); ++i) {
+ QDomElement domElement = children.at(i).toElement();
+ if (domElement.isNull())
continue;
- qDebug() << "\tFound configuration file: " << next;
- const QFileInfo sourceFileInfo(next);
- const QString source = sourceFileInfo.absoluteFilePath();
- QFileInfo targetFileInfo(configCopy, QFileInfo(next).fileName());
-
- if (QFileInfo(next).fileName() == QFileInfo(configFile).fileName())
- targetFileInfo.setFile(configCopy, QLatin1String("config.xml"));
-
- const QDir targetDir = targetFileInfo.dir();
- if (!targetDir.exists())
- QInstaller::mkpath(targetFileInfo.absolutePath());
- const QString target = targetFileInfo.absoluteFilePath();
-
- if (!QFile::copy(source, target))
- throw Error(QString::fromLatin1("Could not copy %1.").arg(source));
-
- if (sourceFileInfo.fileName() == QFileInfo(configFile).fileName()) {
- QFile configXml(targetDir.filePath(QLatin1String("config.xml")));
- configXml.open(QIODevice::ReadOnly);
- QDomDocument dom;
- dom.setContent(&configXml);
- configXml.close();
-
- // iterate over all child elements, searching for relative file names
- const QDomNodeList children = dom.documentElement().childNodes();
- for (int i = 0; i < children.count(); ++i) {
- QDomElement el = children.at(i).toElement();
- if (el.isNull())
- continue;
-
- QFileInfo fi(absoluteConfigPath, el.text());
+ const QString tagName = domElement.tagName();
+ const QString elementText = domElement.text();
+ qDebug() << QString::fromLatin1("Read dom element: <%1>%2</%1>.").arg(tagName, elementText);
+
+ QString newName = domElement.text().replace(QRegExp(QLatin1String("\\\\|/|\\.|:")),
+ QLatin1String("_"));
+
+ QString targetFile;
+ QFileInfo elementFileInfo;
+ if (tagName == QLatin1String("Icon") || tagName == QLatin1String("InstallerApplicationIcon")) {
#if defined(Q_OS_MAC)
- const QFileInfo fiIcon(absoluteConfigPath, el.text() + QLatin1String(".icns"));
+ const QString suffix = QLatin1String(".icns");
#elif defined(Q_OS_WIN)
- const QFileInfo fiIcon(absoluteConfigPath, el.text() + QLatin1String(".ico"));
+ const QString suffix = QLatin1String(".ico");
#else
- const QFileInfo fiIcon(absoluteConfigPath, el.text() + QLatin1String(".png"));
+ const QString suffix = QLatin1String(".png");
#endif
- if (!fi.exists() && fiIcon.exists())
- fi = fiIcon;
-
- if (!fi.exists() || fi.absolutePath() == QFileInfo(configFile).dir().absolutePath())
- continue;
-
- if (fi.isDir())
- continue;
+ elementFileInfo = QFileInfo(sourceConfigFilePath, elementText + suffix);
+ targetFile = targetDir + QLatin1Char('/') + newName + suffix;
+ } else {
+ elementFileInfo = QFileInfo(sourceConfigFilePath, elementText);
+ const QString suffix = elementFileInfo.completeSuffix();
+ if (!suffix.isEmpty())
+ newName.append(QLatin1Char('.') + suffix);
+ targetFile = targetDir + QLatin1Char('/') + newName;
+ }
+ if (!elementFileInfo.exists() || elementFileInfo.isDir())
+ continue;
- const QString newName = el.text().replace(QRegExp(QLatin1String("\\\\|/|\\.")),
- QLatin1String("_"));
+ domElement.replaceChild(dom.createTextNode(newName), domElement.firstChild());
+ QInstallerTools::copyWithException(elementFileInfo.absoluteFilePath(), targetFile, tagName);
+ }
- if (!QFile::exists(targetDir.absoluteFilePath(newName))) {
- if (!QFile::copy(fi.absoluteFilePath(), targetDir.absoluteFilePath(newName)))
- throw Error(QString::fromLatin1("Could not copy %1.").arg(el.text()));
- }
- el.removeChild(el.firstChild());
- el.appendChild(dom.createTextNode(newName));
- }
+ QInstaller::openForWrite(&configXml, configXml.fileName());
+ QTextStream stream(&configXml);
+ dom.save(stream, 4);
- openForWrite(&configXml, configXml.fileName());
- QTextStream stream(&configXml);
- dom.save(stream, 4);
- qDebug() << "\tdone.";
- }
- }
- return metapath;
+ qDebug() << "done.\n";
}
static int printErrorAndUsageAndExit(const QString &err)
@@ -706,31 +692,37 @@ int main(int argc, char **argv)
qDebug() << "Parsed arguments, ok.";
+ int exitCode = EXIT_FAILURE;
+ const QString tmpMetaDir = QInstaller::createTemporaryDirectory();
try {
- QInstallerTools::PackageInfoVector packages = createListOfPackages(packagesDirectory,
+ const Settings settings = Settings::fromFileAndPrefix(configFile, QFileInfo(configFile).absolutePath());
+ QInstallerTools::PackageInfoVector packages = QInstallerTools::createListOfPackages(packagesDirectory,
filteredPackages, ftype);
- const QString metaDir = createMetaDataDirectory(packages, packagesDirectory, configFile);
+ QInstallerTools::copyMetaData(tmpMetaDir, packagesDirectory, packages, settings.applicationName(),
+ settings.applicationVersion());
+
+ copyConfigData(configFile, tmpMetaDir + QLatin1String("/installer-config"));
{
- QSettings confInternal(metaDir + QLatin1String("/config/config-internal.ini")
+ QSettings confInternal(tmpMetaDir + QLatin1String("/config/config-internal.ini")
, QSettings::IniFormat);
+ // assume offline installer if there are no repositories
+ offlineOnly |= settings.repositories().isEmpty();
confInternal.setValue(QLatin1String("offlineOnly"), offlineOnly);
}
#if defined(Q_OS_MAC)
// on mac, we enforce building a bundle
- if (!target.endsWith(QLatin1String(".app")) && !target.endsWith(QLatin1String(".dmg"))) {
+ if (!target.endsWith(QLatin1String(".app")) && !target.endsWith(QLatin1String(".dmg")))
target += QLatin1String(".app");
- }
#endif
- int result = EXIT_FAILURE;
{
Input input;
input.outputPath = target;
input.installerExePath = templateBinary;
- input.binaryResourcePath = createBinaryResourceFile(metaDir);
+ input.binaryResourcePath = createBinaryResourceFile(tmpMetaDir);
input.binaryResources = createBinaryResourceFiles(resources);
- QInstallerTools::copyComponentData(packagesDirectory, metaDir, packages);
+ QInstallerTools::copyComponentData(packagesDirectory, tmpMetaDir, &packages);
// now put the packages into the components section of the binary
foreach (const QInstallerTools::PackageInfo &info, packages) {
@@ -740,7 +732,7 @@ int main(int argc, char **argv)
qDebug() << "Creating component info for" << info.name;
foreach (const QString &archive, info.copiedArchives) {
const QSharedPointer<Archive> arch(new Archive(archive));
- qDebug() << QString::fromLatin1("\tAppending %1 (%2)").arg(archive,
+ qDebug() << QString::fromLatin1("Appending %1 (%2)").arg(archive,
humanReadableSize(arch->size()));
comp.appendArchive(arch);
}
@@ -748,7 +740,7 @@ int main(int argc, char **argv)
}
qDebug() << "Creating the binary";
- result = assemble(input, configFile);
+ exitCode = assemble(input, settings);
// cleanup
qDebug() << "Cleaning up...";
@@ -756,14 +748,12 @@ int main(int argc, char **argv)
foreach (const QString &resource, input.binaryResources)
QFile::remove(resource);
}
- removeDirectory(metaDir, true);
- return result;
} catch (const Error &e) {
- std::cerr << "caught exception: " << e.message() << std::endl;
- return EXIT_FAILURE;
+ std::cerr << "Caught exception: " << e.message() << std::endl;
} catch (...) {
std::cerr << "Unknown exception caught" << std::endl;
- return EXIT_FAILURE;
}
- return EXIT_FAILURE;
+
+ QInstaller::removeDirectory(tmpMetaDir, true);
+ return exitCode;
}
diff --git a/tools/common/repositorygen.cpp b/tools/common/repositorygen.cpp
index dcf6b6133..644ab08ca 100644
--- a/tools/common/repositorygen.cpp
+++ b/tools/common/repositorygen.cpp
@@ -42,6 +42,7 @@
#include <fileutils.h>
#include <errors.h>
+#include <globals.h>
#include <lib7z_facade.h>
#include <settings.h>
#include <qinstallerglobal.h>
@@ -72,6 +73,33 @@ void QInstallerTools::printRepositoryGenOptions()
std::cout << " --ignore-invalid-packages Ignore all invalid packages instead of aborting." << std::endl;
}
+QString QInstallerTools::makePathAbsolute(const QString &path)
+{
+ if (QFileInfo(path).isRelative())
+ return QDir::current().absoluteFilePath(path);
+ return path;
+}
+
+void QInstallerTools::copyWithException(const QString &source, const QString &target, const QString &kind)
+{
+ qDebug() << QString::fromLatin1("Copying associated %1 file '%2'").arg(kind, source);
+
+ const QFileInfo targetFileInfo(target);
+ if (!targetFileInfo.dir().exists())
+ QInstaller::mkpath(targetFileInfo.absolutePath());
+
+ QFile sourceFile(source);
+ if (!sourceFile.copy(target)) {
+ qDebug() << "failed!\n";
+ throw QInstaller::Error(QString::fromLatin1("Could not copy the %1 file from\n'%2' to '%3'\nError: "
+ "'%4'.").arg(kind, source, target,
+ /* in case of an existing target the error String does not show the file */
+ (targetFileInfo.exists() ? QLatin1String("Target already exist.") : sourceFile.errorString())));
+ }
+
+ qDebug() << "done.\n";
+}
+
void QInstallerTools::compressPaths(const QStringList &paths, const QString &archivePath)
{
QFile archive(archivePath);
@@ -79,91 +107,98 @@ void QInstallerTools::compressPaths(const QStringList &paths, const QString &arc
Lib7z::createArchive(&archive, paths);
}
-void QInstallerTools::compressMetaDirectories(const QString &repoDir)
+static QStringList copyFilesFromNode(const QString &parentNode, const QString &childNode, const QString &attr,
+ const QString &kind, const QDomNode &package, const PackageInfo &info, const QString &targetDir)
{
- QDir dir(repoDir);
- const QStringList sub = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
- foreach (const QString &i, sub) {
- QDir sd(dir);
- sd.cd(i);
- const QString absPath = sd.absolutePath();
- const QString fn = QLatin1String("meta.7z");
- const QString tmpTarget = repoDir + QLatin1String("/") +fn;
- compressPaths(QStringList() << absPath, tmpTarget);
- QFile tmp(tmpTarget);
- const QString finalTarget = absPath + QLatin1String("/") + fn;
- if (!tmp.rename(finalTarget)) {
- throw QInstaller::Error(QString::fromLatin1("Could not move file from '%1' to '%2'").arg(tmpTarget,
- finalTarget));
+ QStringList copiedFiles;
+ const QDomNodeList nodes = package.firstChildElement(parentNode).childNodes();
+ for (int i = 0; i < nodes.count(); ++i) {
+ const QDomNode node = nodes.at(i);
+ if (node.nodeName() != childNode)
+ continue;
+
+ const QDir dir(QString::fromLatin1("%1/meta").arg(info.directory));
+ const QString filter = attr.isEmpty() ? node.toElement().text() : node.toElement().attribute(attr);
+ const QStringList files = dir.entryList(QStringList(filter), QDir::Files);
+ if (files.isEmpty()) {
+ throw QInstaller::Error(QString::fromLatin1("Couldn't find any %1 matching '%2' "
+ "while copying %1 of '%3'.").arg(kind, filter, info.name));
+ }
+
+ foreach (const QString &file, files) {
+ const QString source(QString::fromLatin1("%1/meta/%2").arg(info.directory, file));
+ const QString target(QString::fromLatin1("%1/%2/%3").arg(targetDir, info.name, file));
+ copyWithException(source, target, kind);
+ copiedFiles.append(file);
}
}
+ return copiedFiles;
}
-void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QString &dataDir,
+void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &metaDataDir,
const PackageInfoVector &packages, const QString &appName, const QString &appVersion,
const QString &redirectUpdateUrl)
{
- QString metapath = outDir;
- if (QFileInfo(metapath).isRelative())
- metapath = QDir::cleanPath(QDir::current().absoluteFilePath(metapath));
- qDebug() << "Generating meta data...";
-
- if (!QFile::exists(metapath))
- QInstaller::mkpath(metapath);
+ const QString targetDir = makePathAbsolute(_targetDir);
+ if (!QFile::exists(targetDir))
+ QInstaller::mkpath(targetDir);
QDomDocument doc;
QDomElement root;
- // use existing Updates.xml, if any
- QFile existingUpdatesXml(QFileInfo(dataDir, QLatin1String("Updates.xml")).absoluteFilePath());
- if (!existingUpdatesXml.open(QIODevice::ReadOnly) || !doc.setContent(&existingUpdatesXml)) {
+ QFile existingUpdatesXml(QFileInfo(metaDataDir, QLatin1String("Updates.xml")).absoluteFilePath());
+ if (existingUpdatesXml.open(QIODevice::ReadOnly) && doc.setContent(&existingUpdatesXml)) {
+ root = doc.documentElement();
+ // remove entry for this component from existing Updates.xml, if found
+ foreach (const PackageInfo &info, packages) {
+ const QDomNodeList packageNodes = root.childNodes();
+ for (int i = packageNodes.count() - 1; i >= 0; --i) {
+ const QDomNode node = packageNodes.at(i);
+ if (node.nodeName() != QLatin1String("PackageUpdate"))
+ continue;
+ if (node.firstChildElement(QLatin1String("Name")).text() != info.name)
+ continue;
+ root.removeChild(node);
+ }
+ }
+ existingUpdatesXml.close();
+ // TODO: maybe we should replace or remove an existing redirect with the one given, if so
+ } else {
root = doc.createElement(QLatin1String("Updates"));
- root.appendChild(doc.createElement(QLatin1String("ApplicationName"))).appendChild(
- doc.createTextNode(appName));
- root.appendChild(doc.createElement(QLatin1String("ApplicationVersion"))).appendChild(
- doc.createTextNode(appVersion));
- root.appendChild(doc.createElement(QLatin1String("Checksum"))).appendChild(
- doc.createTextNode(QLatin1String("true")));
+ root.appendChild(doc.createElement(QLatin1String("ApplicationName"))).appendChild(doc
+ .createTextNode(appName));
+ root.appendChild(doc.createElement(QLatin1String("ApplicationVersion"))).appendChild(doc
+ .createTextNode(appVersion));
+ root.appendChild(doc.createElement(QLatin1String("Checksum"))).appendChild(doc
+ .createTextNode(QLatin1String("true")));
if (!redirectUpdateUrl.isEmpty()) {
- root.appendChild(doc.createElement(QLatin1String("RedirectUpdateUrl"))).appendChild(
- doc.createTextNode(redirectUpdateUrl));
+ root.appendChild(doc.createElement(QLatin1String("RedirectUpdateUrl"))).appendChild(doc
+ .createTextNode(redirectUpdateUrl));
}
- } else {
- root = doc.documentElement();
}
- for (PackageInfoVector::const_iterator it = packages.begin(); it != packages.end(); ++it) {
- const QString packageXmlPath = QString::fromLatin1("%1/meta/package.xml").arg(it->directory);
- qDebug() << QString::fromLatin1("\tGenerating meta data for package %1 using %2.").arg(
- it->name, packageXmlPath);
+ foreach (const PackageInfo &info, packages) {
+ if (!QDir(targetDir).mkpath(info.name))
+ throw QInstaller::Error(QString::fromLatin1("Could not create directory '%1'.").arg(info.name));
- // remove existing entry for this component from existing Updates.xml
- const QDomNodeList packageNodes = root.childNodes();
- for (int i = 0; i < packageNodes.count(); ++i) {
- const QDomNode node = packageNodes.at(i);
- if (node.nodeName() != QLatin1String("PackageUpdate"))
- continue;
- if (node.firstChildElement(QLatin1String("Name")).text() != it->name)
- continue;
- root.removeChild(node);
- --i;
- }
+ const QString packageXmlPath = QString::fromLatin1("%1/meta/package.xml").arg(info.directory);
+ qDebug() << QString::fromLatin1("Copy meta data for package '%1' using '%2'.").arg(info.name,
+ packageXmlPath);
- QDomDocument packageXml;
QFile file(packageXmlPath);
QInstaller::openForRead(&file, packageXmlPath);
+
QString errMsg;
- int col = 0;
int line = 0;
- if (!packageXml.setContent(&file, &errMsg, &line, &col)) {
+ int column = 0;
+ QDomDocument packageXml;
+ if (!packageXml.setContent(&file, &errMsg, &line, &column)) {
throw QInstaller::Error(QString::fromLatin1("Could not parse '%1': line: %2, column: %3: %4 (%5)")
- .arg(packageXmlPath, QString::number(line), QString::number(col), errMsg, it->name));
+ .arg(packageXmlPath).arg(line).arg(column).arg(errMsg, info.name));
}
- const QDomNode package = packageXml.firstChildElement(QLatin1String("Package"));
QDomElement update = doc.createElement(QLatin1String("PackageUpdate"));
- QDomElement nameElement = doc.createElement(QLatin1String("Name"));
- nameElement.appendChild(doc.createTextNode(it->name));
- update.appendChild(nameElement);
+ QDomNode nameElement = update.appendChild(doc.createElement(QLatin1String("Name")));
+ nameElement.appendChild(doc.createTextNode(info.name));
// list of current unused or later transformed tags
QStringList blackList;
@@ -173,6 +208,7 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt
bool foundDefault = false;
bool foundVirtual = false;
bool foundDisplayName = false;
+ const QDomNode package = packageXml.firstChildElement(QLatin1String("Package"));
const QDomNodeList childNodes = package.childNodes();
for (int i = 0; i < childNodes.count(); ++i) {
const QDomNode node = childNodes.at(i);
@@ -187,13 +223,12 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt
if (node.isComment() || blackList.contains(key))
continue; // just skip comments and some tags...
- const QString value = node.toElement().text();
QDomElement element = doc.createElement(key);
- for (int i = 0; i < node.attributes().size(); i++) {
- element.setAttribute(node.attributes().item(i).toAttr().name(),
- node.attributes().item(i).toAttr().value());
+ for (int j = 0; j < node.attributes().size(); ++j) {
+ element.setAttribute(node.attributes().item(j).toAttr().name(),
+ node.attributes().item(j).toAttr().value());
}
- update.appendChild(element).appendChild(doc.createTextNode(value));
+ update.appendChild(element).appendChild(doc.createTextNode(node.toElement().text()));
}
if (foundDefault && foundVirtual) {
@@ -204,8 +239,7 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt
if (!foundDisplayName) {
qWarning() << "No DisplayName tag found, using component Name instead.";
QDomElement displayNameElement = doc.createElement(QLatin1String("DisplayName"));
- displayNameElement.appendChild(doc.createTextNode(it->name));
- update.appendChild(displayNameElement);
+ update.appendChild(displayNameElement).appendChild(doc.createTextNode(info.name));
}
// get the size of the data
@@ -213,14 +247,11 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt
quint64 compressedComponentSize = 0;
const QDir::Filters filters = QDir::Files | QDir::NoDotAndDotDot;
- const QDir cmpDataDir = QString::fromLatin1("%1/%2/data").arg(dataDir, it->name);
- const QFileInfoList entries = cmpDataDir.exists() ? cmpDataDir.entryInfoList(filters | QDir::Dirs)
- : QDir(QString::fromLatin1("%1/%2").arg(dataDir, it->name)).entryInfoList(filters);
-
+ const QDir dataDir = QString::fromLatin1("%1/%2/data").arg(metaDataDir, info.name);
+ const QFileInfoList entries = dataDir.exists() ? dataDir.entryInfoList(filters | QDir::Dirs)
+ : QDir(QString::fromLatin1("%1/%2").arg(metaDataDir, info.name)).entryInfoList(filters);
+ qDebug() << QString::fromLatin1("calculate size of directory: %1").arg(dataDir.absolutePath());
foreach (const QFileInfo &fi, entries) {
- if (fi.isHidden())
- continue;
-
try {
if (fi.isDir()) {
QDirIterator recursDirIt(fi.filePath(), QDirIterator::Subdirectories);
@@ -233,18 +264,20 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt
// if it's an archive already, list its files and sum the uncompressed sizes
QFile archive(fi.filePath());
compressedComponentSize += archive.size();
- archive.open(QIODevice::ReadOnly);
- const QVector< Lib7z::File > files = Lib7z::listArchive(&archive);
- for (QVector< Lib7z::File >::const_iterator fileIt = files.begin();
- fileIt != files.end(); ++fileIt) {
- componentSize += fileIt->uncompressedSize;
- }
+ QInstaller::openForRead(&archive, archive.fileName());
+
+ QVector<Lib7z::File>::const_iterator fileIt;
+ const QVector<Lib7z::File> files = Lib7z::listArchive(&archive);
+ for (fileIt = files.begin(); fileIt != files.end(); ++fileIt)
+ componentSize += fileIt->uncompressedSize;
} else {
// otherwise just add its size
const quint64 size = fi.size();
componentSize += size;
compressedComponentSize += size;
}
+ } catch (const QInstaller::Error &error) {
+ qDebug() << error.message();
} catch(...) {
// ignore, that's just about the sizes - and size doesn't matter, you know?
}
@@ -257,16 +290,11 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt
root.appendChild(update);
- if (!QDir(metapath).mkpath(it->name))
- throw QInstaller::Error(QString::fromLatin1("Could not create directory '%1'.").arg(it->name));
-
- // copy scripts
+ // copy script file
const QString script = package.firstChildElement(QLatin1String("Script")).text();
if (!script.isEmpty()) {
- const QString fromLocation(QString::fromLatin1("%1/meta/%2").arg(it->directory, script));
-
QString scriptContent;
- QFile scriptFile(fromLocation);
+ QFile scriptFile(QString::fromLatin1("%1/meta/%2").arg(info.directory, script));
if (scriptFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&scriptFile);
scriptContent = in.readAll();
@@ -274,173 +302,75 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt
static QScriptEngine testScriptEngine;
testScriptEngine.evaluate(scriptContent, scriptFile.fileName());
if (testScriptEngine.hasUncaughtException()) {
- throw QInstaller::Error(QString::fromLatin1("Exception while loading the component script: '%1'")
+ throw QInstaller::Error(QString::fromLatin1("Exception while loading component script: '%1'")
.arg(QInstaller::uncaughtExceptionString(&testScriptEngine, scriptFile.fileName())));
}
- // added the xml tag RequiresAdminRights to the xml if somewhere addElevatedOperation is used
+ // add RequiresAdminRights tag to xml if addElevatedOperation is used somewhere
if (scriptContent.contains(QLatin1String("addElevatedOperation"))) {
- QDomElement requiresAdminRightsElement =
- doc.createElement(QLatin1String("RequiresAdminRights"));
- requiresAdminRightsElement.appendChild(doc.createTextNode(QLatin1String("true")));
+ QDomElement element = doc.createElement(QLatin1String("RequiresAdminRights"));
+ element.appendChild(doc.createTextNode(QLatin1String("true")));
}
- qDebug() << "\tCopying associated script" << script << "into the meta package...";
- QString toLocation(QString::fromLatin1("%1/%2/%3").arg(metapath, it->name, script));
- if (!scriptFile.copy(toLocation)) {
- qDebug() << "failed!";
- throw QInstaller::Error(QString::fromLatin1("Could not copy the script '%1' to its target location '%2'.")
- .arg(fromLocation, toLocation));
- } else {
- qDebug() << "\tdone.";
- }
+ const QString toLocation(QString::fromLatin1("%1/%2/%3").arg(targetDir, info.name, script));
+ copyWithException(scriptFile.fileName(), toLocation, QLatin1String("script"));
}
// copy user interfaces
- const QDomNodeList uiNodes = package.firstChildElement(QLatin1String("UserInterfaces")).childNodes();
- QStringList userinterfaces;
- for (int i = 0; i < uiNodes.count(); ++i) {
- const QDomNode node = uiNodes.at(i);
- if (node.nodeName() != QLatin1String("UserInterface"))
- continue;
-
- const QDir dir(QString::fromLatin1("%1/meta").arg(it->directory));
- const QStringList uis = dir.entryList(QStringList(node.toElement().text()), QDir::Files);
- if (uis.isEmpty()) {
- throw QInstaller::Error(QString::fromLatin1("Couldn't find any user interface matching '%1' while "
- "copying user interfaces of '%2'.").arg(node.toElement().text(), it->name));
- }
-
- for (QStringList::const_iterator ui = uis.begin(); ui != uis.end(); ++ui) {
- qDebug() << "\tCopying associated user interface" << *ui << "into the meta package...";
- userinterfaces.push_back(*ui);
- if (!QFile::copy(QString::fromLatin1("%1/meta/%2").arg(it->directory, *ui),
- QString::fromLatin1("%1/%2/%3").arg(metapath, it->name, *ui))) {
- qDebug() << "failed!";
- throw QInstaller::Error(QString::fromLatin1("Could not copy the UI file '%1' to its target "
- "location '%2'.").arg(*ui, it->name));
- } else {
- qDebug() << "done";
- }
- }
- }
-
- if (!userinterfaces.isEmpty()) {
- update.appendChild(doc.createElement(QLatin1String("UserInterfaces")))
- .appendChild(doc.createTextNode(userinterfaces.join(QChar::fromLatin1(','))));
+ const QStringList uiFiles = copyFilesFromNode(QLatin1String("UserInterfaces"),
+ QLatin1String("UserInterface"), QString(), QLatin1String("user interface"), package, info,
+ targetDir);
+ if (!uiFiles.isEmpty()) {
+ update.appendChild(doc.createElement(QLatin1String("UserInterfaces"))).appendChild(doc
+ .createTextNode(uiFiles.join(QChar::fromLatin1(','))));
}
// copy translations
- const QDomNodeList qmNodes = package.firstChildElement(QLatin1String("Translations")).childNodes();
- QStringList translations;
+ QStringList trFiles;
if (!qApp->arguments().contains(QString::fromLatin1("--ignore-translations"))) {
- for (int i = 0; i < qmNodes.count(); ++i) {
- const QDomNode node = qmNodes.at(i);
- if (node.nodeName() != QLatin1String("Translation"))
- continue;
-
- const QDir dir(QString::fromLatin1("%1/meta").arg(it->directory));
- const QStringList qms = dir.entryList(QStringList(node.toElement().text()), QDir::Files);
- if (qms.isEmpty()) {
- throw QInstaller::Error(QString::fromLatin1("Could not find any translation file matching '%1' "
- "while copying translations of '%2'.").arg(node.toElement().text(), it->name));
- }
-
- for (QStringList::const_iterator qm = qms.begin(); qm != qms.end(); ++qm) {
- qDebug() << "\tCopying associated translation" << *qm << "into the meta package...";
- translations.push_back(*qm);
- if (!QFile::copy(QString::fromLatin1("%1/meta/%2").arg(it->directory, *qm),
- QString::fromLatin1("%1/%2/%3").arg(metapath, it->name, *qm))) {
- qDebug() << "failed!";
- throw QInstaller::Error(QString::fromLatin1("Could not copy the translation '%1' to its "
- "target location '%2'.").arg(*qm, it->name));
- } else {
- qDebug() << "done";
- }
- }
- }
-
- if (!translations.isEmpty()) {
- update.appendChild(doc.createElement(QLatin1String("Translations")))
- .appendChild(doc.createTextNode(translations.join(QChar::fromLatin1(','))));
+ trFiles = copyFilesFromNode(QLatin1String("Translations"), QLatin1String("Translation"),
+ QString(), QLatin1String("translation"), package, info, targetDir);
+ if (!trFiles.isEmpty()) {
+ update.appendChild(doc.createElement(QLatin1String("Translations"))).appendChild(doc
+ .createTextNode(trFiles.join(QChar::fromLatin1(','))));
}
-
}
// copy license files
- const QDomNodeList licenseNodes = package.firstChildElement(QLatin1String("Licenses")).childNodes();
- for (int i = 0; i < licenseNodes.count(); ++i) {
- const QDomNode licenseNode = licenseNodes.at(i);
- if (licenseNode.nodeName() == QLatin1String("License")) {
- const QString &licenseFile =
- licenseNode.toElement().attributeNode(QLatin1String("file")).value();
- const QString &sourceFile =
- QString::fromLatin1("%1/meta/%2").arg(it->directory).arg(licenseFile);
- if (!QFile::exists(sourceFile)) {
- throw QInstaller::Error(QString::fromLatin1("Could not find any license matching '%1' while "
- "copying license files of '%2'.").arg(licenseFile, it->name));
- }
-
- qDebug() << "\tCopying associated license file" << licenseFile << "into the meta package...";
- if (!QFile::copy(sourceFile, QString::fromLatin1("%1/%2/%3")
- .arg(metapath, it->name, licenseFile))) {
- qDebug() << "failed!";
- throw QInstaller::Error(QString::fromLatin1("Could not copy the license file '%1' to its "
- "target location '%2'.").arg(licenseFile, it->name));
- } else {
- qDebug() << "done.";
- }
-
- // Translated License files
- for (int j = 0; j < translations.size(); ++j) {
- QFileInfo translationFile(translations.at(j));
- QFileInfo untranslated(licenseFile);
- const QString &translatedLicenseFile =
- QString::fromLatin1("%2_%3.%4").arg(untranslated.baseName(),
- translationFile.baseName(), untranslated.completeSuffix());
- const QString &translatedSourceFile =
- QString::fromLatin1("%1/meta/%2").arg(it->directory).arg(translatedLicenseFile);
- if (!QFile::exists(translatedSourceFile)) {
- qDebug() << "Could not find translated license file" << translatedSourceFile;
- continue;
- }
-
- qDebug() << "\tCopying associated license file" << translatedLicenseFile
- << "into the meta package...";
-
- if (!QFile::copy(translatedSourceFile, QString::fromLatin1("%1/%2/%3")
- .arg(metapath, it->name, translatedLicenseFile))) {
- qDebug() << "\tfailed!";
- } else {
- qDebug() << "\tdone.";
- }
+ const QStringList licenses = copyFilesFromNode(QLatin1String("Licenses"), QLatin1String("License"),
+ QLatin1String("file"), QLatin1String("license"), package, info, targetDir);
+ if (!licenses.isEmpty()) {
+ foreach (const QString &trFile, trFiles) {
+ // Copy translated license file based on the assumption that it will have the same base name
+ // as the original license plus the file name of an existing translation file without suffix.
+ foreach (const QString &license, licenses) {
+ const QFileInfo untranslated(license);
+ const QString translatedLicense = QString::fromLatin1("%2_%3.%4").arg(untranslated
+ .baseName(), QFileInfo(trFile).baseName(), untranslated.completeSuffix());
+ // ignore copy failure, that's just about the translations
+ QFile::copy(QString::fromLatin1("%1/meta/%2").arg(info.directory).arg(translatedLicense),
+ QString::fromLatin1("%1/%2/%3").arg(targetDir, info.name, translatedLicense));
}
}
- }
-
- if (licenseNodes.count() > 0)
update.appendChild(package.firstChildElement(QLatin1String("Licenses")).cloneNode());
+ }
}
-
doc.appendChild(root);
- const QString updatesXmlFile = QFileInfo(metapath, QLatin1String("Updates.xml")).absoluteFilePath();
- QFile updatesXml(updatesXmlFile);
-
- QInstaller::openForWrite(&updatesXml, updatesXmlFile);
- QInstaller::blockingWrite(&updatesXml, doc.toByteArray());
+ QFile targetUpdatesXml(targetDir + QLatin1String("/Updates.xml"));
+ QInstaller::openForWrite(&targetUpdatesXml, targetUpdatesXml.fileName());
+ QInstaller::blockingWrite(&targetUpdatesXml, doc.toByteArray());
}
PackageInfoVector QInstallerTools::createListOfPackages(const QString &packagesDirectory,
const QStringList &filteredPackages, FilterType filterType)
{
- qDebug() << "Collecting information about available packages...";
+ qDebug() << "\nCollecting information about available packages...";
bool ignoreInvalidPackages = qApp->arguments().contains(QString::fromLatin1("--ignore-invalid-packages"));
PackageInfoVector dict;
- const QFileInfoList entries = QDir(packagesDirectory)
- .entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
+ const QFileInfoList entries = QDir(packagesDirectory).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
for (QFileInfoList::const_iterator it = entries.begin(); it != entries.end(); ++it) {
if (filterType == Exclude) {
if (filteredPackages.contains(it->fileName()))
@@ -449,14 +379,14 @@ PackageInfoVector QInstallerTools::createListOfPackages(const QString &packagesD
if (!filteredPackages.contains(it->fileName()))
continue;
}
- qDebug() << QString::fromLatin1("\tfound subdirectory '%1'").arg(it->fileName());
+ qDebug() << QString::fromLatin1("found subdirectory '%1'").arg(it->fileName());
// because the filter is QDir::Dirs - filename means the name of the subdirectory
if (it->fileName().contains(QLatin1Char('-'))) {
if (ignoreInvalidPackages)
continue;
- throw QInstaller::Error(QString::fromLatin1("Component '%1' mustn't contain '-'. This is not allowed, because "
- "dashes are used as the separator between the component name and the version number internally.")
- .arg(it->fileName()));
+ throw QInstaller::Error(QString::fromLatin1("Component '%1' mustn't contain '-'. This is not "
+ "allowed, because dashes are used as the separator between the component name and the "
+ "version number internally.").arg(it->fileName()));
}
QFile file(QString::fromLatin1("%1/meta/package.xml").arg(it->filePath()));
@@ -507,11 +437,11 @@ PackageInfoVector QInstallerTools::createListOfPackages(const QString &packagesD
.arg(fileInfo.absoluteFilePath(), info.version));
}
info.dependencies = packageElement.firstChildElement(QLatin1String("Dependencies")).text()
- .split(QInstaller::scCommaRegExp, QString::SkipEmptyParts);
+ .split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
info.directory = it->filePath();
dict.push_back(info);
- qDebug() << QString::fromLatin1("\t- it provides the package %1 - %2").arg(name, info.version);
+ qDebug() << QString::fromLatin1("- it provides the package %1 - %2").arg(info.name, info.version);
}
if (dict.isEmpty())
@@ -580,8 +510,10 @@ void QInstallerTools::compressMetaDirectories(const QString &repoDir, const QStr
const QByteArray sha1Sum = QInstaller::calculateHash(&tmp, QCryptographicHash::Sha1);
writeSHA1ToNodeWithName(doc, elements, sha1Sum, path);
const QString finalTarget = absPath + QLatin1String("/") + fn;
- if (!tmp.rename(finalTarget))
- throw QInstaller::Error(QString::fromLatin1("Could not move '%1' to '%2'").arg(tmpTarget, finalTarget));
+ if (!tmp.rename(finalTarget)) {
+ throw QInstaller::Error(QString::fromLatin1("Could not move '%1' to '%2'").arg(tmpTarget,
+ finalTarget));
+ }
}
QInstaller::openForWrite(&existingUpdatesXml, existingUpdatesXml.fileName());
@@ -590,10 +522,10 @@ void QInstallerTools::compressMetaDirectories(const QString &repoDir, const QStr
}
void QInstallerTools::copyComponentData(const QString &packageDir, const QString &repoDir,
- PackageInfoVector &infos)
+ PackageInfoVector *const infos)
{
- for (int i = 0; i < infos.count(); ++i) {
- const PackageInfo info = infos.at(i);
+ for (int i = 0; i < infos->count(); ++i) {
+ const PackageInfo info = infos->at(i);
const QString name = info.name;
qDebug() << "Copying component data for" << name;
@@ -616,8 +548,8 @@ void QInstallerTools::copyComponentData(const QString &packageDir, const QString
qDebug() << QString::fromLatin1("Copying archive from '%1' to '%2'").arg(tmp.fileName(),
target);
if (!tmp.copy(target)) {
- throw QInstaller::Error(QString::fromLatin1("Could not copy '%1' to '%2': %3").arg(tmp.fileName(),
- target, tmp.errorString()));
+ throw QInstaller::Error(QString::fromLatin1("Could not copy '%1' to '%2': %3")
+ .arg(tmp.fileName(), target, tmp.errorString()));
}
compressedFiles.append(target);
} else {
@@ -642,7 +574,7 @@ void QInstallerTools::copyComponentData(const QString &packageDir, const QString
}
foreach (const QString &target, compressedFiles) {
- infos[i].copiedArchives.append(target);
+ (*infos)[i].copiedArchives.append(target);
QFile archiveFile(target);
QFile archiveHashFile(archiveFile.fileName() + QLatin1String(".sha1"));
@@ -659,7 +591,7 @@ void QInstallerTools::copyComponentData(const QString &packageDir, const QString
QInstaller::openForWrite(&archiveHashFile, archiveHashFile.fileName());
archiveHashFile.write(hashOfArchiveData);
qDebug() << "Generated sha1 hash:" << hashOfArchiveData;
- infos[i].copiedArchives.append(archiveHashFile.fileName());
+ (*infos)[i].copiedArchives.append(archiveHashFile.fileName());
archiveHashFile.close();
} catch (const QInstaller::Error &/*e*/) {
archiveFile.close();
diff --git a/tools/common/repositorygen.h b/tools/common/repositorygen.h
index 50349c8b6..49a81eb1d 100644
--- a/tools/common/repositorygen.h
+++ b/tools/common/repositorygen.h
@@ -48,7 +48,6 @@
namespace QInstallerTools {
-void printRepositoryGenOptions();
struct PackageInfo
{
@@ -65,21 +64,22 @@ enum FilterType {
Exclude
};
+void printRepositoryGenOptions();
+QString makePathAbsolute(const QString &path);
+void copyWithException(const QString &source, const QString &target, const QString &kind = QString());
+
+PackageInfoVector createListOfPackages(const QString &packagesDirectory, const QStringList &filteredPackages,
+ FilterType ftype);
QHash<QString, QString> buildPathToVersionMapping(const PackageInfoVector &info);
-void compressMetaDirectories(const QString &repoDir);
void compressPaths(const QStringList &paths, const QString &archivePath);
void compressMetaDirectories(const QString &repoDir, const QString &baseDir,
const QHash<QString, QString> &versionMapping);
-void copyComponentData(const QString &packageDir, const QString &repoDir, PackageInfoVector &infos);
-
-void generateMetaDataDirectory(const QString &outDir, const QString &dataDir,
- const PackageInfoVector &packages, const QString &appName,
- const QString& appVersion, const QString &redirectUpdateUrl = QString());
+void copyMetaData(const QString &outDir, const QString &dataDir, const PackageInfoVector &packages,
+ const QString &appName, const QString& appVersion, const QString &redirectUpdateUrl = QString());
+void copyComponentData(const QString &packageDir, const QString &repoDir, PackageInfoVector *const infos);
-PackageInfoVector createListOfPackages(const QString &packagesDirectory, const QStringList &filteredPackages,
- FilterType ftype);
} // namespace QInstallerTools
diff --git a/tools/repogen/repogen.cpp b/tools/repogen/repogen.cpp
index 1380e4ebf..84a7d918e 100644
--- a/tools/repogen/repogen.cpp
+++ b/tools/repogen/repogen.cpp
@@ -90,16 +90,10 @@ static int printErrorAndUsageAndExit(const QString &err)
return 1;
}
-static QString makeAbsolute(const QString &path)
-{
- QFileInfo fi(path);
- if (fi.isAbsolute())
- return path;
- return QDir::current().absoluteFilePath(path);
-}
-
int main(int argc, char** argv)
{
+ QString tmpMetaDir;
+ int exitCode = EXIT_FAILURE;
try {
QCoreApplication app(argc, argv);
@@ -188,7 +182,7 @@ int main(int argc, char** argv)
"exclusive!"));
}
- const QString repositoryDir = makeAbsolute(args.first());
+ const QString repositoryDir = QInstallerTools::makePathAbsolute(args.first());
if (remove)
QInstaller::removeDirectory(repositoryDir);
@@ -199,7 +193,7 @@ int main(int argc, char** argv)
QInstallerTools::PackageInfoVector packages = QInstallerTools::createListOfPackages(packagesDir,
filteredPackages, filterType);
- QHash<QString, QString> pathToVersionMapping = buildPathToVersionMapping(packages);
+ QHash<QString, QString> pathToVersionMapping = QInstallerTools::buildPathToVersionMapping(packages);
foreach (const QInstallerTools::PackageInfo &package, packages) {
const QFileInfo fi(repositoryDir, package.name);
@@ -207,27 +201,27 @@ int main(int argc, char** argv)
removeDirectory(fi.absoluteFilePath());
}
- copyComponentData(packagesDir, repositoryDir, packages);
-
- TempDirDeleter tmpDeleter;
- const QString metaTmp = createTemporaryDirectory();
- tmpDeleter.add(metaTmp);
-
- generateMetaDataDirectory(metaTmp, repositoryDir, packages, QLatin1String("{AnyApplication}"),
+ tmpMetaDir = QInstaller::createTemporaryDirectory();
+ QInstallerTools::copyComponentData(packagesDir, repositoryDir, &packages);
+ QInstallerTools::copyMetaData(tmpMetaDir, repositoryDir, packages, QLatin1String("{AnyApplication}"),
QLatin1String(QUOTE(IFW_REPOSITORY_FORMAT_VERSION)), redirectUpdateUrl);
- QInstallerTools::compressMetaDirectories(metaTmp, metaTmp, pathToVersionMapping);
+ QInstallerTools::compressMetaDirectories(tmpMetaDir, tmpMetaDir, pathToVersionMapping);
QDirIterator it(repositoryDir, QStringList(QLatin1String("Updates*.xml")), QDir::Files | QDir::CaseSensitive);
while (it.hasNext()) {
it.next();
QFile::remove(it.fileInfo().absoluteFilePath());
}
- moveDirectoryContents(metaTmp, repositoryDir);
- return 0;
+ QInstaller::moveDirectoryContents(tmpMetaDir, repositoryDir);
+ exitCode = EXIT_SUCCESS;
} catch (const Lib7z::SevenZipException &e) {
- std::cerr << "caught 7zip exception: " << e.message() << std::endl;
+ std::cerr << "Caught 7zip exception: " << e.message() << std::endl;
} catch (const QInstaller::Error &e) {
- std::cerr << "caught exception: " << e.message() << std::endl;
+ std::cerr << "Caught exception: " << e.message() << std::endl;
+ } catch (...) {
+ std::cerr << "Unknown exception caught" << std::endl;
}
- return 1;
+
+ QInstaller::removeDirectory(tmpMetaDir, true);
+ return exitCode;
}
diff --git a/tools/repogenfromonlinerepo/downloadmanager.h b/tools/repogenfromonlinerepo/downloadmanager.h
index 13cce7163..29aebec45 100644
--- a/tools/repogenfromonlinerepo/downloadmanager.h
+++ b/tools/repogenfromonlinerepo/downloadmanager.h
@@ -54,7 +54,7 @@ class DownloadManager: public QObject
{
Q_OBJECT
public:
- DownloadManager(QObject *parent = 0);
+ explicit DownloadManager(QObject *parent = 0);
void append(const QUrl &url);
void append(const QStringList &urlList);
diff --git a/tools/repogenfromonlinerepo/main.cpp b/tools/repogenfromonlinerepo/main.cpp
index 12023d495..d9c331fa2 100644
--- a/tools/repogenfromonlinerepo/main.cpp
+++ b/tools/repogenfromonlinerepo/main.cpp
@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
// get Updates.xml to get to know what we can download
downloadManager.append(QUrl(repoUrl + QLatin1String("/Updates.xml")));
- QObject::connect( &downloadManager, SIGNAL( finished() ), &downloadEventLoop, SLOT( quit() ) );
+ QObject::connect(&downloadManager, SIGNAL(finished()), &downloadEventLoop, SLOT(quit()));
downloadEventLoop.exec();
// END - get Updates.xml to get to know what we can download
@@ -192,7 +192,7 @@ int main(int argc, char *argv[])
// get Updates.xml to get to know what we can download
downloadManager.append(QUrl(repoUrl + QLatin1String("/") + packageName + QLatin1String("/")
+ packageScript));
- QObject::connect( &downloadManager, SIGNAL( finished() ), &downloadEventLoop, SLOT( quit() ) );
+ QObject::connect(&downloadManager, SIGNAL(finished()), &downloadEventLoop, SLOT(quit()));
downloadEventLoop.exec();
// END - get Updates.xml to get to know what we can download