diff options
-rw-r--r-- | installerfw.pri | 1 | ||||
-rw-r--r-- | src/libs/ifwtools/binarycreator.cpp (renamed from tools/binarycreator/binarycreator.cpp) | 415 | ||||
-rw-r--r-- | src/libs/ifwtools/binarycreator.h | 123 | ||||
-rw-r--r-- | src/libs/ifwtools/ifwtools.pri | 19 | ||||
-rw-r--r-- | src/libs/ifwtools/ifwtools_global.h | 44 | ||||
-rw-r--r-- | src/libs/ifwtools/rcc/qcorecmdlineargs_p.h (renamed from tools/binarycreator/rcc/qcorecmdlineargs_p.h) | 6 | ||||
-rw-r--r-- | src/libs/ifwtools/rcc/rcc.cpp (renamed from tools/binarycreator/rcc/rcc.cpp) | 0 | ||||
-rw-r--r-- | src/libs/ifwtools/rcc/rcc.h (renamed from tools/binarycreator/rcc/rcc.h) | 0 | ||||
-rw-r--r-- | src/libs/ifwtools/rcc/rccmain.cpp (renamed from tools/binarycreator/rcc/rccmain.cpp) | 2 | ||||
-rw-r--r-- | src/libs/ifwtools/repositorygen.cpp (renamed from tools/common/repositorygen.cpp) | 31 | ||||
-rw-r--r-- | src/libs/ifwtools/repositorygen.h (renamed from tools/common/repositorygen.h) | 37 | ||||
-rw-r--r-- | src/libs/ifwtools/resources/copylibsintobundle.sh (renamed from tools/binarycreator/resources/copylibsintobundle.sh) | 0 | ||||
-rw-r--r-- | src/libs/ifwtools/resources/default_icon_mac.icns (renamed from tools/binarycreator/resources/default_icon_mac.icns) | bin | 118992 -> 118992 bytes | |||
-rw-r--r-- | src/libs/ifwtools/resources/ifwtools.qrc | 7 | ||||
-rw-r--r-- | src/libs/installer/installer.pro | 1 | ||||
-rw-r--r-- | tests/auto/tools/repotest/repotest.pro | 1 | ||||
-rw-r--r-- | tools/archivegen/archivegen.pro | 6 | ||||
-rw-r--r-- | tools/binarycreator/binarycreator.pro | 9 | ||||
-rw-r--r-- | tools/binarycreator/binarycreator.qrc | 7 | ||||
-rw-r--r-- | tools/binarycreator/main.cpp | 210 | ||||
-rw-r--r-- | tools/repogen/repogen.cpp | 4 | ||||
-rw-r--r-- | tools/repogen/repogen.pri | 1 | ||||
-rw-r--r-- | tools/repogen/repogen.pro | 5 |
23 files changed, 552 insertions, 377 deletions
diff --git a/installerfw.pri b/installerfw.pri index a1abf41e3..e38bb5108 100644 --- a/installerfw.pri +++ b/installerfw.pri @@ -92,6 +92,7 @@ macx:QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden INCLUDEPATH += \ $$IFW_SOURCE_TREE/src/libs/7zip \ $$IFW_SOURCE_TREE/src/libs/kdtools \ + $$IFW_SOURCE_TREE/src/libs/ifwtools \ $$IFW_SOURCE_TREE/src/libs/installer win32:INCLUDEPATH += $$IFW_SOURCE_TREE/src/libs/7zip/win/CPP unix:INCLUDEPATH += $$IFW_SOURCE_TREE/src/libs/7zip/unix/CPP diff --git a/tools/binarycreator/binarycreator.cpp b/src/libs/ifwtools/binarycreator.cpp index f6662615e..b3119f5be 100644 --- a/tools/binarycreator/binarycreator.cpp +++ b/src/libs/ifwtools/binarycreator.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -25,19 +25,18 @@ ** $QT_END_LICENSE$ ** **************************************************************************/ -#include "common/repositorygen.h" -#include <qtpatch.h> +#include "binarycreator.h" -#include <binarycontent.h> -#include <binaryformat.h> -#include <errors.h> -#include <fileio.h> -#include <fileutils.h> -#include <init.h> -#include <repository.h> -#include <settings.h> -#include <utils.h> +#include "qtpatch.h" +#include "repositorygen.h" +#include "binarycontent.h" +#include "errors.h" +#include "fileio.h" +#include "init.h" +#include "repository.h" +#include "settings.h" +#include "utils.h" #include <QDateTime> #include <QDirIterator> @@ -60,45 +59,7 @@ #endif using namespace QInstaller; - -struct Input { - QString outputPath; - QString installerExePath; - QInstallerTools::PackageInfoVector packages; - QInstaller::ResourceCollectionManager manager; -}; - -class BundleBackup -{ -public: - explicit BundleBackup(const QString &bundle = QString()) - : bundle(bundle) - { - if (!bundle.isEmpty() && QFileInfo(bundle).exists()) { - backup = generateTemporaryFileName(bundle); - QFile::rename(bundle, backup); - } - } - - ~BundleBackup() - { - if (!backup.isEmpty()) { - removeDirectory(bundle); - QFile::rename(backup, bundle); - } - } - - void release() const - { - if (!backup.isEmpty()) - removeDirectory(backup); - backup.clear(); - } - -private: - const QString bundle; - mutable QString backup; -}; +using namespace QInstallerTools; #ifndef Q_OS_WIN static void chmod755(const QString &absolutFilePath) @@ -563,24 +524,6 @@ static int runRcc(const QStringList &args) return result; } -class WorkingDirectoryChange -{ -public: - explicit WorkingDirectoryChange(const QString &path) - : oldPath(QDir::currentPath()) - { - QDir::setCurrent(path); - } - - virtual ~WorkingDirectoryChange() - { - QDir::setCurrent(oldPath); - } - -private: - const QString oldPath; -}; - static QSharedPointer<QInstaller::Resource> createDefaultResourceFile(const QString &directory, const QString &binaryName) { @@ -629,63 +572,7 @@ QList<QSharedPointer<QInstaller::Resource> > createBinaryResourceFiles(const QSt return result; } -static void printUsage() -{ - QString suffix; -#ifdef Q_OS_WIN - suffix = QLatin1String(".exe"); -#endif - const QString appName = QFileInfo(QCoreApplication::applicationFilePath()).fileName(); - std::cout << "Usage: " << appName << " [options] target" << std::endl; - std::cout << std::endl; - std::cout << "Options:" << std::endl; - - std::cout << " -t|--template file Use file as installer template binary" << std::endl; - std::cout << " If this parameter is not given, the template used" << std::endl; - std::cout << " defaults to installerbase." << std::endl; - - QInstallerTools::printRepositoryGenOptions(); - - std::cout << " -c|--config file The file containing the installer configuration" << std::endl; - - std::cout << " -n|--online-only Do not add any package into the installer" << std::endl; - std::cout << " (for online only installers)" << std::endl; - - std::cout << " -f|--offline-only Forces the installer to act as an offline installer, " << std::endl; - std::cout << " i.e. never access online repositories" << std::endl; - - std::cout << " -r|--resources r1,.,rn include the given resource files into the binary" << std::endl; - - std::cout << " -v|--verbose Verbose output" << std::endl; - std::cout << " -rcc|--compile-resource Compiles the default resource and outputs the result into" - << std::endl; - std::cout << " 'update.rcc' in the current path." << std::endl; -#ifdef Q_OS_MACOS - std::cout << " -s|--sign identity Sign generated app bundle using the given code " << std::endl; - std::cout << " signing identity" << std::endl; -#endif - std::cout << std::endl; - std::cout << "Packages are to be found in the current working directory and get listed as " - "their names" << std::endl << std::endl; - std::cout << "Example (offline installer):" << std::endl; - char sep = QDir::separator().toLatin1(); - std::cout << " " << appName << " --offline-only -c installer-config" << sep << "config.xml -p " - "packages-directory -t installerbase" << suffix << " SDKInstaller" << suffix << std::endl; - std::cout << "Creates an offline installer for the SDK, containing all dependencies." << std::endl; - std::cout << std::endl; - std::cout << "Example (online installer):" << std::endl; - std::cout << " " << appName << " -c installer-config" << sep << "config.xml -p packages-directory " - "-e org.qt-project.sdk.qt,org.qt-project.qtcreator -t installerbase" << suffix << " SDKInstaller" - << suffix << std::endl; - std::cout << std::endl; - std::cout << "Creates an installer for the SDK without qt and qt creator." << std::endl; - std::cout << std::endl; - std::cout << "Example update.rcc:" << std::endl; - std::cout << " " << appName << " -c installer-config" << sep << "config.xml -p packages-directory " - "-rcc" << std::endl; -} - -void copyConfigData(const QString &configFile, const QString &targetDir) +void QInstallerTools::copyConfigData(const QString &configFile, const QString &targetDir) { qDebug() << "Begin to copy configuration file and data."; @@ -763,187 +650,87 @@ void copyConfigData(const QString &configFile, const QString &targetDir) qDebug() << "done.\n"; } -static int printErrorAndUsageAndExit(const QString &err) +int QInstallerTools::createBinary(BinaryCreatorArgs args, QString &argumentError) { - std::cerr << qPrintable(err) << std::endl << std::endl; - printUsage(); - return EXIT_FAILURE; -} - -int main(int argc, char **argv) -{ -// increase maximum numbers of file descriptors + // increase maximum numbers of file descriptors #if defined (Q_OS_MACOS) struct rlimit rl; getrlimit(RLIMIT_NOFILE, &rl); rl.rlim_cur = qMin(static_cast<rlim_t>(OPEN_MAX), rl.rlim_max); setrlimit(RLIMIT_NOFILE, &rl); #endif - QCoreApplication app(argc, argv); - - QInstaller::init(); - - QString templateBinary = QLatin1String("installerbase"); QString suffix; #ifdef Q_OS_WIN suffix = QLatin1String(".exe"); - templateBinary = templateBinary + suffix; + if (!args.target.endsWith(suffix)) + args.target = args.target + suffix; #endif - if (!QFileInfo(templateBinary).exists()) - templateBinary = QString::fromLatin1("%1/%2").arg(qApp->applicationDirPath(), templateBinary); - - QString target; - QString configFile; - QStringList packagesDirectories; - QStringList repositoryDirectories; - bool onlineOnly = false; - bool offlineOnly = false; - QStringList resources; - QStringList filteredPackages; - QInstallerTools::FilterType ftype = QInstallerTools::Exclude; - bool compileResource = false; - QString signingIdentity; - - const QStringList args = app.arguments().mid(1); - for (QStringList::const_iterator it = args.begin(); it != args.end(); ++it) { - if (*it == QLatin1String("-h") || *it == QLatin1String("--help")) { - printUsage(); - return 0; - } else if (*it == QLatin1String("-p") || *it == QLatin1String("--packages")) { - ++it; - if (it == args.end()) { - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Packages parameter missing argument.")); - } - if (!QFileInfo(*it).exists()) { - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Package directory not found at the " - "specified location.")); - } - packagesDirectories.append(*it); - } else if (*it == QLatin1String("--repository")) { - ++it; - if (it == args.end()) { - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Repository parameter missing argument.")); - } - if (QFileInfo(*it).exists()) { - repositoryDirectories.append(*it); - } else { - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Only local filesystem repositories now supported.")); - } - } else if (*it == QLatin1String("-e") || *it == QLatin1String("--exclude")) { - ++it; - if (!filteredPackages.isEmpty()) - return printErrorAndUsageAndExit(QString::fromLatin1("Error: --include and --exclude are mutually " - "exclusive. Use either one or the other.")); - if (it == args.end() || it->startsWith(QLatin1String("-"))) - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Package to exclude missing.")); - filteredPackages = it->split(QLatin1Char(',')); - } else if (*it == QLatin1String("-i") || *it == QLatin1String("--include")) { - ++it; - if (!filteredPackages.isEmpty()) - return printErrorAndUsageAndExit(QString::fromLatin1("Error: --include and --exclude are mutually " - "exclusive. Use either one or the other.")); - if (it == args.end() || it->startsWith(QLatin1String("-"))) - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Package to include missing.")); - filteredPackages = it->split(QLatin1Char(',')); - ftype = QInstallerTools::Include; + + // Begin check arguments + foreach (const QString &packageDir, args.packagesDirectories) { + if (!QFileInfo(packageDir).exists()) { + argumentError = QString::fromLatin1("Error: Package directory not found at the specified location."); + return EXIT_FAILURE; } - else if (*it == QLatin1String("-v") || *it == QLatin1String("--verbose")) { - QInstaller::setVerbose(true); - } else if (*it == QLatin1String("-n") || *it == QLatin1String("--online-only")) { - if (!filteredPackages.isEmpty()) { - return printErrorAndUsageAndExit(QString::fromLatin1("Error: 'online-only' option cannot be used " - "in conjunction with the 'include' or 'exclude' option. An 'online-only' installer will never " - "contain any components apart from the root component.")); - } - onlineOnly = true; - } else if (*it == QLatin1String("-f") || *it == QLatin1String("--offline-only")) { - offlineOnly = true; - } else if (*it == QLatin1String("-t") || *it == QLatin1String("--template")) { - ++it; - if (it == args.end()) { - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Template parameter missing argument.")); - } - templateBinary = *it; -#ifdef Q_OS_WIN - if (!templateBinary.endsWith(suffix)) - templateBinary = templateBinary + suffix; -#endif - if (!QFileInfo(templateBinary).exists()) { - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Template not found at the specified " - "location.")); - } - } else if (*it == QLatin1String("-c") || *it == QLatin1String("--config")) { - ++it; - if (it == args.end()) - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Config parameter missing argument.")); - const QFileInfo fi(*it); - if (!fi.exists()) { - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Config file %1 not found at the " - "specified location.").arg(*it)); - } - if (!fi.isFile()) { - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Configuration %1 is not a file.") - .arg(*it)); - } - if (!fi.isReadable()) { - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Config file %1 is not readable.") - .arg(*it)); - } - configFile = *it; - } else if (*it == QLatin1String("-r") || *it == QLatin1String("--resources")) { - ++it; - if (it == args.end() || it->startsWith(QLatin1String("-"))) - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Resource files to include are missing.")); - resources = it->split(QLatin1Char(',')); - } else if (*it == QLatin1String("--ignore-translations") - || *it == QLatin1String("--ignore-invalid-packages")) { - continue; - } else if (*it == QLatin1String("-rcc") || *it == QLatin1String("--compile-resource")) { - compileResource = true; -#ifdef Q_OS_MACOS - } else if (*it == QLatin1String("-s") || *it == QLatin1String("--sign")) { - ++it; - if (it == args.end() || it->startsWith(QLatin1String("-"))) - return printErrorAndUsageAndExit(QString::fromLatin1("Error: No code signing identity specified.")); - signingIdentity = *it; -#endif - } else { - if (it->startsWith(QLatin1String("-"))) { - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Unknown option \"%1\" used. Maybe you " - "are using an old syntax.").arg(*it)); - } else if (target.isEmpty()) { - target = *it; + } + foreach (const QString &repositoryDir, args.repositoryDirectories) { + if (!QFileInfo(repositoryDir).exists()) { + argumentError = QString::fromLatin1("Error: Only local filesystem repositories now supported."); + return EXIT_FAILURE; + } + } + if (!args.filteredPackages.isEmpty() && args.onlineOnly) { + argumentError = QString::fromLatin1("Error: 'online-only' option cannot be used " + "in conjunction with the 'include' or 'exclude' option. An 'online-only' installer will never " + "contain any components apart from the root component."); + return EXIT_FAILURE; + } #ifdef Q_OS_WIN - if (!target.endsWith(suffix)) - target = target + suffix; + if (!args.templateBinary.endsWith(suffix)) + args.templateBinary = args.templateBinary + suffix; #endif - } else { - return printErrorAndUsageAndExit(QString::fromLatin1("Error: You are using an old syntax please add the " - "component name with the include option") - .arg(*it)); - } - } + if (!QFileInfo(args.templateBinary).exists()) { + argumentError = QString::fromLatin1("Error: Template not found at the specified location."); + return EXIT_FAILURE; } - - if (onlineOnly && offlineOnly) { - return printErrorAndUsageAndExit(QString::fromLatin1("You cannot use --online-only and " - "--offline-only at the same time.")); + const QFileInfo fi(args.configFile); + if (!fi.exists()) { + argumentError = QString::fromLatin1("Error: Config file %1 not found at the " + "specified location.").arg(fi.absoluteFilePath()); + return EXIT_FAILURE; } - - if (onlineOnly) { - filteredPackages.append(QLatin1String("X_fake_filter_component_for_online_only_installer_X")); - ftype = QInstallerTools::Include; + if (!fi.isFile()) { + argumentError = QString::fromLatin1("Error: Configuration %1 is not a file.") + .arg(fi.absoluteFilePath()); + return EXIT_FAILURE; } - - if (target.isEmpty() && !compileResource) - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Target parameter missing.")); - - if (configFile.isEmpty()) - return printErrorAndUsageAndExit(QString::fromLatin1("Error: No configuration file selected.")); - - if (packagesDirectories.isEmpty() && repositoryDirectories.isEmpty()) - return printErrorAndUsageAndExit(QString::fromLatin1("Error: Both Package directory and Repository parameters missing.")); - + if (!fi.isReadable()) { + argumentError = QString::fromLatin1("Error: Config file %1 is not readable.") + .arg(fi.absoluteFilePath()); + return EXIT_FAILURE; + } + if (args.onlineOnly && args.offlineOnly) { + argumentError = QString::fromLatin1("You cannot use --online-only and " + "--offline-only at the same time."); + return EXIT_FAILURE; + } + if (args.target.isEmpty() && !args.compileResource) { + argumentError = QString::fromLatin1("Error: Target parameter missing."); + return EXIT_FAILURE; + } + if (args.configFile.isEmpty()) { + argumentError = QString::fromLatin1("Error: No configuration file selected."); + return EXIT_FAILURE; + } + if (args.packagesDirectories.isEmpty() && args.repositoryDirectories.isEmpty()) { + argumentError = QString::fromLatin1("Error: Both Package directory and Repository parameters missing."); + return EXIT_FAILURE; + } + if (args.onlineOnly) { + args.filteredPackages.append(QLatin1String("X_fake_filter_component_for_online_only_installer_X")); + args.ftype = QInstallerTools::Include; + } + // End check arguments qDebug() << "Parsed arguments, ok."; Input input; @@ -955,71 +742,71 @@ int main(int argc, char **argv) tmp2.setAutoRemove(false); const QString tmpRepoDir = tmp2.path(); try { - const Settings settings = Settings::fromFileAndPrefix(configFile, QFileInfo(configFile) + const Settings settings = Settings::fromFileAndPrefix(args.configFile, QFileInfo(args.configFile) .absolutePath()); // Note: the order here is important - QInstallerTools::PackageInfoVector packages; + PackageInfoVector packages; // 1; update the list of available compressed packages - if (!repositoryDirectories.isEmpty()) { + if (!args.repositoryDirectories.isEmpty()) { // 1.1; search packages - QInstallerTools::PackageInfoVector precompressedPackages = QInstallerTools::createListOfRepositoryPackages(repositoryDirectories, - &filteredPackages, ftype); + PackageInfoVector precompressedPackages = createListOfRepositoryPackages(args.repositoryDirectories, + &args.filteredPackages, args.ftype); // 1.2; add to common vector packages.append(precompressedPackages); } // 2; update the list of available prepared packages - if (!packagesDirectories.isEmpty()) { + if (!args.packagesDirectories.isEmpty()) { // 2.1; search packages - QInstallerTools::PackageInfoVector preparedPackages = QInstallerTools::createListOfPackages(packagesDirectories, - &filteredPackages, ftype); + PackageInfoVector preparedPackages = createListOfPackages(args.packagesDirectories, + &args.filteredPackages, args.ftype); // 2.2; copy the packages data and setup the packages vector with the files we copied, // must happen before copying meta data because files will be compressed if // needed and meta data generation relies on this - QInstallerTools::copyComponentData(packagesDirectories, tmpRepoDir, &preparedPackages); + copyComponentData(args.packagesDirectories, tmpRepoDir, &preparedPackages); // 2.3; add to common vector packages.append(preparedPackages); } // 3; copy the meta data of the available packages, generate Updates.xml - QInstallerTools::copyMetaData(tmpMetaDir, tmpRepoDir, packages, settings + copyMetaData(tmpMetaDir, tmpRepoDir, packages, settings .applicationName(), settings.version(), QStringList()); // 4; copy the configuration file and and icons etc. - copyConfigData(configFile, tmpMetaDir + QLatin1String("/installer-config")); + copyConfigData(args.configFile, tmpMetaDir + QLatin1String("/installer-config")); { QSettings confInternal(tmpMetaDir + QLatin1String("/config/config-internal.ini") , QSettings::IniFormat); // assume offline installer if there are no repositories and no //--online-only not set - offlineOnly = offlineOnly | settings.repositories().isEmpty(); - if (onlineOnly) - offlineOnly = !onlineOnly; - confInternal.setValue(QLatin1String("offlineOnly"), offlineOnly); + args.offlineOnly = args.offlineOnly | settings.repositories().isEmpty(); + if (args.onlineOnly) + args.offlineOnly = !args.onlineOnly; + confInternal.setValue(QLatin1String("offlineOnly"), args.offlineOnly); } #ifdef Q_OS_MACOS // on mac, we enforce building a bundle - if (!target.endsWith(QLatin1String(".app")) && !target.endsWith(QLatin1String(".dmg"))) - target += QLatin1String(".app"); + if (!args.target.endsWith(QLatin1String(".app")) && !args.target.endsWith(QLatin1String(".dmg"))) + args.target += QLatin1String(".app"); #endif - if (!compileResource) { + if (!args.compileResource) { // 5; put the copied resources into a resource file - QInstaller::ResourceCollection metaCollection("QResources"); + ResourceCollection metaCollection("QResources"); metaCollection.appendResource(createDefaultResourceFile(tmpMetaDir, generateTemporaryFileName())); - metaCollection.appendResources(createBinaryResourceFiles(resources)); + metaCollection.appendResources(createBinaryResourceFiles(args.resources)); input.manager.insertCollection(metaCollection); input.packages = packages; - input.outputPath = target; - input.installerExePath = templateBinary; + input.outputPath = args.target; + input.installerExePath = args.templateBinary; qDebug() << "Creating the binary"; - exitCode = assemble(input, settings, signingIdentity); + exitCode = assemble(input, settings, args.signingIdentity); } else { createDefaultResourceFile(tmpMetaDir, QDir::currentPath() + QLatin1String("/update.rcc")); exitCode = EXIT_SUCCESS; @@ -1033,7 +820,7 @@ int main(int argc, char **argv) } qDebug() << "Cleaning up..."; - const QInstaller::ResourceCollection collection = input.manager.collectionByName("QResources"); + const ResourceCollection collection = input.manager.collectionByName("QResources"); foreach (const QSharedPointer<QInstaller::Resource> &resource, collection.resources()) QFile::remove(QString::fromUtf8(resource->name())); QInstaller::removeDirectory(tmpMetaDir, true); diff --git a/src/libs/ifwtools/binarycreator.h b/src/libs/ifwtools/binarycreator.h new file mode 100644 index 000000000..c20e230a4 --- /dev/null +++ b/src/libs/ifwtools/binarycreator.h @@ -0,0 +1,123 @@ +/************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +**************************************************************************/ + +#ifndef BINARYCREATOR_H +#define BINARYCREATOR_H + +#include "ifwtools_global.h" + +#include "repositorygen.h" +#include "fileutils.h" +#include "binaryformat.h" + +#include <QtCore/QString> +#include <QtCore/QFile> + +namespace QInstallerTools { + +struct Input +{ + QString outputPath; + QString installerExePath; + QInstallerTools::PackageInfoVector packages; + QInstaller::ResourceCollectionManager manager; +}; + +struct IFWTOOLS_EXPORT BinaryCreatorArgs +{ + QString target; + QString configFile; + QString templateBinary; + QStringList packagesDirectories; + QStringList repositoryDirectories; + bool onlineOnly = false; + bool offlineOnly = false; + QStringList resources; + QStringList filteredPackages; + FilterType ftype = QInstallerTools::Exclude; + bool compileResource = false; + QString signingIdentity; +}; + +class BundleBackup +{ +public: + explicit BundleBackup(const QString &bundle = QString()) + : bundle(bundle) + { + if (!bundle.isEmpty() && QFileInfo(bundle).exists()) { + backup = QInstaller::generateTemporaryFileName(bundle); + QFile::rename(bundle, backup); + } + } + + ~BundleBackup() + { + if (!backup.isEmpty()) { + QInstaller::removeDirectory(bundle); + QFile::rename(backup, bundle); + } + } + + void release() const + { + if (!backup.isEmpty()) + QInstaller::removeDirectory(backup); + backup.clear(); + } + +private: + const QString bundle; + mutable QString backup; +}; + +class WorkingDirectoryChange +{ +public: + explicit WorkingDirectoryChange(const QString &path) + : oldPath(QDir::currentPath()) + { + QDir::setCurrent(path); + } + + virtual ~WorkingDirectoryChange() + { + QDir::setCurrent(oldPath); + } + +private: + const QString oldPath; +}; + +void copyConfigData(const QString &configFile, const QString &targetDir); + +int IFWTOOLS_EXPORT createBinary(BinaryCreatorArgs args, QString &argumentError); + +} // namespace QInstallerTools + +#endif // BINARYCREATOR_H diff --git a/src/libs/ifwtools/ifwtools.pri b/src/libs/ifwtools/ifwtools.pri new file mode 100644 index 000000000..0ce7b45fc --- /dev/null +++ b/src/libs/ifwtools/ifwtools.pri @@ -0,0 +1,19 @@ +INCLUDEPATH += $$PWD $$PWD/rcc + +DEFINES += BUILD_SHARED_IFWTOOLS + +HEADERS += $$PWD/rcc/rcc.h \ + $$PWD/rcc/qcorecmdlineargs_p.h + +SOURCES += $$PWD/rcc/rcc.cpp \ + $$PWD/rcc/rccmain.cpp + +HEADERS += $$PWD/ifwtools_global.h \ + $$PWD/repositorygen.h \ + $$PWD/binarycreator.h + +SOURCES += $$PWD/repositorygen.cpp \ + $$PWD/binarycreator.cpp + +RESOURCES += $$PWD/resources/ifwtools.qrc + diff --git a/src/libs/ifwtools/ifwtools_global.h b/src/libs/ifwtools/ifwtools_global.h new file mode 100644 index 000000000..ff04efce8 --- /dev/null +++ b/src/libs/ifwtools/ifwtools_global.h @@ -0,0 +1,44 @@ +/************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +**************************************************************************/ + +#ifndef IFWTOOLS_GLOBAL_H +#define IFWTOOLS_GLOBAL_H + +#include <QtCore/QtGlobal> + +#ifndef QT_STATIC +# ifdef BUILD_SHARED_IFWTOOLS +# define IFWTOOLS_EXPORT Q_DECL_EXPORT +# else +# define IFWTOOLS_EXPORT Q_DECL_IMPORT +# endif +#else +# define IFWTOOLS_EXPORT +#endif + +#endif //IFWTOOLS_GLOBAL_H diff --git a/tools/binarycreator/rcc/qcorecmdlineargs_p.h b/src/libs/ifwtools/rcc/qcorecmdlineargs_p.h index 9ea85de8a..9c55a43cd 100644 --- a/tools/binarycreator/rcc/qcorecmdlineargs_p.h +++ b/src/libs/ifwtools/rcc/qcorecmdlineargs_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -40,8 +40,8 @@ // We mean it. // -#include "QtCore/qstring.h" -#include "QtCore/qstringlist.h" +#include <QtCore/qstring.h> +#include <QtCore/qstringlist.h> QT_BEGIN_NAMESPACE diff --git a/tools/binarycreator/rcc/rcc.cpp b/src/libs/ifwtools/rcc/rcc.cpp index 10b7cbc4f..10b7cbc4f 100644 --- a/tools/binarycreator/rcc/rcc.cpp +++ b/src/libs/ifwtools/rcc/rcc.cpp diff --git a/tools/binarycreator/rcc/rcc.h b/src/libs/ifwtools/rcc/rcc.h index ecf408dbc..ecf408dbc 100644 --- a/tools/binarycreator/rcc/rcc.h +++ b/src/libs/ifwtools/rcc/rcc.h diff --git a/tools/binarycreator/rcc/rccmain.cpp b/src/libs/ifwtools/rcc/rccmain.cpp index 8c33997dd..47d8fa8de 100644 --- a/tools/binarycreator/rcc/rccmain.cpp +++ b/src/libs/ifwtools/rcc/rccmain.cpp @@ -26,7 +26,7 @@ ** **************************************************************************/ -#include <rcc.h> +#include "rcc.h" #include "qcorecmdlineargs_p.h" #include <QDebug> diff --git a/tools/common/repositorygen.cpp b/src/libs/ifwtools/repositorygen.cpp index 45ea0a541..819ab1ac8 100644 --- a/tools/common/repositorygen.cpp +++ b/src/libs/ifwtools/repositorygen.cpp @@ -25,23 +25,24 @@ ** $QT_END_LICENSE$ ** **************************************************************************/ + #include "repositorygen.h" -#include <constants.h> -#include <fileio.h> -#include <fileutils.h> -#include <errors.h> -#include <globals.h> -#include <lib7z_create.h> -#include <lib7z_extract.h> -#include <lib7z_facade.h> -#include <lib7z_list.h> -#include <settings.h> -#include <qinstallerglobal.h> -#include <utils.h> -#include <scriptengine.h> - -#include <updater.h> +#include "constants.h" +#include "fileio.h" +#include "fileutils.h" +#include "errors.h" +#include "globals.h" +#include "lib7z_create.h" +#include "lib7z_extract.h" +#include "lib7z_facade.h" +#include "lib7z_list.h" +#include "settings.h" +#include "qinstallerglobal.h" +#include "utils.h" +#include "scriptengine.h" + +#include "updater.h" #include <QtCore/QDirIterator> #include <QtCore/QRegExp> diff --git a/tools/common/repositorygen.h b/src/libs/ifwtools/repositorygen.h index f5202c1fc..49d0a51dd 100644 --- a/tools/common/repositorygen.h +++ b/src/libs/ifwtools/repositorygen.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -26,8 +26,10 @@ ** **************************************************************************/ -#ifndef QINSTALLER_REPOSITORYGEN_H -#define QINSTALLER_REPOSITORYGEN_H +#ifndef REPOSITORYGEN_H +#define REPOSITORYGEN_H + +#include "ifwtools_global.h" #include <QHash> #include <QString> @@ -37,8 +39,7 @@ namespace QInstallerTools { - -struct PackageInfo +struct IFWTOOLS_EXPORT PackageInfo { QString name; QString version; @@ -50,38 +51,38 @@ struct PackageInfo }; typedef QVector<PackageInfo> PackageInfoVector; -enum FilterType { +enum IFWTOOLS_EXPORT FilterType { Include, Exclude }; -void printRepositoryGenOptions(); -QString makePathAbsolute(const QString &path); -void copyWithException(const QString &source, const QString &target, const QString &kind = QString()); +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()); -PackageInfoVector createListOfPackages(const QStringList &packagesDirectories, QStringList *packagesToFilter, +PackageInfoVector IFWTOOLS_EXPORT createListOfPackages(const QStringList &packagesDirectories, QStringList *packagesToFilter, FilterType ftype); -PackageInfoVector createListOfRepositoryPackages(const QStringList &repositoryDirectories, QStringList *packagesToFilter, +PackageInfoVector IFWTOOLS_EXPORT createListOfRepositoryPackages(const QStringList &repositoryDirectories, QStringList *packagesToFilter, FilterType filterType); -QHash<QString, QString> buildPathToVersionMapping(const PackageInfoVector &info); +QHash<QString, QString> IFWTOOLS_EXPORT buildPathToVersionMapping(const PackageInfoVector &info); -void compressMetaDirectories(const QString &repoDir, const QString &existingUnite7zUrl, +void IFWTOOLS_EXPORT compressMetaDirectories(const QString &repoDir, const QString &existingUnite7zUrl, const QHash<QString, QString> &versionMapping, bool createSplitMetadata, bool createUnifiedMetadata); 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, +void IFWTOOLS_EXPORT copyMetaData(const QString &outDir, const QString &dataDir, const PackageInfoVector &packages, const QString &appName, const QString& appVersion, const QStringList &uniteMetadatas); -void copyComponentData(const QStringList &packageDir, const QString &repoDir, PackageInfoVector *const infos); +void IFWTOOLS_EXPORT copyComponentData(const QStringList &packageDir, const QString &repoDir, PackageInfoVector *const infos); -void filterNewComponents(const QString &repositoryDir, QInstallerTools::PackageInfoVector &packages); +void IFWTOOLS_EXPORT filterNewComponents(const QString &repositoryDir, QInstallerTools::PackageInfoVector &packages); -QString existingUniteMeta7z(const QString &repositoryDir); +QString IFWTOOLS_EXPORT existingUniteMeta7z(const QString &repositoryDir); } // namespace QInstallerTools -#endif // QINSTALLER_REPOSITORYGEN_H +#endif // REPOSITORYGEN_H diff --git a/tools/binarycreator/resources/copylibsintobundle.sh b/src/libs/ifwtools/resources/copylibsintobundle.sh index 1ad5da4db..1ad5da4db 100644 --- a/tools/binarycreator/resources/copylibsintobundle.sh +++ b/src/libs/ifwtools/resources/copylibsintobundle.sh diff --git a/tools/binarycreator/resources/default_icon_mac.icns b/src/libs/ifwtools/resources/default_icon_mac.icns Binary files differindex 8d870d649..8d870d649 100644 --- a/tools/binarycreator/resources/default_icon_mac.icns +++ b/src/libs/ifwtools/resources/default_icon_mac.icns diff --git a/src/libs/ifwtools/resources/ifwtools.qrc b/src/libs/ifwtools/resources/ifwtools.qrc new file mode 100644 index 000000000..8b73a8442 --- /dev/null +++ b/src/libs/ifwtools/resources/ifwtools.qrc @@ -0,0 +1,7 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>default_icon_mac.icns</file> + <file>copylibsintobundle.sh</file> + <file alias="resources/installerbase.ico">../../../sdk/installerbase.ico</file> +</qresource> +</RCC> diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro index d1e21bb63..2462dbe63 100644 --- a/src/libs/installer/installer.pro +++ b/src/libs/installer/installer.pro @@ -6,6 +6,7 @@ CONFIG += staticlib include(../7zip/7zip.pri) include(../kdtools/kdtools.pri) +include(../ifwtools/ifwtools.pri) include(../../../installerfw.pri) # productkeycheck API diff --git a/tests/auto/tools/repotest/repotest.pro b/tests/auto/tools/repotest/repotest.pro index 73d482638..930abafd6 100644 --- a/tests/auto/tools/repotest/repotest.pro +++ b/tests/auto/tools/repotest/repotest.pro @@ -1,5 +1,4 @@ include(../../qttest.pri) -include(../../../../tools/repogen/repogen.pri) QT -= gui diff --git a/tools/archivegen/archivegen.pro b/tools/archivegen/archivegen.pro index 2cb8b6bdc..0a5032d2f 100644 --- a/tools/archivegen/archivegen.pro +++ b/tools/archivegen/archivegen.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = archivegen -INCLUDEPATH += . .. ../common +INCLUDEPATH += . .. include(../../installerfw.pri) @@ -11,9 +11,7 @@ LIBS += -l7z CONFIG += console DESTDIR = $$IFW_APP_PATH -SOURCES += archive.cpp \ - ../common/repositorygen.cpp -HEADERS += ../common/repositorygen.h +SOURCES += archive.cpp macx:include(../../no_app_bundle.pri) diff --git a/tools/binarycreator/binarycreator.pro b/tools/binarycreator/binarycreator.pro index ddde5e984..994de83c1 100644 --- a/tools/binarycreator/binarycreator.pro +++ b/tools/binarycreator/binarycreator.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = binarycreator -INCLUDEPATH += . .. rcc ../common +INCLUDEPATH += . .. include(../../installerfw.pri) @@ -9,12 +9,7 @@ QT += qml xml CONFIG += console DESTDIR = $$IFW_APP_PATH -SOURCES = binarycreator.cpp \ - rcc/rcc.cpp \ - rcc/rccmain.cpp \ - ../common/repositorygen.cpp -HEADERS = rcc/rcc.h -RESOURCES += binarycreator.qrc +SOURCES = main.cpp macx:include(../../no_app_bundle.pri) diff --git a/tools/binarycreator/binarycreator.qrc b/tools/binarycreator/binarycreator.qrc deleted file mode 100644 index b64e3a21a..000000000 --- a/tools/binarycreator/binarycreator.qrc +++ /dev/null @@ -1,7 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>resources/default_icon_mac.icns</file> - <file>resources/copylibsintobundle.sh</file> - <file alias="resources/installerbase.ico">../../src/sdk/installerbase.ico</file> -</qresource> -</RCC> diff --git a/tools/binarycreator/main.cpp b/tools/binarycreator/main.cpp new file mode 100644 index 000000000..b5a0ae4f7 --- /dev/null +++ b/tools/binarycreator/main.cpp @@ -0,0 +1,210 @@ +/************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +**************************************************************************/ + +#include <binarycreator.h> +#include <init.h> +#include <utils.h> + +#include <QtCore/QDebug> + +#include <iostream> + +using namespace QInstaller; + +static void printUsage() +{ + QString suffix; +#ifdef Q_OS_WIN + suffix = QLatin1String(".exe"); +#endif + const QString appName = QFileInfo(QCoreApplication::applicationFilePath()).fileName(); + std::cout << "Usage: " << appName << " [options] target" << std::endl; + std::cout << std::endl; + std::cout << "Options:" << std::endl; + + std::cout << " -t|--template file Use file as installer template binary" << std::endl; + std::cout << " If this parameter is not given, the template used" << std::endl; + std::cout << " defaults to installerbase." << std::endl; + + QInstallerTools::printRepositoryGenOptions(); + + std::cout << " -c|--config file The file containing the installer configuration" << std::endl; + + std::cout << " -n|--online-only Do not add any package into the installer" << std::endl; + std::cout << " (for online only installers)" << std::endl; + + std::cout << " -f|--offline-only Forces the installer to act as an offline installer, " << std::endl; + std::cout << " i.e. never access online repositories" << std::endl; + + std::cout << " -r|--resources r1,.,rn include the given resource files into the binary" << std::endl; + + std::cout << " -v|--verbose Verbose output" << std::endl; + std::cout << " -rcc|--compile-resource Compiles the default resource and outputs the result into" + << std::endl; + std::cout << " 'update.rcc' in the current path." << std::endl; +#ifdef Q_OS_MACOS + std::cout << " -s|--sign identity Sign generated app bundle using the given code " << std::endl; + std::cout << " signing identity" << std::endl; +#endif + std::cout << std::endl; + std::cout << "Packages are to be found in the current working directory and get listed as " + "their names" << std::endl << std::endl; + std::cout << "Example (offline installer):" << std::endl; + char sep = QDir::separator().toLatin1(); + std::cout << " " << appName << " --offline-only -c installer-config" << sep << "config.xml -p " + "packages-directory -t installerbase" << suffix << " SDKInstaller" << suffix << std::endl; + std::cout << "Creates an offline installer for the SDK, containing all dependencies." << std::endl; + std::cout << std::endl; + std::cout << "Example (online installer):" << std::endl; + std::cout << " " << appName << " -c installer-config" << sep << "config.xml -p packages-directory " + "-e org.qt-project.sdk.qt,org.qt-project.qtcreator -t installerbase" << suffix << " SDKInstaller" + << suffix << std::endl; + std::cout << std::endl; + std::cout << "Creates an installer for the SDK without qt and qt creator." << std::endl; + std::cout << std::endl; + std::cout << "Example update.rcc:" << std::endl; + std::cout << " " << appName << " -c installer-config" << sep << "config.xml -p packages-directory " + "-rcc" << std::endl; +} + +static int printErrorAndUsageAndExit(const QString &err) +{ + std::cerr << qPrintable(err) << std::endl << std::endl; + printUsage(); + return EXIT_FAILURE; +} + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + QInstaller::init(); + + QInstallerTools::BinaryCreatorArgs parsedArgs; + + parsedArgs.templateBinary = QLatin1String("installerbase"); + QString suffix; +#ifdef Q_OS_WIN + suffix = QLatin1String(".exe"); + parsedArgs.templateBinary = parsedArgs.templateBinary + suffix; +#endif + if (!QFileInfo(parsedArgs.templateBinary).exists()) + parsedArgs.templateBinary = QString::fromLatin1("%1/%2").arg(qApp->applicationDirPath(), parsedArgs.templateBinary); + + const QStringList args = app.arguments().mid(1); + for (QStringList::const_iterator it = args.begin(); it != args.end(); ++it) { + if (*it == QLatin1String("-h") || *it == QLatin1String("--help")) { + printUsage(); + return 0; + } else if (*it == QLatin1String("-p") || *it == QLatin1String("--packages")) { + ++it; + if (it == args.end()) { + return printErrorAndUsageAndExit(QString::fromLatin1("Error: Packages parameter missing argument.")); + } + parsedArgs.packagesDirectories.append(*it); + } else if (*it == QLatin1String("--repository")) { + ++it; + if (it == args.end()) { + return printErrorAndUsageAndExit(QString::fromLatin1("Error: Repository parameter missing argument.")); + } + parsedArgs.repositoryDirectories.append(*it); + } else if (*it == QLatin1String("-e") || *it == QLatin1String("--exclude")) { + ++it; + if (!parsedArgs.filteredPackages.isEmpty()) + return printErrorAndUsageAndExit(QString::fromLatin1("Error: --include and --exclude are mutually " + "exclusive. Use either one or the other.")); + if (it == args.end() || it->startsWith(QLatin1String("-"))) + return printErrorAndUsageAndExit(QString::fromLatin1("Error: Package to exclude missing.")); + parsedArgs.filteredPackages = it->split(QLatin1Char(',')); + } else if (*it == QLatin1String("-i") || *it == QLatin1String("--include")) { + ++it; + if (!parsedArgs.filteredPackages.isEmpty()) + return printErrorAndUsageAndExit(QString::fromLatin1("Error: --include and --exclude are mutually " + "exclusive. Use either one or the other.")); + if (it == args.end() || it->startsWith(QLatin1String("-"))) + return printErrorAndUsageAndExit(QString::fromLatin1("Error: Package to include missing.")); + parsedArgs.filteredPackages = it->split(QLatin1Char(',')); + parsedArgs.ftype = QInstallerTools::Include; + } + else if (*it == QLatin1String("-v") || *it == QLatin1String("--verbose")) { + QInstaller::setVerbose(true); + } else if (*it == QLatin1String("-n") || *it == QLatin1String("--online-only")) { + parsedArgs.onlineOnly = true; + } else if (*it == QLatin1String("-f") || *it == QLatin1String("--offline-only")) { + parsedArgs.offlineOnly = true; + } else if (*it == QLatin1String("-t") || *it == QLatin1String("--template")) { + ++it; + if (it == args.end()) { + return printErrorAndUsageAndExit(QString::fromLatin1("Error: Template parameter missing argument.")); + } + parsedArgs.templateBinary = *it; + } else if (*it == QLatin1String("-c") || *it == QLatin1String("--config")) { + ++it; + if (it == args.end()) + return printErrorAndUsageAndExit(QString::fromLatin1("Error: Config parameter missing argument.")); + parsedArgs.configFile = *it; + } else if (*it == QLatin1String("-r") || *it == QLatin1String("--resources")) { + ++it; + if (it == args.end() || it->startsWith(QLatin1String("-"))) + return printErrorAndUsageAndExit(QString::fromLatin1("Error: Resource files to include are missing.")); + parsedArgs.resources = it->split(QLatin1Char(',')); + } else if (*it == QLatin1String("--ignore-translations") + || *it == QLatin1String("--ignore-invalid-packages")) { + continue; + } else if (*it == QLatin1String("-rcc") || *it == QLatin1String("--compile-resource")) { + parsedArgs.compileResource = true; +#ifdef Q_OS_MACOS + } else if (*it == QLatin1String("-s") || *it == QLatin1String("--sign")) { + ++it; + if (it == args.end() || it->startsWith(QLatin1String("-"))) + return printErrorAndUsageAndExit(QString::fromLatin1("Error: No code signing identity specified.")); + parsedArgs.signingIdentity = *it; +#endif + } else { + if (it->startsWith(QLatin1String("-"))) { + return printErrorAndUsageAndExit(QString::fromLatin1("Error: Unknown option \"%1\" used. Maybe you " + "are using an old syntax.").arg(*it)); + } else if (parsedArgs.target.isEmpty()) { + parsedArgs.target = *it; + } else { + return printErrorAndUsageAndExit(QString::fromLatin1("Error: You are using an old syntax please add the " + "component name with the include option") + .arg(*it)); + } + } + } + + QString errorMsg; + if (QInstallerTools::createBinary(parsedArgs, errorMsg) == EXIT_FAILURE) { + if (!errorMsg.isEmpty()) + printErrorAndUsageAndExit(errorMsg); + + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/tools/repogen/repogen.cpp b/tools/repogen/repogen.cpp index 5c67cbc1c..10aa0370b 100644 --- a/tools/repogen/repogen.cpp +++ b/tools/repogen/repogen.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -25,8 +25,8 @@ ** $QT_END_LICENSE$ ** **************************************************************************/ -#include "common/repositorygen.h" +#include <repositorygen.h> #include <errors.h> #include <fileutils.h> #include <init.h> diff --git a/tools/repogen/repogen.pri b/tools/repogen/repogen.pri deleted file mode 100644 index 319b137ff..000000000 --- a/tools/repogen/repogen.pri +++ /dev/null @@ -1 +0,0 @@ -INCLUDEPATH += $$PWD/../common diff --git a/tools/repogen/repogen.pro b/tools/repogen/repogen.pro index 016a8fe8e..0380bb78b 100644 --- a/tools/repogen/repogen.pro +++ b/tools/repogen/repogen.pro @@ -2,7 +2,6 @@ TEMPLATE = app TARGET = repogen INCLUDEPATH += . .. -include(repogen.pri) include(../../installerfw.pri) QT -= gui @@ -11,9 +10,7 @@ QT += qml xml CONFIG += console DESTDIR = $$IFW_APP_PATH -SOURCES += repogen.cpp \ - ../common/repositorygen.cpp -HEADERS += ../common/repositorygen.h +SOURCES += repogen.cpp macx:include(../../no_app_bundle.pri) |