summaryrefslogtreecommitdiffstats
path: root/tools/repogen/repogen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/repogen/repogen.cpp')
-rw-r--r--tools/repogen/repogen.cpp59
1 files changed, 23 insertions, 36 deletions
diff --git a/tools/repogen/repogen.cpp b/tools/repogen/repogen.cpp
index 1380e4ebf..4113826b8 100644
--- a/tools/repogen/repogen.cpp
+++ b/tools/repogen/repogen.cpp
@@ -69,8 +69,6 @@ static void printUsage()
QInstallerTools::printRepositoryGenOptions();
std::cout << " -r|--remove Force removing target directory if existent." << std::endl;
- std::cout << " -u|--updateurl URL instructs clients to receive updates from a " << std::endl;
- std::cout << " different location" << std::endl;
std::cout << " --update Update a set of existing components (defined by " << std::endl;
std::cout << " --include or --exclude) in the repository" << std::endl;
@@ -80,7 +78,7 @@ static void printUsage()
std::cout << std::endl;
std::cout << "Example:" << std::endl;
std::cout << " " << appName << " -p ../examples/packages -u "
- "http://www.some-server.com:8080 repository/" << std::endl;
+ "http://www.example.com:8080 repository/" << std::endl;
}
static int printErrorAndUsageAndExit(const QString &err)
@@ -90,16 +88,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);
@@ -110,7 +102,6 @@ int main(int argc, char** argv)
QStringList filteredPackages;
bool updateExistingRepository = false;
QString packagesDir;
- QString redirectUpdateUrl;
QInstallerTools::FilterType filterType = QInstallerTools::Exclude;
bool remove = false;
@@ -160,12 +151,6 @@ int main(int argc, char** argv)
return printErrorAndUsageAndExit(QObject::tr("Error: Config parameter missing argument"));
args.removeFirst();
std::cout << "Config file parameter is deprecated and ignored." << std::endl;
- } else if (args.first() == QLatin1String("-u") || args.first() == QLatin1String("--updateurl")) {
- args.removeFirst();
- if (args.isEmpty())
- return printErrorAndUsageAndExit(QObject::tr("Error: Config parameter missing argument"));
- redirectUpdateUrl = args.first();
- args.removeFirst();
} else if (args.first() == QLatin1String("--ignore-translations")
|| args.first() == QLatin1String("--ignore-invalid-packages")) {
args.removeFirst();
@@ -188,18 +173,20 @@ 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);
- if (!updateExistingRepository && QFile::exists(repositoryDir)) {
+ if (!updateExistingRepository && QFile::exists(repositoryDir) && !QDir(repositoryDir).entryList(
+ QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty()) {
+
throw QInstaller::Error(QObject::tr("Repository target folder %1 already exists!")
.arg(repositoryDir));
}
QInstallerTools::PackageInfoVector packages = QInstallerTools::createListOfPackages(packagesDir,
- filteredPackages, filterType);
- QHash<QString, QString> pathToVersionMapping = buildPathToVersionMapping(packages);
+ &filteredPackages, filterType);
+ QHash<QString, QString> pathToVersionMapping = QInstallerTools::buildPathToVersionMapping(packages);
foreach (const QInstallerTools::PackageInfo &package, packages) {
const QFileInfo fi(repositoryDir, package.name);
@@ -207,27 +194,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}"),
- QLatin1String(QUOTE(IFW_REPOSITORY_FORMAT_VERSION)), redirectUpdateUrl);
- QInstallerTools::compressMetaDirectories(metaTmp, metaTmp, pathToVersionMapping);
+ tmpMetaDir = QInstaller::createTemporaryDirectory();
+ QInstallerTools::copyComponentData(packagesDir, repositoryDir, &packages);
+ QInstallerTools::copyMetaData(tmpMetaDir, repositoryDir, packages, QLatin1String("{AnyApplication}"),
+ QLatin1String(QUOTE(IFW_REPOSITORY_FORMAT_VERSION)));
+ 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;
}