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>
74 lines
3.4 KiB
C++
74 lines
3.4 KiB
C++
#pragma once
|
|
|
|
#include "package-manager.h"
|
|
|
|
// Flatpak provider: manages flatpak applications through the `flatpak` CLI.
|
|
// Unlike pacman it runs per-user (no sudo), so requiresPassword() is false.
|
|
class FlatpakManager : public IPackageManager {
|
|
public:
|
|
std::string getName() const override { return "flatpak"; }
|
|
std::string getVersion() const override { return "1.0.0"; }
|
|
std::string getDescription() const override {
|
|
return "Gestionnaire d'applications Flatpak";
|
|
}
|
|
|
|
bool canSearch() const override { return true; }
|
|
bool canInstall() const override { return true; }
|
|
bool canRemove() const override { return true; }
|
|
bool canUpdate() const override { return true; }
|
|
bool canListInstalled() const override { return true; }
|
|
|
|
bool isAvailable() const override {
|
|
return system("which flatpak > /dev/null 2>&1") == 0;
|
|
}
|
|
|
|
// Last lines of the failed command output, shown to the user on failure.
|
|
std::string lastError() const override { return m_lastError; }
|
|
|
|
// Parse `flatpak search` output (one whitespace-aligned row per app:
|
|
// "Name Description Application ID Version Branch Remotes").
|
|
// Exposed as static so the parsing can be unit-tested without flatpak.
|
|
static std::vector<PackageInfo> parseSearchOutput(const std::string& output);
|
|
|
|
// Parse `flatpak list --columns=application,version,origin` output
|
|
// (tab-separated fields per installed application).
|
|
static std::vector<PackageInfo> parseInstalledOutput(const std::string& output);
|
|
|
|
// Parse `flatpak remote-ls --updates --columns=application,version` output
|
|
// (tab-separated fields per application with a pending update).
|
|
static std::vector<PackageInfo> parseUpdatesOutput(const std::string& output);
|
|
|
|
std::vector<PackageInfo> search(const std::string& query) override;
|
|
bool install(const std::string& packageName,
|
|
ProgressCallback progressCallback) override;
|
|
bool remove(const std::string& packageName,
|
|
ProgressCallback progressCallback) override;
|
|
bool update(const std::string& packageName = "",
|
|
ProgressCallback progressCallback = nullptr) override;
|
|
std::vector<PackageInfo> listInstalled() override;
|
|
std::vector<PackageInfo> listUpdates() override;
|
|
bool refresh(ProgressCallback progressCallback = nullptr) override;
|
|
|
|
// Cleanup: flatpak knows which runtimes no installed application uses any
|
|
// more, so it can reclaim them from the maintenance page.
|
|
bool canCleanCache() const override { return true; }
|
|
bool cleanCache(ProgressCallback progressCallback = nullptr) override;
|
|
|
|
// Make an app appear in the desktop's application launcher (wofi, GNOME,
|
|
// KDE, ...) regardless of XDG_DATA_DIRS, like a pacman install would: link
|
|
// its .desktop entries and icons from flatpak's exports into the user's
|
|
// standard XDG directories (~/.local/share/{applications,icons}). Exposed
|
|
// as static so the linking can be unit/integration tested without flatpak.
|
|
static void integrateDesktopEntries(const std::string& appId);
|
|
static void uninstallDesktopEntries(const std::string& appId);
|
|
|
|
// Re-link every installed app so launchers pick up apps whose integration
|
|
// is missing (e.g. installed before this feature existed).
|
|
void integrateAllInstalled();
|
|
|
|
private:
|
|
bool isInstalled(const std::string& appId);
|
|
|
|
std::string m_lastError;
|
|
};
|