diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 8d4e3ddc..ec1fff29 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 componentList = components( - ComponentType::Root | ComponentType::Descendants); + // List contains components containing update, if essential found contains only essential component + const QList 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 cba1592f..d9e95388 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 ®exp); - 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 c931d0ff..7f833417 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 0a8852f1..0c3b2edc 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 8ae6861a..09cc547d 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);