summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2019-05-27 10:45:21 +0300
committerKatja Marttila <katja.marttila@qt.io>2019-10-18 12:52:39 +0000
commit9ce679325c244859c7e50ed3cca304c1e0f2b698 (patch)
treefdb47b30eaadf9d4a7fe3ed84a8f802a9020325c
parent516492370b95e9c07cad4080ef713d5b2b3f2f94 (diff)
List installed packages from command lineHEADmaster
Change-Id: Ic8efe08be347f3a208e37458936f8316d66ca916 Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
-rw-r--r--src/libs/installer/packagemanagercore.cpp11
-rw-r--r--src/libs/installer/packagemanagercore.h1
-rw-r--r--src/sdk/commandlineparser.cpp2
-rw-r--r--src/sdk/constants.h1
-rw-r--r--src/sdk/installerbase.cpp12
5 files changed, 25 insertions, 2 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index c154edf76..6c30208db 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -1824,6 +1824,17 @@ ComponentModel *PackageManagerCore::updaterComponentModel() const
return d->m_updaterModel;
}
+void PackageManagerCore::listInstalledPackages()
+{
+ LocalPackagesHash installedPackages = this->localInstalledPackages();
+
+ const QStringList &keys = installedPackages.keys();
+ foreach (const QString &key, keys) {
+ KDUpdater::LocalPackage package = installedPackages.value(key);
+ qDebug() << package.name;
+ }
+}
+
void PackageManagerCore::updateComponentsSilently()
{
//Check if there are processes running in the install
diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h
index f4240fde0..eb4a630d4 100644
--- a/src/libs/installer/packagemanagercore.h
+++ b/src/libs/installer/packagemanagercore.h
@@ -226,6 +226,7 @@ public:
ComponentModel *defaultComponentModel() const;
ComponentModel *updaterComponentModel() const;
+ void listInstalledPackages();
void updateComponentsSilently();
// convenience
diff --git a/src/sdk/commandlineparser.cpp b/src/sdk/commandlineparser.cpp
index 3d0d2412a..131f69a48 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::ListInstalledPackages),
+ QLatin1String("Lists installed packages.")));
m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::Platform),
QLatin1String("Use the specified platform plugin."), QLatin1String("plugin")));
m_parser.addPositionalArgument(QLatin1String(CommandLineOptions::KeyValue),
diff --git a/src/sdk/constants.h b/src/sdk/constants.h
index e9eca9103..ea76df620 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 ListInstalledPackages[] = "listInstalledPackages";
const char Platform[] = "platform";
const char SquishPort[] = "squish-port";
diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp
index 8ec142950..5c8478036 100644
--- a/src/sdk/installerbase.cpp
+++ b/src/sdk/installerbase.cpp
@@ -301,8 +301,16 @@ int InstallerBase::run()
throw QInstaller::Error(QLatin1String("Silent update not allowed."));
m_core->setUpdater();
m_core->updateComponentsSilently();
- }
- else {
+ } else if (parser.isSet(QLatin1String(CommandLineOptions::ListInstalledPackages))){
+ if (m_core->isInstaller())
+ throw QInstaller::Error(QLatin1String("Cannot start installer binary as package manager."));
+ m_core->setPackageManager();
+
+ const ProductKeyCheck *const productKeyCheck = ProductKeyCheck::instance();
+ if (!productKeyCheck->hasValidLicense())
+ throw QInstaller::Error(QLatin1String("No valid license found."));
+ m_core->listInstalledPackages();
+ } else {
//create the wizard GUI
TabController controller(nullptr);
controller.setManager(m_core);