summaryrefslogtreecommitdiffstats
path: root/src/libs/installer
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-03-30 16:42:21 +0300
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-04-07 15:43:00 +0300
commit21aef7e78341b1931ca029dda5e5118172bdaafa (patch)
treeece1e5c3900cca1fa300fb9447ea0df11054b874 /src/libs/installer
parentd3021e3cc23b7df322bf9dd7f80df5bbde7cc166 (diff)
Remove existing installation from command line
Add new "purge" command to command line interface. This removes all components and all program directory contents. Add test function to unit tests. Task-number: QTIFW-1574 Change-Id: Iccd4a052c7e2fc8eec0a6ae2b5a93c0c607604cb Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs/installer')
-rw-r--r--src/libs/installer/commandlineparser.cpp6
-rw-r--r--src/libs/installer/constants.h6
-rw-r--r--src/libs/installer/packagemanagercore.cpp16
-rw-r--r--src/libs/installer/packagemanagercore.h1
4 files changed, 26 insertions, 3 deletions
diff --git a/src/libs/installer/commandlineparser.cpp b/src/libs/installer/commandlineparser.cpp
index c82dde944..8c0fb1ee7 100644
--- a/src/libs/installer/commandlineparser.cpp
+++ b/src/libs/installer/commandlineparser.cpp
@@ -53,8 +53,10 @@ CommandLineParser::CommandLineParser()
.arg(CommandLineOptions::scRemoveShort, CommandLineOptions::scRemoveLong)
+ QString::fromLatin1("\t%1, %2 - list currently installed packages\n")
.arg(CommandLineOptions::scListShort, CommandLineOptions::scListLong)
- + QString::fromLatin1("\t%1, %2 - search available packages - <regexp>")
- .arg(CommandLineOptions::scSearchShort, CommandLineOptions::scSearchLong);
+ + QString::fromLatin1("\t%1, %2 - search available packages - <regexp>\n")
+ .arg(CommandLineOptions::scSearchShort, CommandLineOptions::scSearchLong)
+ + QString::fromLatin1("\t%1, %2 - uninstall all packages and remove entire program directory")
+ .arg(CommandLineOptions::scPurgeShort, CommandLineOptions::scPurgeLong);
m_parser.setApplicationDescription(preformatted);
diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h
index 37eb9600a..8f3291b04 100644
--- a/src/libs/installer/constants.h
+++ b/src/libs/installer/constants.h
@@ -124,6 +124,8 @@ static const QLatin1String scListShort("li");
static const QLatin1String scListLong("list");
static const QLatin1String scSearchShort("se");
static const QLatin1String scSearchLong("search");
+static const QLatin1String scPurgeShort("pr");
+static const QLatin1String scPurgeLong("purge");
// Repository management options
static const QLatin1String scAddRepositoryShort("ar");
@@ -186,7 +188,9 @@ static const QStringList scCommandLineInterfaceOptions = {
scListShort,
scListLong,
scSearchShort,
- scSearchLong
+ scSearchLong,
+ scPurgeShort,
+ scPurgeLong
};
} // namespace CommandLineOptions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 55a143ceb..0a5eec513 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -2219,6 +2219,22 @@ bool PackageManagerCore::uninstallComponentsSilently(const QStringList& componen
}
/*!
+ Uninstalls all installed components without GUI and removes
+ the program directory. Returns \c true if components are
+ uninstalled successfully, otherwise returns \c false.
+*/
+bool PackageManagerCore::removeInstallationSilently()
+{
+ if (d->runningProcessesFound())
+ throw Error(tr("Running processes found."));
+
+ autoRejectMessageBoxes();
+
+ setCompleteUninstallation(true);
+ return run();
+}
+
+/*!
Installs the selected components \a components without displaying a user
interface. Virtual components cannot be installed unless made visible with
--show-virtual-components. AutoDependOn nor non-checkable components cannot
diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h
index 82ab779c3..979ff50e6 100644
--- a/src/libs/installer/packagemanagercore.h
+++ b/src/libs/installer/packagemanagercore.h
@@ -221,6 +221,7 @@ public:
bool installSelectedComponentsSilently(const QStringList& components);
bool installDefaultComponentsSilently();
bool uninstallComponentsSilently(const QStringList& components);
+ bool removeInstallationSilently();
// convenience
Q_INVOKABLE void setInstaller();