summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2012-11-13 12:24:49 +0100
committerKarsten Heimrich <karsten.heimrich@digia.com>2012-11-14 12:06:25 +0100
commit207cfebb778b77bc5308189d8e3a8d34019f1c72 (patch)
tree37bc8464aef62ed6b0499f90242510f5313f26b9 /src
parent0507fa96513a0542936644415efe4e14010b81c8 (diff)
Implement cmd option to dump binary content into given dir.
Reuse already existing functionality, just fix the hard coded "repository" path name. Also check if we are running offline only, as otherwise there will be no data section. Change-Id: Iac45d89822fceee9e527afe0dc9eb589e39e16e7 Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/createlocalrepositoryoperation.cpp15
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp3
-rw-r--r--src/sdk/installerbase.cpp30
-rw-r--r--src/sdk/installerbase_p.cpp6
4 files changed, 48 insertions, 6 deletions
diff --git a/src/libs/installer/createlocalrepositoryoperation.cpp b/src/libs/installer/createlocalrepositoryoperation.cpp
index 87db3a472..e74536b0c 100644
--- a/src/libs/installer/createlocalrepositoryoperation.cpp
+++ b/src/libs/installer/createlocalrepositoryoperation.cpp
@@ -153,15 +153,20 @@ bool CreateLocalRepositoryOperation::performOperation()
return false;
}
- QString repoPath;
try {
- QString binaryPath = QFileInfo(args.at(0)).absoluteFilePath();
+ const QString binaryPath = QFileInfo(args.at(0)).absoluteFilePath();
// Note the "/" at the end, important to make copy directory operation behave well
- repoPath = QFileInfo(args.at(1)).absoluteFilePath() + QLatin1String("/repository/");
+ const QString repoPath = QFileInfo(args.at(1)).absoluteFilePath() + QLatin1Char('/');
- // if we're running as installer and install into an existing target, remove possible previous repos
+ // check if this is an offline version, otherwise there will be no binary data
PackageManagerCore *core = qVariantValue<PackageManagerCore*>(value(QLatin1String("installer")));
- if (core && core->isOfflineOnly() && QFile::exists(repoPath)) {
+ if (core && !core->isOfflineOnly()) {
+ throw QInstaller::Error(tr("Installer needs to be an offline version: %1.")
+ .arg(QDir::toNativeSeparators(binaryPath)));
+ }
+
+ // if we're running as installer and install into an existing target, remove possible previous repos
+ if (QFile::exists(repoPath)) {
Static::fixPermissions(repoPath);
QInstaller::removeDirectory(repoPath);
}
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index 994c5bbeb..561553fb4 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -1420,7 +1420,8 @@ bool PackageManagerCorePrivate::runInstaller()
if (createRepo) {
createRepo->setValue(QLatin1String("uninstall-only"), true);
createRepo->setValue(QLatin1String("installer"), QVariant::fromValue(m_core));
- createRepo->setArguments(QStringList() << QCoreApplication::applicationFilePath() << target);
+ createRepo->setArguments(QStringList() << QCoreApplication::applicationFilePath()
+ << target + QLatin1String("/repository"));
connectOperationToInstaller(createRepo, progressOperationSize);
diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp
index b12d5c9a0..b5aa6f5e4 100644
--- a/src/sdk/installerbase.cpp
+++ b/src/sdk/installerbase.cpp
@@ -189,6 +189,36 @@ int main(int argc, char *argv[])
return InstallerBase().replaceMaintenanceToolBinary(args);
}
+ if (args.contains(QLatin1String("--dump-binary-data"))) {
+ bool verbose = args.contains(QLatin1String("--verbose")) || args.contains(QLatin1String("-v"));
+
+ args = args.mid(args.indexOf(QLatin1String("--dump-binary-data")) + 1, 4);
+ // we expect at least -o and the output path
+ if (args.count() < 2 || !args.contains(QLatin1String("-o"))) {
+ InstallerBase::showUsage();
+ return EXIT_FAILURE;
+ }
+
+ // output path
+ const QString output = args.value(args.indexOf(QLatin1String("-o") + 1));
+ if (output.isEmpty()) {
+ InstallerBase::showUsage();
+ return EXIT_FAILURE;
+ }
+
+ MyCoreApplication app(argc, argv);
+
+ // input, if not given use current app
+ QString input = args.value(args.indexOf(QLatin1String("-i") + 1));
+ if (input.isEmpty())
+ input = QCoreApplication::applicationFilePath();
+
+ OperationRunner o(input);
+ o.setVerbose(verbose);
+ return o.runOperation(QStringList(QLatin1String("--runoperation"))
+ << QLatin1String("CreateLocalRepository") << input << output);
+ }
+
// from here, the "normal" installer binary is running
MyApplication app(argc, argv);
args = app.arguments();
diff --git a/src/sdk/installerbase_p.cpp b/src/sdk/installerbase_p.cpp
index bf96a797a..e296c7e3b 100644
--- a/src/sdk/installerbase_p.cpp
+++ b/src/sdk/installerbase_p.cpp
@@ -333,6 +333,12 @@ void InstallerBase::showUsage()
std::cout << std::setw(55) << std::setiosflags(std::ios::left)
<< " --update-installerbase [path/to/new/installerbase]" << std::setw(40)
<< "Patch a full installer with a new installer base" << std::endl;
+ std::cout << std::setw(55) << std::setiosflags(std::ios::left) << " --dump-binary-data [OPTION...] -o "
+ "path" << std::setw(40) << "Dumps the binary content into specified path (offline installer only)"
+ << std::endl;
+ std::cout << std::setw(55) << std::setiosflags(std::ios::left) << " -i "
+ << std::setw(40) << "Path to binary data file, otherwise the current application is assumed to be "
+ "the input file." << std::endl;
}
/* static*/