summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2019-05-27 14:02:36 +0300
committerKatja Marttila <katja.marttila@qt.io>2019-11-22 12:55:39 +0000
commitf8ade64515482e2079fde805b93ee11e3dae44f5 (patch)
treeeb487a2c41b341777c8a92b828ef5d212fad0a5b
parente238e764331197ec48e9b8b6c29368ee40efe82c (diff)
Update selected components from command line
Selected components can be updated with --updatePackages <package_id>. If essential components are found, only the essential components are updated. Change-Id: I0eb8a8f5ca855af16eabd5f888cd9a0d5e933d84 Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
-rw-r--r--src/libs/installer/packagemanagercore.cpp48
-rw-r--r--src/libs/installer/packagemanagercore.h3
-rw-r--r--src/sdk/commandlineparser.cpp2
-rw-r--r--src/sdk/constants.h1
-rw-r--r--src/sdk/installerbase.cpp12
5 files changed, 36 insertions, 30 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 8d4e3ddc4..ec1fff29d 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -1879,20 +1879,15 @@ void PackageManagerCore::listInstalledPackages()
}
}
-void PackageManagerCore::updateComponentsSilently()
+void PackageManagerCore::updateComponentsSilently(const QStringList &componentsToUpdate)
{
if (d->runningProcessesFound())
return;
+ setUpdater();
+ autoRejectMessageBoxes();
- autoAcceptMessageBoxes();
-
- //Prevent infinite loop if installation for some reason fails.
- setMessageBoxAutomaticAnswer(QLatin1String("installationErrorWithRetry"), QMessageBox::Cancel);
-
- fetchRemotePackagesTree();
-
- const QList<QInstaller::Component*> componentList = components(
- ComponentType::Root | ComponentType::Descendants);
+ // List contains components containing update, if essential found contains only essential component
+ const QList<QInstaller::Component*> componentList = componentsMarkedForInstallation();
if (componentList.count() == 0) {
qDebug() << "No updates available.";
@@ -1906,26 +1901,27 @@ void PackageManagerCore::updateComponentsSilently()
essentialUpdatesFound = true;
}
if (!essentialUpdatesFound) {
- //Mark all components to be updated
+ int componentToUpdateCount = componentsToUpdate.count();
+ //Mark components to be updated
foreach (Component *comp, componentList) {
- comp->setCheckState(Qt::Checked);
- }
- }
- QString htmlOutput;
- bool componentsOk = calculateComponents(&htmlOutput);
- if (componentsOk) {
- if (runPackageUpdater()) {
- writeMaintenanceTool();
- if (essentialUpdatesFound) {
- qDebug() << "Essential components updated successfully.";
- }
- else {
- qDebug() << "Components updated successfully.";
+ if (componentToUpdateCount == 0) { // No components given, update all
+ comp->setCheckState(Qt::Checked);
+ } else { // Check only components we want to update
+ foreach (const QString &name, componentsToUpdate) {
+ if (comp->name() == name)
+ comp->setCheckState(Qt::Checked);
+ else
+ comp->setCheckState(Qt::Unchecked);
+ }
}
}
}
- else {
- qDebug() << htmlOutput;
+
+ if (d->calculateComponentsAndRun()) {
+ if (essentialUpdatesFound)
+ qDebug() << "Essential components updated successfully.";
+ else
+ qDebug() << "Components updated successfully.";
}
}
}
diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h
index cba1592fc..d9e953882 100644
--- a/src/libs/installer/packagemanagercore.h
+++ b/src/libs/installer/packagemanagercore.h
@@ -227,8 +227,7 @@ public:
ComponentModel *updaterComponentModel() const;
void listInstalledPackages();
void listAvailablePackages(const QString &regexp);
- void updateComponentsSilently();
-
+ void updateComponentsSilently(const QStringList &componentsToUpdate);
// convenience
Q_INVOKABLE bool isInstaller() const;
Q_INVOKABLE bool isOfflineOnly() const;
diff --git a/src/sdk/commandlineparser.cpp b/src/sdk/commandlineparser.cpp
index c931d0ff9..7f833417c 100644
--- a/src/sdk/commandlineparser.cpp
+++ b/src/sdk/commandlineparser.cpp
@@ -118,6 +118,8 @@ CommandLineParser::CommandLineParser()
QLatin1String("URI,...")));
m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::SilentUpdate),
QLatin1String("Updates all packages silently.")));
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::UpdatePackages),
+ QLatin1String("Updates selected packages."), QLatin1String("package,...")));
m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::ListInstalledPackages),
QLatin1String("Lists installed packages.")));
m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::ListPackages),
diff --git a/src/sdk/constants.h b/src/sdk/constants.h
index 0a8852f13..0c3b2edc9 100644
--- a/src/sdk/constants.h
+++ b/src/sdk/constants.h
@@ -54,6 +54,7 @@ const char StartServer[] = "startserver";
const char StartClient[] = "startclient";
const char InstallCompressedRepository[] = "installCompressedRepository";
const char SilentUpdate[] = "silentUpdate";
+const char UpdatePackages[] = "updatePackages";
const char ListInstalledPackages[] = "listInstalledPackages";
const char ListPackages[] = "listPackages";
const char Platform[] = "platform";
diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp
index 8ae6861a5..09cc547d2 100644
--- a/src/sdk/installerbase.cpp
+++ b/src/sdk/installerbase.cpp
@@ -319,8 +319,7 @@ int InstallerBase::run()
if (m_core->isInstaller())
throw QInstaller::Error(QLatin1String("Cannot start installer binary as updater."));
checkLicense();
- m_core->setUpdater();
- m_core->updateComponentsSilently();
+ m_core->updateComponentsSilently(QStringList());
} else if (parser.isSet(QLatin1String(CommandLineOptions::ListInstalledPackages))){
if (m_core->isInstaller())
throw QInstaller::Error(QLatin1String("Cannot start installer binary as package manager."));
@@ -333,6 +332,15 @@ int InstallerBase::run()
checkLicense();
QString regexp = parser.value(QLatin1String(CommandLineOptions::ListPackages));
m_core->listAvailablePackages(regexp);
+ } else if (parser.isSet(QLatin1String(CommandLineOptions::UpdatePackages))) {
+ if (m_core->isInstaller())
+ throw QInstaller::Error(QLatin1String("Cannot start installer binary as updater."));
+ checkLicense();
+ QStringList packages;
+ const QString &value = parser.value(QLatin1String(CommandLineOptions::UpdatePackages));
+ if (!value.isEmpty())
+ packages = value.split(QLatin1Char(','), QString::SkipEmptyParts);
+ m_core->updateComponentsSilently(packages);
} else {
//create the wizard GUI
TabController controller(nullptr);