feat(cleanup): add a maintenance page for unused and legacy packages
Leftovers pile up on a machine: dependencies that no installed package requires any more, and installs coming from the AUR or manual builds that the sync databases know nothing about. The new Nettoyage page lists both (orphans first, since they are the ones that can be removed in bulk), shows which provider reported each row, and frees the space held by the caches: paccache (or pacman -Sc) and flatpak's unused runtimes. Cleanup is an optional capability of IPackageManager, so providers that only install packages keep working unchanged. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
1 parent
b8f8dc569f
commit
632cdf1dea
10 files changed
+750
-6
No files matched your search
@@ -43,6 +43,24 @@ public:
|
||||
// Exposed as static so the parsing can be unit-tested without invoking pacman.
|
||||
static std::map<std::string, std::string> parseSyncRepos(const std::string& output);
|
||||
|
||||
// Merge `pacman -Qdt` (orphans) and `pacman -Qm` (foreign) output into
|
||||
// cleanup candidates tagged with their reason: orphans are safe to
|
||||
// bulk-remove, foreign packages are listed for review only since nothing
|
||||
// proves they are unused. Exposed as static so it can be unit-tested
|
||||
// without invoking pacman.
|
||||
static std::vector<PackageInfo> parseCleanupOutput(const std::string& orphans,
|
||||
const std::string& foreign);
|
||||
|
||||
// `pacman -Rns` command removing every given package together with the
|
||||
// dependencies it dragged in, or empty when the list is empty. Exposed as
|
||||
// static so the command can be unit-tested without invoking pacman.
|
||||
static std::string removePackagesCommand(const std::vector<std::string>& packages);
|
||||
|
||||
// Command that trims the package cache, given whether paccache
|
||||
// (pacman-contrib) is installed on this system. Exposed as static so both
|
||||
// branches can be unit-tested without invoking pacman.
|
||||
static std::string cleanCacheCommand(bool paccacheAvailable);
|
||||
|
||||
// Detect a sudo authentication failure (wrong or missing password) in the
|
||||
// output of a privileged command. Exposed as static so it can be
|
||||
// unit-tested without invoking sudo.
|
||||
@@ -79,6 +97,16 @@ public:
|
||||
std::vector<PackageInfo> listUpdates() override;
|
||||
bool refresh(ProgressCallback progressCallback = nullptr) override;
|
||||
|
||||
// Cleanup: pacman is the one provider that knows about packages no longer
|
||||
// required by anything (-Qdt) and about legacy installs coming from
|
||||
// outside the sync databases (-Qm).
|
||||
bool canListCleanup() const override { return true; }
|
||||
bool canCleanCache() const override { return true; }
|
||||
std::vector<PackageInfo> listCleanupCandidates() override;
|
||||
bool removePackages(const std::vector<std::string>& packages,
|
||||
ProgressCallback progressCallback = nullptr) override;
|
||||
bool cleanCache(ProgressCallback progressCallback = nullptr) override;
|
||||
|
||||
private:
|
||||
bool isPackageInstalled(const std::string& name);
|
||||
|
||||
|
||||
Reference in new issue
Block a user