docs: describe plugin types, addon template and default Flatpak build
tests / build-test (push) Has been cancelled

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
BlackAngelTVandCodebuff committed 2026-09-10 18:49:48 +02:00
1 parent 8658855cca
commit 4200f63b4f
2 files changed
+71 -28

No files matched your search

+35 -14
View File
@@ -9,7 +9,7 @@ Package manager for **Arch Linux** based on **pacman**, with a Qt6 graphical int
- 🗑️ **Package removal**
- 🔄 **Individual or global updates**
- 📋 **History of all actions**
- 🧩 **Multi-provider**: pacman and Flatpak built in, plus **plugins** to add other managers (apt, dnf, …)
- 🧩 **Plugins**: package managers (pacman built-in, **Flatpak shipped by default**) and **extensions** written in C++ (UI addons, helpers, …)
## Architecture
@@ -18,9 +18,10 @@ package-manager/
├── CMakeLists.txt # Build root
├── include/
│ ├── package-manager.h # Package manager interface (IPackageManager)
│ ├── provider-plugin.h # C ABI contract for provider plugins
│ ├── plugin.h # Generic plugin contract (PluginInfo, IPlugin)
│ ├── provider-plugin.h # C ABI contract for plugins (providers + addons)
│ ├── pacman-manager.h # pacman manager (Arch Linux, built-in)
│ ├── plugin-manager.h # Provider registry + plugin loading
│ ├── plugin-manager.h # Plugin registry + shared-library loading
│ ├── main-window.h # Main GUI
│ ├── history-manager.h # Action history
│ └── package-model.h # Qt model for the list
@@ -33,8 +34,9 @@ package-manager/
│ ├── history-manager.cpp
│ └── package-model.cpp
├── plugins/
│ ├── example-provider/ # Example external plugin (template)
│ └── flatpak-provider/ # Flatpak plugin (loaded at runtime)
│ ├── example-provider/ # Example external provider plugin (template)
│ ├── example-addon/ # Example external addon plugin (extension, template)
│ └── flatpak-provider/ # Flatpak plugin (loaded at runtime, built by default)
├── tests/ # Unit tests (assert, no Qt)
└── resources/
```
@@ -57,6 +59,11 @@ cmake -B build -DFWS_BUILD_EXAMPLE_PLUGIN=ON
cmake --build build -j$(nproc)
```
The **Flatpak plugin is built by default** (`FWS_BUILD_FLATPAK_PLUGIN=ON`): a plain `cmake -B build` is enough to get a Flatpak-enabled app. Useful options:
- `-DFWS_BUILD_FLATPAK_PLUGIN=OFF`: skip the Flatpak plugin;
- `-DFWS_BUILD_EXAMPLE_ADDON=ON`: also build the example addon plugin (`build/plugins/libsample-addon.so`).
### Install
**User install** (recommended, no sudo — the binary goes to `~/.local/bin`):
@@ -118,7 +125,7 @@ The interface uses **Qt6** with a dark theme, a **navigation sidebar** and stack
- ⬆️ **Updates**: outdated packages detected by `pacman -Qu`, "Update all" button
- 📋 **History**: filterable table (installs / removals / updates)
- 📜 **Logs**: built-in `/var/log/pacman.log` viewer
- 🧩 **Providers**: lists all managers (built-in and plugins), enable / disable and plugin rescan
- 🧩 **Plugins**: lists every plugin (package providers and extensions), enable / disable and plugin rescan
### Interface overview
```text
@@ -142,7 +149,12 @@ The interface uses **Qt6** with a dark theme, a **navigation sidebar** and stack
└──────────────────────────────────────────────────────────────────────────────────────┘
```
## Package managers (providers)
## Plugins & extensions
Two kinds of plugins coexist, both written in **C++**:
- **Providers** (`IPackageManager`): add a package manager (pacman built-in, Flatpak external, apt, dnf, …);
- **Extensions / addons** (`IPlugin`): anything else — a UI addon, a helper, a better loading experience… — with no relation to package management.
The `IPackageManager` interface (implemented by the built-in `PacmanManager` and the Flatpak plugin) defines:
@@ -166,22 +178,31 @@ The `IPackageManager` interface (implemented by the built-in `PacmanManager` and
| `listUpdates()` | List outdated packages |
| `refresh(callback)` | Refresh the sources |
Search queries **all active providers at once**: every result shows its origin in the **Provider** column (Pacman, Flatpak, …), and the Installed / Updates pages are aggregated. Install, remove and update are routed automatically to the right manager. The sidebar **Providers** page lets you enable / disable each provider, rescan plugins and **install a missing tool** (e.g. "Install tool" for Flatpak runs `sudo pacman -S flatpak`, then the provider becomes available).
Search queries **all active providers at once**: every result shows its origin in the **Provider** column (Pacman, Flatpak, …), and the Installed / Updates pages are aggregated. Install, remove and update are routed automatically to the right manager. The sidebar **Plugins** page lists everything (providers **and** addons), lets you enable / disable each plugin, rescan plugins and **install a missing tool** (e.g. "Install tool" for Flatpak runs `sudo pacman -S flatpak`, then the provider becomes available).
### Adding a provider (plugins)
### Adding a plugin
**Pacman** is **built-in** (compiled into the application); **Flatpak** is an **external plugin** loaded at runtime from `plugins/` (`plugins/flatpak-provider`), next to the executable or in `~/.local/share/PacManager/plugins/`. Flatpak installs auto-add the flathub remote when missing and fall back to a **per-user** install (no password) when the system-wide install fails (polkit, homonymous remotes) — the real error is shown on failure. An app installed via Flatpak appears immediately in the desktop launcher: its `.desktop` entries and icons are linked into `~/.local/share/applications` and `~/.local/share/icons` (the XDG dirs scanned by **every** environment: wofi, GNOME, KDE…), exactly like a pacman install, and are removed again on uninstall. Search shows the real status of each app (Installed / Update available). This is covered by an **integration test** that drives the real flatpak CLI (install, list, update, search, uninstall). To add another manager (apt, dnf, zypper, or another distro's repos) without touching the application:
**Pacman** is **built-in** (compiled into the application); **Flatpak** is an **external plugin** loaded at runtime from `plugins/` (`plugins/flatpak-provider`), next to the executable or in `~/.local/share/PacManager/plugins/`, and **built by default** (`FWS_BUILD_FLATPAK_PLUGIN=ON`). Flatpak installs auto-add the flathub remote when missing and fall back to a **per-user** install (no password) when the system-wide install fails (polkit, homonymous remotes) — the real error is shown on failure. An app installed via Flatpak appears immediately in the desktop launcher: its `.desktop` entries and icons are linked into `~/.local/share/applications` and `~/.local/share/icons` (the XDG dirs scanned by **every** environment: wofi, GNOME, KDE…), exactly like a pacman install, and are removed again on uninstall. Search shows the real status of each app (Installed / Update available). This is covered by an **integration test** that drives the real flatpak CLI (install, list, update, search, uninstall).
**Adding a provider** (apt, dnf, zypper, or another distro's repos) without touching the application:
1. Implement `IPackageManager` in a `.cpp` file (copy `plugins/example-provider/example-provider.cpp` as a template).
2. Export the C ABI contract with the `FWS_PROVIDER_PLUGIN(MyManager, "id", "Name", "1.0.0", "Description", "Author")` macro.
3. Compile it as a shared library and drop it into `~/.local/share/PacManager/plugins/` or `plugins/` next to the executable.
4. Click **Rescan** on the Providers page.
4. Click **Rescan** on the Plugins page.
Building the example plugin:
**Adding an extension / addon** (anything, as long as it is C++):
1. Implement `IPlugin` in a `.cpp` file (copy `plugins/example-addon/example-addon.cpp` as a template). The `onLoad()` / `onUnload()` lifecycle hooks are called by the application, and `onUiReady(QMainWindow*)` hands you the main window to attach your own widgets (status bar, buttons, …).
2. Export the C ABI contract with the `FWS_ADDON_PLUGIN(MyAddon, "id", "Name", "1.0.0", "Description", "Author")` macro.
3. Compile it as a shared library and drop it into `~/.local/share/PacManager/plugins/` or `plugins/` next to the executable.
4. Click **Rescan** on the Plugins page.
Building the example plugins:
```bash
cmake -B build -DFWS_BUILD_EXAMPLE_PLUGIN=ON && cmake --build build
# build/plugins/libsample-provider.so is copied next to the executable
cmake -B build -DFWS_BUILD_EXAMPLE_PLUGIN=ON -DFWS_BUILD_EXAMPLE_ADDON=ON && cmake --build build
# build/plugins/libsample-provider.so and build/plugins/libsample-addon.so are copied next to the executable
```
The plugin must be compiled with the same compiler and headers as the application (like a regular Qt plugin).
+36 -14
View File
@@ -9,7 +9,7 @@ Gestionnaire de paquets pour **Arch Linux** basé sur **pacman**, avec interface
- 🗑️ **Suppression** de paquets
- 🔄 **Mise à jour** individuelle ou globale
- 📋 **Historique** de toutes les actions
- 🧩 **Multi-fournisseurs** : pacman et Flatpak intégrés, plus des **plugins** pour ajouter d'autres gestionnaires (apt, dnf, …)
- 🧩 **Plugins** : gestionnaires de paquets (pacman intégré, **Flatpak livré par défaut**) et **extensions** écrites en C++ (addons graphiques, helpers, …)
## Architecture
@@ -18,8 +18,10 @@ package-manager/
├── CMakeLists.txt # Build root
├── include/
│ ├── package-manager.h # Interface du gestionnaire de paquets (IPackageManager)
│ ├── provider-plugin.h # Contrat C ABI des plugins fournisseurs│ ├── pacman-manager.h # Gestionnaire pacman (Arch Linux, intégré)
│ ├── plugin-manager.h # Registre des fournisseurs + chargement des plugins
│ ├── plugin.h # Contrat générique des plugins (PluginInfo, IPlugin)
│ ├── provider-plugin.h # Contrat C ABI des plugins (fournisseurs + addons)
│ ├── pacman-manager.h # Gestionnaire pacman (Arch Linux, intégré)
│ ├── plugin-manager.h # Registre des plugins + chargement des bibliothèques
│ ├── main-window.h # GUI principal
│ ├── history-manager.h # Historique des actions
│ └── package-model.h # Modèle Qt pour la liste
@@ -32,8 +34,9 @@ package-manager/
│ ├── history-manager.cpp
│ └── package-model.cpp
├── plugins/
│ ├── example-provider/ # Plugin externe d'exemple (modèle à copier)
│ └── flatpak-provider/ # Plugin Flatpak (chargé à l'exécution)
│ ├── example-provider/ # Plugin fournisseur externe d'exemple (modèle à copier)
│ ├── example-addon/ # Plugin addon externe d'exemple (extension, modèle à copier)
│ └── flatpak-provider/ # Plugin Flatpak (chargé à l'exécution, construit par défaut)
├── tests/ # Tests unitaires (assert, sans Qt)
└── resources/
```
@@ -56,6 +59,11 @@ cmake -B build -DFWS_BUILD_EXAMPLE_PLUGIN=ON
cmake --build build -j$(nproc)
```
Le **plugin Flatpak est construit par défaut** (`FWS_BUILD_FLATPAK_PLUGIN=ON`) : un `cmake -B build` simple suffit pour obtenir une app avec Flatpak disponible. Options utiles :
- `-DFWS_BUILD_FLATPAK_PLUGIN=OFF` : ne pas construire le plugin Flatpak ;
- `-DFWS_BUILD_EXAMPLE_ADDON=ON` : construire aussi le plugin addon d'exemple (`build/plugins/libsample-addon.so`).
### Installer
**Installation utilisateur** (recommandée, sans sudo — le binaire va dans `~/.local/bin`) :
@@ -117,7 +125,7 @@ L'interface utilise **Qt6** avec un thème sombre, une **sidebar de navigation**
- ⬆️ **Mises à jour** : paquets obsolètes détectés par `pacman -Qu`, bouton « Tout mettre à jour »
- 📋 **Historique** : tableau filtrable (installations / suppressions / mises à jour)
- 📜 **Logs** : journal `/var/log/pacman.log` intégré
- 🧩 **Providers** : liste des gestionnaires (intégrés et plugins), activation / désactivation et rechargement des plugins
- 🧩 **Plugins** : liste de tous les plugins (fournisseurs de paquets et extensions), activation / désactivation et rechargement
### Aperçu de l'interface
```text
@@ -141,7 +149,12 @@ L'interface utilise **Qt6** avec un thème sombre, une **sidebar de navigation**
└──────────────────────────────────────────────────────────────────────────────────────┘
```
## Gestionnaires de paquets (providers)
## Plugins & extensions
Deux types de plugins coexistent, tous deux écrits en **C++** :
- **Fournisseurs** (`IPackageManager`) : ajoutent un gestionnaire de paquets (pacman intégré, Flatpak externe, apt, dnf, …) ;
- **Extensions / addons** (`IPlugin`) : tout le reste — addon graphique, helper, amélioration du chargement… — sans rapport avec la gestion de paquets.
L'interface `IPackageManager` (implémentée par `PacmanManager` et `FlatpakManager`) définit :
@@ -165,22 +178,31 @@ L'interface `IPackageManager` (implémentée par `PacmanManager` et `FlatpakMana
| `listUpdates()` | Liste des paquets obsolètes |
| `refresh(callback)` | Rafraîchit les sources |
La recherche interroge **tous les fournisseurs actifs à la fois** : chaque résultat porte sa provenance dans la colonne **Fournisseur** (Pacman, Flatpak, …) et les pages Installés / Mises à jour sont agrégées. Installation, suppression et mise à jour sont routées automatiquement vers le bon gestionnaire. La page **Providers** de la barre latérale permet d'activer / désactiver chaque fournisseur, de recharger les plugins et d'**installer l'outil manquant** (ex. « Installer l'outil » pour Flatpak lance `sudo pacman -S flatpak` puis rend le fournisseur disponible).
La recherche interroge **tous les fournisseurs actifs à la fois** : chaque résultat porte sa provenance dans la colonne **Fournisseur** (Pacman, Flatpak, …) et les pages Installés / Mises à jour sont agrégées. Installation, suppression et mise à jour sont routées automatiquement vers le bon gestionnaire. La page **Plugins** de la barre latérale liste tout (fournisseurs **et** addons), permet d'activer / désactiver chaque plugin, de recharger les plugins et d'**installer l'outil manquant** (ex. « Installer l'outil » pour Flatpak lance `sudo pacman -S flatpak` puis rend le fournisseur disponible).
### Ajouter un fournisseur (plugins)
### Ajouter un plugin
**Pacman** est **intégré** (compilé dans l'application) ; **Flatpak** est un **plugin externe** chargé à l'exécution depuis `plugins/` (`plugins/flatpak-provider`), à côté de l'exécutable ou dans `~/.local/share/PacManager/plugins/`. L'installation Flatpak ajoute automatiquement le dépôt flathub si besoin et retombe en installation **utilisateur** (sans mot de passe) quand l'installation système échoue (polkit, plusieurs dépôts homonymes) — l'erreur réelle est affichée en cas d'échec. Une app installée via Flatpak apparaît immédiatement dans le launcher du bureau : ses entrées `.desktop` et ses icônes sont liées dans `~/.local/share/applications` et `~/.local/share/icons` (les dossiers XDG scannés par **tout** environnement : wofi, GNOME, KDE…), exactement comme une installation pacman, et retirées à la désinstallation. La recherche affiche le statut réel de chaque app (Installé / Mise à jour disponible). Le tout est couvert par un **test d'intégration** qui pilote le vrai CLI flatpak (install, liste, mise à jour, recherche, désinstallation). Pour ajouter un autre gestionnaire (apt, dnf, zypper, ou les dépôts d'une autre distro) sans toucher à l'application :
**Pacman** est **intégré** (compilé dans l'application) ; **Flatpak** est un **plugin externe** chargé à l'exécution depuis `plugins/` (`plugins/flatpak-provider`), à côté de l'exécutable ou dans `~/.local/share/PacManager/plugins/`, et **construit par défaut** (`FWS_BUILD_FLATPAK_PLUGIN=ON`). L'installation Flatpak ajoute automatiquement le dépôt flathub si besoin et retombe en installation **utilisateur** (sans mot de passe) quand l'installation système échoue (polkit, plusieurs dépôts homonymes) — l'erreur réelle est affichée en cas d'échec. Une app installée via Flatpak apparaît immédiatement dans le launcher du bureau : ses entrées `.desktop` et ses icônes sont liées dans `~/.local/share/applications` et `~/.local/share/icons` (les dossiers XDG scannés par **tout** environnement : wofi, GNOME, KDE…), exactement comme une installation pacman, et retirées à la désinstallation. La recherche affiche le statut réel de chaque app (Installé / Mise à jour disponible). Le tout est couvert par un **test d'intégration** qui pilote le vrai CLI flatpak (install, liste, mise à jour, recherche, désinstallation).
**Ajouter un fournisseur** (apt, dnf, zypper, ou les dépôts d'une autre distro) sans toucher à l'application :
1. Implémentez `IPackageManager` dans un fichier `.cpp` (copiez `plugins/example-provider/example-provider.cpp` comme modèle).
2. Exportez le contrat C ABI avec la macro `FWS_PROVIDER_PLUGIN(MyManager, "id", "Nom", "1.0.0", "Description", "Auteur")`.
3. Compilez en bibliothèque partagée et déposez-la dans `~/.local/share/PacManager/plugins/` ou `plugins/` à côté de l'exécutable.
4. Cliquez sur **Recharger** dans la page Providers.
4. Cliquez sur **Recharger** dans la page Plugins.
Build du plugin d'exemple :
**Ajouter une extension / addon** (n'importe quoi, tant que c'est du C++) :
1. Implémentez `IPlugin` dans un fichier `.cpp` (copiez `plugins/example-addon/example-addon.cpp` comme modèle). Les hooks de cycle de vie `onLoad()` / `onUnload()` sont appelés par l'application, et `onUiReady(QMainWindow*)` vous donne la fenêtre principale pour attacher vos widgets (barre de statut, boutons, …).
2. Exportez le contrat C ABI avec la macro `FWS_ADDON_PLUGIN(MyAddon, "id", "Nom", "1.0.0", "Description", "Auteur")`.
3. Compilez en bibliothèque partagée et déposez-la dans `~/.local/share/PacManager/plugins/` ou `plugins/` à côté de l'exécutable.
4. Cliquez sur **Recharger** dans la page Plugins.
Build des plugins d'exemple :
```bash
cmake -B build -DFWS_BUILD_EXAMPLE_PLUGIN=ON && cmake --build build
# build/plugins/libsample-provider.so est copié à côté de l'exécutable
cmake -B build -DFWS_BUILD_EXAMPLE_PLUGIN=ON -DFWS_BUILD_EXAMPLE_ADDON=ON && cmake --build build
# build/plugins/libsample-provider.so et build/plugins/libsample-addon.so sont copiés à côté de l'exécutable
```
Le plugin doit être compilé avec le même compilateur et les mêmes en-têtes que l'application (comme un plugin Qt classique).