diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/binarycreator/binarycreator.cpp | 63 | ||||
-rw-r--r-- | tools/common/repositorygen.cpp | 112 | ||||
-rw-r--r-- | tools/common/repositorygen.h | 1 | ||||
-rw-r--r-- | tools/repogenfromonlinerepo/downloadmanager.h | 2 | ||||
-rw-r--r-- | tools/repogenfromonlinerepo/main.cpp | 4 |
5 files changed, 97 insertions, 85 deletions
diff --git a/tools/binarycreator/binarycreator.cpp b/tools/binarycreator/binarycreator.cpp index 594686e61..c98f614ed 100644 --- a/tools/binarycreator/binarycreator.cpp +++ b/tools/binarycreator/binarycreator.cpp @@ -154,8 +154,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); @@ -218,9 +224,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) { @@ -478,23 +488,23 @@ static QString createMetaDataDirectory(const QInstallerTools::PackageInfoVector generateMetaDataDirectory(metapath, packagesDir, packages, settings.applicationName(), settings.applicationVersion()); - const QString configCopy = metapath + QLatin1String("/installer-config"); - QInstaller::mkdir(configCopy); + const QString tempConfigDirPath = metapath + QLatin1String("/installer-config"); + QInstaller::mkdir(tempConfigDirPath); QString absoluteConfigPath = QFileInfo(configFile).absolutePath(); 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 + if (next.contains(QLatin1String("/."))) // skip files that are in directories starting with a dot continue; - qDebug() << "\tFound configuration file: " << next; + qDebug() << "Found configuration file: " << next; const QFileInfo sourceFileInfo(next); const QString source = sourceFileInfo.absoluteFilePath(); - QFileInfo targetFileInfo(configCopy, QFileInfo(next).fileName()); + QFileInfo targetFileInfo(tempConfigDirPath, QFileInfo(next).fileName()); if (QFileInfo(next).fileName() == QFileInfo(configFile).fileName()) - targetFileInfo.setFile(configCopy, QLatin1String("config.xml")); + targetFileInfo.setFile(tempConfigDirPath, QLatin1String("config.xml")); const QDir targetDir = targetFileInfo.dir(); if (!targetDir.exists()) @@ -514,42 +524,41 @@ static QString createMetaDataDirectory(const QInstallerTools::PackageInfoVector // 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()) + QDomElement domElement = children.at(i).toElement(); + if (domElement.isNull()) continue; - QFileInfo fi(absoluteConfigPath, el.text()); + QFileInfo elementFileInfo(absoluteConfigPath, domElement.text()); #if defined(Q_OS_MAC) - const QFileInfo fiIcon(absoluteConfigPath, el.text() + QLatin1String(".icns")); + const QFileInfo iconFileInfo(absoluteConfigPath, domElement.text() + QLatin1String(".icns")); #elif defined(Q_OS_WIN) - const QFileInfo fiIcon(absoluteConfigPath, el.text() + QLatin1String(".ico")); + const QFileInfo iconFileInfo(absoluteConfigPath, domElement.text() + QLatin1String(".ico")); #else - const QFileInfo fiIcon(absoluteConfigPath, el.text() + QLatin1String(".png")); + const QFileInfo iconFileInfo(absoluteConfigPath, domElement.text() + QLatin1String(".png")); #endif - if (!fi.exists() && fiIcon.exists()) - fi = fiIcon; + if (!elementFileInfo.exists() && iconFileInfo.exists()) + elementFileInfo = iconFileInfo; - if (!fi.exists() || fi.absolutePath() == QFileInfo(configFile).dir().absolutePath()) + if (!elementFileInfo.exists() || elementFileInfo.absolutePath() == QFileInfo(configFile).dir().absolutePath()) continue; - if (fi.isDir()) + if (elementFileInfo.isDir()) continue; - const QString newName = el.text().replace(QRegExp(QLatin1String("\\\\|/|\\.")), + const QString newName = domElement.text().replace(QRegExp(QLatin1String("\\\\|/|\\.")), QLatin1String("_")); 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())); + if (!QFile::copy(elementFileInfo.absoluteFilePath(), targetDir.absoluteFilePath(newName))) + throw Error(QString::fromLatin1("Could not copy %1.").arg(domElement.text())); } - el.removeChild(el.firstChild()); - el.appendChild(dom.createTextNode(newName)); + domElement.replaceChild(dom.createTextNode(newName), domElement.firstChild()); } openForWrite(&configXml, configXml.fileName()); QTextStream stream(&configXml); dom.save(stream, 4); - qDebug() << "\tdone."; + qDebug() << "done.\n"; } } return metapath; @@ -740,7 +749,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); } diff --git a/tools/common/repositorygen.cpp b/tools/common/repositorygen.cpp index dcf6b6133..fdad96871 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,31 @@ void QInstallerTools::printRepositoryGenOptions() std::cout << " --ignore-invalid-packages Ignore all invalid packages instead of aborting." << std::endl; } +void QInstallerTools::copyWithException(const QString &source, const QString &target, const QString &kind) +{ + QFile sourceFile(source); + qDebug() << QString::fromLatin1("Copying associated %1 file '%2'").arg(kind, source); + + const QFileInfo targetFileInfo(target); + const QDir targetDir = targetFileInfo.dir(); + if (!targetDir.exists()) + QInstaller::mkpath(targetFileInfo.absolutePath()); + + // in the case of an existing target the error String does not show the file + if (targetFileInfo.exists()) { + 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, QLatin1String("Target already exist."))); + } + + if (!sourceFile.copy(target)) { + qDebug() << "failed!\n"; + throw QInstaller::Error(QString::fromLatin1("Could not copy the %1 file.\nError: '%2'" + ).arg(kind, sourceFile.errorString())); + } + qDebug() << "done.\n"; +} + void QInstallerTools::compressPaths(const QStringList &paths, const QString &archivePath) { QFile archive(archivePath); @@ -106,7 +132,6 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt 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); @@ -133,7 +158,7 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt 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( + qDebug() << QString::fromLatin1("Generating meta data for package '%1' using '%2'.").arg( it->name, packageXmlPath); // remove existing entry for this component from existing Updates.xml @@ -189,7 +214,7 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt const QString value = node.toElement().text(); QDomElement element = doc.createElement(key); - for (int i = 0; i < node.attributes().size(); i++) { + for (int i = 0; i < node.attributes().size(); ++i) { element.setAttribute(node.attributes().item(i).toAttr().name(), node.attributes().item(i).toAttr().value()); } @@ -213,14 +238,12 @@ 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) + const QDir componentDataDir = QString::fromLatin1("%1/%2/data").arg(dataDir, it->name); + const QFileInfoList entries = componentDataDir.exists() ? componentDataDir.entryInfoList(filters | QDir::Dirs) : QDir(QString::fromLatin1("%1/%2").arg(dataDir, it->name)).entryInfoList(filters); + qDebug() << QString::fromLatin1("calculate size of directory: %1").arg(componentDataDir.absolutePath()); foreach (const QFileInfo &fi, entries) { - if (fi.isHidden()) - continue; - try { if (fi.isDir()) { QDirIterator recursDirIt(fi.filePath(), QDirIterator::Subdirectories); @@ -285,15 +308,9 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt requiresAdminRightsElement.appendChild(doc.createTextNode(QLatin1String("true"))); } - qDebug() << "\tCopying associated script" << script << "into the meta package..."; + const QString kind(QLatin1String("script")); 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."; - } + copyWithException(fromLocation, toLocation, kind); } // copy user interfaces @@ -311,17 +328,12 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt "copying user interfaces of '%2'.").arg(node.toElement().text(), it->name)); } + const QString kind(QLatin1String("user interface")); for (QStringList::const_iterator ui = uis.begin(); ui != uis.end(); ++ui) { - qDebug() << "\tCopying associated user interface" << *ui << "into the meta package..."; + const QString source(QString::fromLatin1("%1/meta/%2").arg(it->directory, *ui)); + const QString target(QString::fromLatin1("%1/%2/%3").arg(metapath, it->name, *ui)); 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"; - } + copyWithException(source, target, kind); } } @@ -346,17 +358,12 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt "while copying translations of '%2'.").arg(node.toElement().text(), it->name)); } + const QString kind(QLatin1String("translation")); for (QStringList::const_iterator qm = qms.begin(); qm != qms.end(); ++qm) { - qDebug() << "\tCopying associated translation" << *qm << "into the meta package..."; + const QString source(QString::fromLatin1("%1/meta/%2").arg(it->directory, *qm)); + const QString target(QString::fromLatin1("%1/%2/%3").arg(metapath, it->name, *qm)); 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"; - } + copyWithException(source, target, kind); } } @@ -381,15 +388,11 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt "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."; - } + + + const QString kind(QLatin1String("license")); + const QString target(QString::fromLatin1("%1/%2/%3").arg(metapath, it->name, licenseFile)); + copyWithException(sourceFile, target, kind); // Translated License files for (int j = 0; j < translations.size(); ++j) { @@ -405,14 +408,13 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt 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 QString translated_kind(QLatin1String("license")); + const QString translated_target(QString::fromLatin1("%1/%2/%3").arg(metapath, it->name, + translatedLicenseFile)); + try { + copyWithException(translatedSourceFile, translated_target, translated_kind); + } catch(...) { + // ignore, that's just about the translations } } } @@ -434,7 +436,7 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt 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")); @@ -449,7 +451,7 @@ 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) @@ -507,11 +509,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()) diff --git a/tools/common/repositorygen.h b/tools/common/repositorygen.h index 50349c8b6..85560a7fa 100644 --- a/tools/common/repositorygen.h +++ b/tools/common/repositorygen.h @@ -67,6 +67,7 @@ enum FilterType { QHash<QString, QString> buildPathToVersionMapping(const PackageInfoVector &info); +void copyWithException(const QString &source, const QString &target, const QString &kind = QString()); void compressMetaDirectories(const QString &repoDir); void compressPaths(const QStringList &paths, const QString &archivePath); void compressMetaDirectories(const QString &repoDir, const QString &baseDir, 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 |