summaryrefslogtreecommitdiffstats
path: root/src/sdk/installerbase.cpp
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-02-03 16:50:31 +0200
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-02-17 14:01:25 +0000
commit814a46420b372a81d8deb176807fac6654aa4980 (patch)
treeb083338c80cdfb25060855a0b129f0af41aa667d /src/sdk/installerbase.cpp
parentac38ce9ee96bc2b827d89b089a9d2e2ca37608d7 (diff)
Enable optional targetDir argument on command line installation
Try to use default target directory value from internal configuration when --targetDir option is not set. This affects usage of options --installDefault and --installPackages (when running as installer). Task-number: QTIFW-1608 Change-Id: Ieac709f6e3d7c539a3a1cb66dce8eb448b20dcfe Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/sdk/installerbase.cpp')
-rw-r--r--src/sdk/installerbase.cpp44
1 files changed, 16 insertions, 28 deletions
diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp
index a14999b45..0f7994666 100644
--- a/src/sdk/installerbase.cpp
+++ b/src/sdk/installerbase.cpp
@@ -346,22 +346,8 @@ int InstallerBase::run()
checkLicense();
m_core->autoRejectMessageBoxes();
if (m_core->isInstaller()) {
- if (!setTargetDirFromCommandLine(parser)) {
- const QString &value = parser.value(QLatin1String(CommandLineOptions::TargetDir));
- if (m_core->checkTargetDir(value)) {
- QString targetDirWarning = m_core->targetDirWarning(value);
- if (!targetDirWarning.isEmpty()) {
- qCWarning(QInstaller::lcGeneral) << m_core->targetDirWarning(value);
- return EXIT_FAILURE;
- }
- m_core->setValue(QLatin1String("TargetDir"), value);
- } else {
- return EXIT_FAILURE;
- }
- } else {
- qCWarning(QInstaller::lcGeneral) << "Please specify target directory.";
+ if (!setTargetDirForCommandLineInterface(parser))
return EXIT_FAILURE;
- }
}
QStringList packages;
@@ -374,7 +360,7 @@ int InstallerBase::run()
throw QInstaller::Error(QLatin1String("Cannot start installer binary as installer."));
checkLicense();
m_core->autoRejectMessageBoxes();
- if (!setTargetDirFromCommandLine(parser))
+ if (!setTargetDirForCommandLineInterface(parser))
return EXIT_FAILURE;
m_core->installDefaultComponentsSilently();
} else if (parser.isSet(QLatin1String(CommandLineOptions::UninstallSelectedPackages))) {
@@ -471,21 +457,23 @@ void InstallerBase::checkLicense()
}
}
-bool InstallerBase::setTargetDirFromCommandLine(CommandLineParser &parser)
+bool InstallerBase::setTargetDirForCommandLineInterface(CommandLineParser &parser)
{
+ QString targetDir;
if (parser.isSet(QLatin1String(CommandLineOptions::TargetDir))) {
- const QString &value = parser.value(QLatin1String(CommandLineOptions::TargetDir));
- if (m_core->checkTargetDir(value)) {
- QString targetDirWarning = m_core->targetDirWarning(value);
- if (!targetDirWarning.isEmpty()) {
- qDebug() << m_core->targetDirWarning(value);
- } else {
- m_core->setValue(QLatin1String("TargetDir"), value);
- return true;
- }
- }
+ targetDir = parser.value(QLatin1String(CommandLineOptions::TargetDir));
} else {
- qWarning() << "Please specify target directory.";
+ targetDir = m_core->value(QLatin1String("TargetDir"));
+ qCDebug(QInstaller::lcGeneral) << "No target directory specified, using default value:" << targetDir;
+ }
+ if (m_core->checkTargetDir(targetDir)) {
+ QString targetDirWarning = m_core->targetDirWarning(targetDir);
+ if (!targetDirWarning.isEmpty()) {
+ qCWarning(QInstaller::lcGeneral) << m_core->targetDirWarning(targetDir);
+ } else {
+ m_core->setValue(QLatin1String("TargetDir"), targetDir);
+ return true;
+ }
}
return false;
}