summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortjenssen <tim.jenssen@nokia.com>2012-03-12 19:02:53 +0100
committerTim Jenssen <tim.jenssen@nokia.com>2012-03-12 20:54:15 +0100
commit7c4eb3ae375c18263de34ee1ee3db960142325f2 (patch)
tree5aedb4e51c68a45135e0fc3da0a124c69a9e15ad
parentefec753c4fcbf8fa13cff072b6671b0f4e4d17d0 (diff)
use include and exclude instead of the old package list
- the use of include and exclude everywhere is avoiding overlap with some other options, like --single, --nodeps - the name of single was unclear and is renamed in --update - removed the unused/old dependency code - and moved the content from collectAvailablePackages to createPackages - renamed ftype variable to filterType for better understanding Change-Id: Ia0d3528a964cca7c334ac3b240207e10ca063fa2 Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
-rw-r--r--installerbuilder/binarycreator/binarycreator.cpp23
-rw-r--r--installerbuilder/common/repositorygen.cpp206
-rw-r--r--installerbuilder/common/repositorygen.h4
-rw-r--r--installerbuilder/repogen/repogen.cpp29
4 files changed, 108 insertions, 154 deletions
diff --git a/installerbuilder/binarycreator/binarycreator.cpp b/installerbuilder/binarycreator/binarycreator.cpp
index a3dee0f78..dacf601c2 100644
--- a/installerbuilder/binarycreator/binarycreator.cpp
+++ b/installerbuilder/binarycreator/binarycreator.cpp
@@ -385,7 +385,7 @@ static QStringList createBinaryResourceFiles(const QStringList &resources)
static void printUsage()
{
const QString appName = QFileInfo(QCoreApplication::applicationFilePath()).fileName();
- std::cout << "Usage: " << appName << " [options] target package1 [package2 ...]" << std::endl;
+ std::cout << "Usage: " << appName << " [options] target" << std::endl;
std::cout << std::endl;
std::cout << "Options:" << std::endl;
@@ -408,12 +408,12 @@ static void printUsage()
"their names" << std::endl << std::endl;
std::cout << "Example (offline installer):" << std::endl;
std::cout << " " << appName << " --offline-only -c installer-config -p packages-directory -t "
- "installerbase SDKInstaller.exe com.nokia.sdk" << std::endl;
+ "installerbase SDKInstaller.exe" << 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 -p packages-directory -e com.nokia.sdk.qt,"
- "com.nokia.qtcreator -t installerbase SDKInstaller.exe com.nokia.sdk" << std::endl;
+ "com.nokia.qtcreator -t installerbase SDKInstaller.exe" << 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;
@@ -575,6 +575,9 @@ int main(int argc, char **argv)
else if (*it == QLatin1String("-v") || *it == QLatin1String("--verbose")) {
QInstaller::setVerbose(true);
} else if (*it == QLatin1String("-n") || *it == QLatin1String("--nodeps")) {
+ if (!filteredPackages.isEmpty())
+ return printErrorAndUsageAndExit(QObject::tr("for the --include and --exclude case you also "
+ "have to ensure that nopdeps==false"));
nodeps = true;
} else if (*it == QLatin1String("--offline-only")) {
offlineOnly = true;
@@ -621,20 +624,24 @@ int main(int argc, char **argv)
}
}
+ if (!components.isEmpty()) {
+ std::cout << "Package names at the end of the command are deprecated"
+ " - please use --include or --exclude" << std::endl;
+ if (nodeps)
+ filteredPackages.append(components);
+ ftype = Include;
+ }
+
if (target.isEmpty())
return printErrorAndUsageAndExit(QObject::tr("Error: Target parameter missing."));
- if (components.isEmpty())
- return printErrorAndUsageAndExit(QObject::tr("Error: No components selected."));
-
if (configDir.isEmpty())
return printErrorAndUsageAndExit(QObject::tr("Error: No configuration directory selected."));
qDebug() << "Parsed arguments, ok.";
try {
- PackageInfoVector packages = createListOfPackages(components, packagesDirectory, filteredPackages,
- ftype, !nodeps);
+ PackageInfoVector packages = createListOfPackages(packagesDirectory, filteredPackages, ftype);
const QString metaDir = createMetaDataDirectory(packages, packagesDirectory, configDir);
{
QSettings confInternal(metaDir + "/config/config-internal.ini", QSettings::IniFormat);
diff --git a/installerbuilder/common/repositorygen.cpp b/installerbuilder/common/repositorygen.cpp
index d68e6e4c6..0f2f174da 100644
--- a/installerbuilder/common/repositorygen.cpp
+++ b/installerbuilder/common/repositorygen.cpp
@@ -66,90 +66,6 @@ static bool operator==(const PackageInfo &lhs, const PackageInfo &rhs)
}
QT_END_NAMESPACE
-static PackageInfoVector collectAvailablePackages(const QString &packagesDirectory,
- const QStringList &filteredPackages, FilterType ftype)
-{
- qDebug() << "Collecting 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);
- for (QFileInfoList::const_iterator it = entries.begin(); it != entries.end(); ++it) {
- if (ftype == Exclude) {
- if (filteredPackages.contains(it->fileName()))
- continue;
- } else {
- if (!filteredPackages.contains(it->fileName()))
- continue;
- }
- qDebug() << QString::fromLatin1("\tfound 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(QObject::tr("Component %1 can't contain '-'. This is not allowed, because "
- "it is 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()));
- if (!file.exists()) {
- if (ignoreInvalidPackages)
- continue;
- throw QInstaller::Error(QObject::tr("Component %1 does not contain a package "
- "description(meta/package.xml is missing).").arg(it->fileName()));
- }
-
- file.open(QIODevice::ReadOnly);
-
- QDomDocument doc;
- QString error;
- int errorLine = 0;
- int errorColumn = 0;
- if (!doc.setContent(&file, &error, &errorLine, &errorColumn)) {
- if (ignoreInvalidPackages)
- continue;
- throw QInstaller::Error(QObject::tr("Component package description for %1 is invalid. "
- "Error at line: %2, column: %3 -> %4").arg(it->fileName(), QString::number(errorLine),
- QString::number(errorColumn), error));
- }
-
- const QString name = doc.firstChildElement(QLatin1String("Package"))
- .firstChildElement(QLatin1String("Name")).text();
- if (name != it->fileName()) {
- if (ignoreInvalidPackages)
- continue;
- throw QInstaller::Error(QObject::tr("Component folder name must match component name: "
- "%1 in %2/").arg(name, it->fileName()));
- }
-
- PackageInfo info;
- info.name = name;
- info.version = doc.firstChildElement(QLatin1String("Package")).
- firstChildElement(QLatin1String("Version")).text();
- if (!QRegExp(QLatin1String("[0-9]+((\\.|-)[0-9]+)*")).exactMatch(info.version)) {
- if (ignoreInvalidPackages)
- continue;
- throw QInstaller::Error(QObject::tr("Component version for %1 is invalid! <Version>%2</version>")
- .arg(it->fileName(), info.version));
- }
- info.dependencies = doc.firstChildElement(QLatin1String("Package")).
- firstChildElement(QLatin1String("Dependencies")).text().split(QRegExp(QLatin1String("\\b(,|, )\\b")),
- QString::SkipEmptyParts);
- info.directory = it->filePath();
- dict.push_back(info);
-
- qDebug() << QString::fromLatin1("\t- it provides the package %1 - %2").arg(name, info.version);
- }
-
- if (dict.isEmpty())
- qDebug() << "No available packages found at the specified location.";
-
- return dict;
-}
-
/*!
Returns PackageInfo of package with right name and version
*/
@@ -622,64 +538,88 @@ void QInstaller::generateMetaDataDirectory(const QString &outDir, const QString
blockingWrite(&updatesXml, doc.toByteArray());
}
-PackageInfoVector QInstaller::createListOfPackages(const QStringList &components,
- const QString &packagesDirectory, const QStringList &filteredPackages, FilterType ftype, bool addDependencies)
+PackageInfoVector QInstaller::createListOfPackages(const QString &packagesDirectory,
+ const QStringList &filteredPackages, FilterType filterType)
{
- const PackageInfoVector availablePackageInfos = collectAvailablePackages(packagesDirectory,
- filteredPackages, ftype);
- if (!addDependencies) {
- PackageInfoVector packageInfos;
- foreach (const PackageInfo &info, availablePackageInfos) {
- if (components.contains(info.name))
- packageInfos.append(info);
+ qDebug() << "Collecting 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);
+ for (QFileInfoList::const_iterator it = entries.begin(); it != entries.end(); ++it) {
+ if (filterType == Exclude) {
+ if (filteredPackages.contains(it->fileName()))
+ continue;
+ } else {
+ if (!filteredPackages.contains(it->fileName()))
+ continue;
+ }
+ qDebug() << QString::fromLatin1("\tfound 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(QObject::tr("Component %1 can't contain '-'. This is not allowed, because "
+ "it is used as the separator between the component name and the version number internally.").arg(
+ it->fileName()));
}
- return packageInfos;
- }
- return availablePackageInfos;
- // we don't want to have two different dependency checking codes (installer itself and repogen here)
- // so because they have two different behaviours we deactivate it here for now
+ QFile file(QString::fromLatin1("%1/meta/package.xml").arg(it->filePath()));
+ if (!file.exists()) {
+ if (ignoreInvalidPackages)
+ continue;
+ throw QInstaller::Error(QObject::tr("Component %1 does not contain a package "
+ "description(meta/package.xml is missing).").arg(it->fileName()));
+ }
- qDebug() << "Calculating dependencies for selected packages...";
- PackageInfoVector needed = calculateNeededPackages(components, availablePackageInfos, addDependencies);
+ file.open(QIODevice::ReadOnly);
- qDebug() << "The following packages will be placed in the installer:";
- {
- QDebug mergedDebugOutput = qDebug().nospace();
- foreach (const PackageInfo &i, needed) {
- mergedDebugOutput << " " << i.name;
- if (!i.version.isEmpty())
- mergedDebugOutput << "-" << i.version;
+ QDomDocument doc;
+ QString error;
+ int errorLine = 0;
+ int errorColumn = 0;
+ if (!doc.setContent(&file, &error, &errorLine, &errorColumn)) {
+ if (ignoreInvalidPackages)
+ continue;
+ throw QInstaller::Error(QObject::tr("Component package description for %1 is invalid. "
+ "Error at line: %2, column: %3 -> %4").arg(it->fileName(), QString::number(errorLine),
+ QString::number(errorColumn), error));
}
- } // to write mergedDebugOutput
-
- // now just append the virtual parents (not including all their descendants!)
- // like... if com.nokia.sdk.qt.qtcore was passed, even com.nokia.sdk.qt will show up in the tree
- if (addDependencies) {
- for (int i = 0; i < needed.count(); ++i) {
- const PackageInfo& package = needed.at(i);
- const QString name = package.name;
- const QString version = package.version;
- QString id = name.section(QChar::fromLatin1('.'), 0, -2);
- while (!id.isEmpty()) {
- PackageInfo info;
- if (!version.isEmpty()) {
- info = findMatchingPackage(QString::fromLatin1("%1-%2").arg(id, version),
- availablePackageInfos);
- }
- if (info.name.isEmpty())
- info = findMatchingPackage(id, availablePackageInfos);
- if (!info.name.isEmpty() && !allPackagesHavePrefix(needed, id) && !needed.contains(info)) {
- qDebug() << QString::fromLatin1("Adding %1 as it is the virtual parent item of %2")
- .arg(info.name, name);
- needed.push_back(info);
- }
- id = id.section(QChar::fromLatin1('.'), 0, -2);
- }
+
+ const QString name = doc.firstChildElement(QLatin1String("Package"))
+ .firstChildElement(QLatin1String("Name")).text();
+ if (name != it->fileName()) {
+ if (ignoreInvalidPackages)
+ continue;
+ throw QInstaller::Error(QObject::tr("Component folder name must match component name: "
+ "%1 in %2/").arg(name, it->fileName()));
+ }
+
+ PackageInfo info;
+ info.name = name;
+ info.version = doc.firstChildElement(QLatin1String("Package")).
+ firstChildElement(QLatin1String("Version")).text();
+ if (!QRegExp(QLatin1String("[0-9]+((\\.|-)[0-9]+)*")).exactMatch(info.version)) {
+ if (ignoreInvalidPackages)
+ continue;
+ throw QInstaller::Error(QObject::tr("Component version for %1 is invalid! <Version>%2</version>")
+ .arg(it->fileName(), info.version));
}
+ info.dependencies = doc.firstChildElement(QLatin1String("Package")).
+ firstChildElement(QLatin1String("Dependencies")).text().split(QRegExp(QLatin1String("\\b(,|, )\\b")),
+ QString::SkipEmptyParts);
+ info.directory = it->filePath();
+ dict.push_back(info);
+
+ qDebug() << QString::fromLatin1("\t- it provides the package %1 - %2").arg(name, info.version);
}
- return needed;
+ if (dict.isEmpty())
+ qDebug() << "No available packages found at the specified location.";
+
+ return dict;
}
QMap<QString, QString> QInstaller::buildPathToVersionMap(const PackageInfoVector &info)
diff --git a/installerbuilder/common/repositorygen.h b/installerbuilder/common/repositorygen.h
index 64290856b..1fa28df95 100644
--- a/installerbuilder/common/repositorygen.h
+++ b/installerbuilder/common/repositorygen.h
@@ -69,8 +69,8 @@ void generateMetaDataDirectory(const QString &outDir, const QString &dataDir,
const PackageInfoVector &packages, const QString &appName,
const QString& appVersion, const QString &redirectUpdateUrl = QString());
-PackageInfoVector createListOfPackages(const QStringList &components, const QString &packagesDirectory,
- const QStringList &filteredPackages, FilterType ftype, bool addDependencies = true);
+PackageInfoVector createListOfPackages(const QString &packagesDirectory, const QStringList &filteredPackages,
+ FilterType ftype);
} // namespace QInstaller
diff --git a/installerbuilder/repogen/repogen.cpp b/installerbuilder/repogen/repogen.cpp
index 4275f7359..46ab03c0c 100644
--- a/installerbuilder/repogen/repogen.cpp
+++ b/installerbuilder/repogen/repogen.cpp
@@ -48,7 +48,7 @@ using namespace QInstaller;
static void printUsage()
{
const QString appName = QFileInfo(QCoreApplication::applicationFilePath()).fileName();
- std::cout << "Usage: " << appName << " [options] repository-dir package1 [package2 ...]" << std::endl;
+ std::cout << "Usage: " << appName << " [options] repository-dir" << std::endl;
std::cout << std::endl;
std::cout << "Options:" << std::endl;
@@ -57,8 +57,8 @@ static void printUsage()
std::cout << " -u|--updateurl url instructs clients to receive updates from a " << std::endl;
std::cout << " different location" << std::endl;
- std::cout << " --single Put only the given components (not their dependencies) " << std::endl;
- std::cout << " into the (already existing) repository" << std::endl;
+ std::cout << " --update Update a set of existing components (defined by --include " << std::endl;
+ std::cout << " or --exclude) in the repository" << std::endl;
std::cout << " -v|--verbose Verbose output" << std::endl;
@@ -93,11 +93,11 @@ int main(int argc, char** argv)
QStringList args = app.arguments().mid(1);
QStringList filteredPackages;
- bool replaceSingleComponent = false;
+ bool updateExistingRepository = false;
QString packagesDir;
QString configDir;
QString redirectUpdateUrl;
- FilterType ftype = Exclude;
+ FilterType filterType = Exclude;
//TODO: use a for loop without removing values from args like it is in binarycreator.cpp
//for (QStringList::const_iterator it = args.begin(); it != args.end(); ++it) {
@@ -123,10 +123,10 @@ int main(int argc, char** argv)
return printErrorAndUsageAndExit(QObject::tr("Error: Package to include missing"));
filteredPackages = args.first().split(QLatin1Char(','));
args.removeFirst();
- ftype = Include;
- } else if (args.first() == QLatin1String("--single")) {
+ filterType = Include;
+ } else if (args.first() == QLatin1String("--single") || args.first() == QLatin1String("--update")) {
args.removeFirst();
- replaceSingleComponent = true;
+ updateExistingRepository = true;
} else if (args.first() == QLatin1String("-p") || args.first() == QLatin1String("--packages")) {
args.removeFirst();
if (args.isEmpty()) {
@@ -203,13 +203,20 @@ int main(int argc, char** argv)
const QString repositoryDir = makeAbsolute(args[argsPosition++]);
const QStringList components = args.mid(argsPosition);
- if (!replaceSingleComponent && QFile::exists(repositoryDir)) {
+ if (!components.isEmpty()) {
+ std::cout << "Package names at the end of the command are deprecated"
+ " - please use --include or --exclude" << std::endl;
+ if (updateExistingRepository)
+ filteredPackages.append(components);
+ filterType = Include;
+ }
+
+ if (!updateExistingRepository && QFile::exists(repositoryDir)) {
throw QInstaller::Error(QObject::tr("Repository target folder %1 already exists!")
.arg(repositoryDir));
}
- PackageInfoVector packages = createListOfPackages(components, packagesDir, filteredPackages,
- ftype, !replaceSingleComponent);
+ PackageInfoVector packages = createListOfPackages(packagesDir, filteredPackages, filterType);
QMap<QString, QString> pathToVersionMapping = buildPathToVersionMap(packages);
for (PackageInfoVector::const_iterator it = packages.begin(); it != packages.end(); ++it) {