Compare commits
17
Commits
78b279aeee
...
V1.6.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9343f53bae | ||
|
|
111143cd4c
|
||
|
|
55718064a6
|
||
|
|
f4aa661b54
|
||
|
|
bea3d61045
|
||
|
|
70a933e5ba | ||
|
|
62d1d67a09
|
||
|
|
fcb69939a3
|
||
|
|
494906d3f7 | ||
|
|
586e4fd0a8 | ||
|
|
3ad11318d9 | ||
|
|
3a77cb8f42
|
||
|
|
65b3496b42
|
||
|
|
05d9a16fe7
|
||
|
|
ab405d3018
|
||
|
|
9252261e24
|
||
|
|
3e4ed92c0a
|
No files matched your search
@@ -46,7 +46,7 @@
|
||||
### Commits demandés par l'utilisateur
|
||||
|
||||
- Lorsque l'utilisateur demande explicitement de créer un commit, l'IA doit le faire après avoir vérifié les changements et les contrôles disponibles, sans attendre une confirmation supplémentaire.
|
||||
- Le titre et le corps du commit ne doivent jamais mentionner l'IA, l'assistant, Codebuff ou l'outil utilisé.
|
||||
- **Le titre et le corps du commit ne doivent jamais mentionner l'IA, l'assistant, Codebuff ou l'outil utilisé.**
|
||||
- **Ne pas ajouter l'IA comme auteur ou co-auteur dans le message du commit.** cette regles est la plus importante.
|
||||
|
||||
## Bonnes pratiques pour un agent
|
||||
|
||||
+30
-1
@@ -30,11 +30,16 @@ find_package(ZLIB REQUIRED)
|
||||
set(SOURCES
|
||||
app/main.cpp
|
||||
app/main-window.cpp
|
||||
# Command-line front-end: parsing, then the runner over the logic layer.
|
||||
cli/cli-command.cpp
|
||||
cli/cli-application.cpp
|
||||
providers/pacman-manager.cpp
|
||||
plugins/plugin-manager.cpp
|
||||
history/history-manager.cpp
|
||||
core/package-model.cpp
|
||||
update/update-manager.cpp
|
||||
# Headless pass run at login by the systemd unit the app installs itself.
|
||||
core/startup-check.cpp
|
||||
logging/app-logging.cpp
|
||||
preferences/app-settings.cpp
|
||||
preferences/language-manager.cpp
|
||||
@@ -60,6 +65,8 @@ set(SOURCES
|
||||
|
||||
set(HEADERS
|
||||
include/sdk/package-manager.h
|
||||
cli/cli-command.h
|
||||
cli/cli-application.h
|
||||
providers/pacman-manager.h
|
||||
plugins/plugin-manager.h
|
||||
include/sdk/provider-plugin.h
|
||||
@@ -67,6 +74,7 @@ set(HEADERS
|
||||
history/history-manager.h
|
||||
core/package-model.h
|
||||
update/update-manager.h
|
||||
core/startup-check.h
|
||||
logging/app-logging.h
|
||||
preferences/app-settings.h
|
||||
preferences/language-manager.h
|
||||
@@ -97,7 +105,7 @@ add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES ENABLE_EXPORTS ON)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
include pages pages/base pages/packages pages/overview pages/system pages/extensions include/sdk logging preferences history archive update plugins providers core app)
|
||||
include pages pages/base pages/packages pages/overview pages/system pages/extensions include/sdk logging preferences history archive update plugins providers core app cli)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets Qt6::Network ZLIB::ZLIB)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||
FWSPACMANAGE_VERSION="${PACMANAGER_VERSION}"
|
||||
@@ -213,9 +221,11 @@ add_test(NAME aur-manager-test COMMAND aur-manager-test)
|
||||
add_executable(app-core-test tests/app-core.test.cpp
|
||||
core/app-core.cpp core/workers.cpp providers/pacman-manager.cpp
|
||||
plugins/plugin-manager.cpp history/history-manager.cpp update/update-manager.cpp
|
||||
core/startup-check.cpp
|
||||
plugins/plugin-package.cpp archive/zip-archive.cpp
|
||||
logging/app-logging.cpp logging/log-manager.cpp preferences/app-settings.cpp
|
||||
core/app-core.h core/workers.h update/update-manager.h
|
||||
core/startup-check.h
|
||||
plugins/plugin-package.h archive/zip-archive.h logging/log-manager.h
|
||||
preferences/app-settings.h)
|
||||
target_include_directories(app-core-test PRIVATE include include/sdk logging preferences history archive update plugins providers core app)
|
||||
@@ -250,6 +260,14 @@ target_compile_definitions(language-manager-test PRIVATE
|
||||
PACMANAGER_TRANSLATIONS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/translations")
|
||||
add_test(NAME language-manager-test COMMAND language-manager-test)
|
||||
|
||||
# The command-line grammar: which arguments ask for the command line rather than
|
||||
# the window, and what each keyword parses into. Pure parsing — no package
|
||||
# manager, no display, nothing spawned (the runner is exercised by hand).
|
||||
add_executable(cli-command-test tests/cli-command.test.cpp cli/cli-command.cpp)
|
||||
target_include_directories(cli-command-test PRIVATE include include/sdk logging preferences history archive update plugins providers core app cli)
|
||||
target_link_libraries(cli-command-test PRIVATE Qt6::Core)
|
||||
add_test(NAME cli-command-test COMMAND cli-command-test)
|
||||
|
||||
# ---- Translations ----
|
||||
#
|
||||
# The language setting loads a catalogue named <code>.json out of a
|
||||
@@ -294,6 +312,17 @@ target_compile_definitions(update-manager-test PRIVATE
|
||||
FWSPACMANAGE_VERSION="${PACMANAGER_VERSION}")
|
||||
add_test(NAME update-manager-test COMMAND update-manager-test)
|
||||
|
||||
# StartupCheck: the pure half (parsing, critical/reboot classification,
|
||||
# notification text) and the autostart files, driven inside a temporary tree so
|
||||
# the user's own ~/.config is never touched.
|
||||
add_executable(startup-check-test tests/startup-check.test.cpp
|
||||
core/startup-check.cpp logging/log-manager.cpp logging/app-logging.cpp
|
||||
preferences/app-settings.cpp
|
||||
core/startup-check.h logging/log-manager.h preferences/app-settings.h)
|
||||
target_include_directories(startup-check-test PRIVATE include include/sdk logging preferences history archive update plugins providers core app)
|
||||
target_link_libraries(startup-check-test PRIVATE Qt6::Core)
|
||||
add_test(NAME startup-check-test COMMAND startup-check-test)
|
||||
|
||||
# ---- Plugins ----
|
||||
#
|
||||
# Flatpak ships as an external provider plugin (not compiled into the binary):
|
||||
|
||||
+7
-3
@@ -53,7 +53,7 @@ download. Once built:
|
||||
cd build && ctest --output-on-failure
|
||||
```
|
||||
|
||||
There are **9 tests**. Most are unit tests that never touch the system;
|
||||
There are **13 tests**. Most are unit tests that never touch the system;
|
||||
`flatpak-integration-test` is the only one that drives the real flatpak CLI (in
|
||||
an isolated temporary installation), and `app-core-test` checks in particular
|
||||
that every privileged path goes through the password gate — **without ever
|
||||
@@ -69,13 +69,17 @@ replaying a request**, so it can never run pacman as root.
|
||||
| `progress-tracker-test` | reading a tool's output, progress, ANSI |
|
||||
| `package-utils-test` | the shared package utilities |
|
||||
| `plugin-package-test` | the `.fwspacm` package format and its installation |
|
||||
| `app-settings-test` | the preferences model and the journal |
|
||||
| `language-manager-test` | the language: resolution, catalogues, coverage |
|
||||
| `cli-command-test` | the command-line grammar |
|
||||
| `update-manager-test` | version detection and self-update |
|
||||
| `startup-check-test` | the update check run at login |
|
||||
|
||||
[doc/tests.md](doc/tests.md) details each target and explains how to add one.
|
||||
|
||||
## Code conventions
|
||||
|
||||
- **Language**: C++20, Qt6. Follow the existing stack and conventions before
|
||||
- **Language**: C++17, Qt6. Follow the existing stack and conventions before
|
||||
adding any dependency.
|
||||
- **Formatting**: `.clang-format` (LLVM, 4 spaces, attached braces, 100
|
||||
columns). Run `clang-format -i <file>` before committing.
|
||||
@@ -104,7 +108,7 @@ The split is structural and not negotiable:
|
||||
|
||||
Adding a screen = a `Page` class (see `pages/base/page.h`) and an entry in the
|
||||
sidebar. Adding a package manager = a plugin implementing `IPackageManager` in
|
||||
`plugins/` — **without touching the application** (see
|
||||
`providers/` — **without touching the application** (see
|
||||
[doc/plugins.md](doc/plugins.md)).
|
||||
|
||||
## Workflow
|
||||
|
||||
+9
-4
@@ -53,8 +53,9 @@ framework, pas de téléchargement. Après avoir compilé :
|
||||
cd build && ctest --output-on-failure
|
||||
```
|
||||
|
||||
Ce sont **9 tests**. La plupart sont unitaires et ne touchent pas au système ;
|
||||
`flatpak-integration-test` est le seul à piloter le vrai CLI flatpak(dans une installation temporaire isolée), et `app-core-test` vérifie notamment que
|
||||
Ce sont **13 tests**. La plupart sont unitaires et ne touchent pas au système ;
|
||||
`flatpak-integration-test` est le seul à piloter le vrai CLI flatpak (dans une
|
||||
installation temporaire isolée), et `app-core-test` vérifie notamment que
|
||||
toute action privilégiée passe par la porte du mot de passe — **sans jamais
|
||||
rejouer une requête**, donc sans jamais exécuter pacman en root.
|
||||
|
||||
@@ -68,14 +69,18 @@ rejouer une requête**, donc sans jamais exécuter pacman en root.
|
||||
| `progress-tracker-test` | lecture de la sortie d'un outil, progression, ANSI |
|
||||
| `package-utils-test` | les utilitaires de paquets partagés |
|
||||
| `plugin-package-test` | le format des paquets `.fwspacm` et leur installation |
|
||||
| `app-settings-test` | le modèle des préférences et le journal |
|
||||
| `language-manager-test` | la langue : résolution, catalogues, couverture |
|
||||
| `cli-command-test` | la grammaire de la ligne de commande |
|
||||
| `update-manager-test` | la détection de version et l'auto-mise à jour |
|
||||
| `startup-check-test` | la vérification des mises à jour au démarrage |
|
||||
|
||||
[doc/tests.md](doc/tests.md) détaille chaque cible et explique comment en
|
||||
ajouter une.
|
||||
|
||||
## Conventions de code
|
||||
|
||||
- **Langage** : C++20, Qt6. Respecter la stack et les conventions déjà en place
|
||||
- **Langage** : C++17, Qt6. Respecter la stack et les conventions déjà en place
|
||||
avant d'ajouter une dépendance.
|
||||
- **Formatage** : `.clang-format` (LLVM, 4 espaces, accolades attachées,
|
||||
100 colonnes). Lancez `clang-format -i <fichier>` avant de commiter.
|
||||
@@ -105,7 +110,7 @@ La coupure est structurante et ne se négocie pas :
|
||||
|
||||
Ajouter un écran = une classe `Page` (voir `pages/base/page.h`) et une entrée dans la
|
||||
barre latérale. Ajouter un gestionnaire de paquets = un plugin implémentant
|
||||
`IPackageManager` dans `plugins/` — **sans toucher à l'application** (voir
|
||||
`IPackageManager` dans `providers/` — **sans toucher à l'application** (voir
|
||||
[doc/plugins.md](doc/plugins.md)).
|
||||
|
||||
## Flux de travail
|
||||
|
||||
+52
-1
@@ -1,6 +1,57 @@
|
||||
# ChangeLog
|
||||
|
||||
Toutes les modifications entre la **V1.5.0** (23/09/2026) et la version courante
|
||||
## V1.6.1 — branche `release-1.6.1`
|
||||
|
||||
Deux corrections ciblées, rien d'autre : le journal ne reprend plus le bavardage
|
||||
de la couche graphique de Qt, et un fichier déposé est confirmé — ou refusé
|
||||
quand la machine le possède déjà.
|
||||
|
||||
### Le journal ne reprend plus la sortie interne de Qt
|
||||
|
||||
Chaque boîte de dialogue ouverte sous Wayland faisait écrire à Qt, dans le
|
||||
journal de l'application, une rafale de lignes de sa couche graphique :
|
||||
|
||||
```
|
||||
[2026-10-09 18:49:23] [ui] mot de passe fourni
|
||||
[2026-10-09 18:49:23] [qt/qt.qpa.wayland.textinput] avertissement: virtual void QtWaylandClient::QWaylandTextInputv3::disableSurface(wl_surface*) Trying to disable 0x… but 0x… is focused
|
||||
```
|
||||
|
||||
Ces catégories (`qt.qpa.*`) décrivent le serveur d'affichage, pas
|
||||
l'application, et l'utilisateur ne peut rien en faire : elles restent sur la
|
||||
sortie standard — là où un développeur les cherche, la console n'ayant rien
|
||||
perdu — et ne sont plus journalisées. Tout ce que l'application journalise
|
||||
d'elle-même, `pacmgr.*` compris, y est toujours ; `LogManager::journalsQtCategory()`
|
||||
porte la décision.
|
||||
|
||||
### Un fichier déposé est confirmé, et refusé s'il est déjà installé
|
||||
|
||||
Déposer un fichier Flatpak ou un paquet `.fwspacm` — ou l'ouvrir par « Ouvrir
|
||||
avec PacManager » — répond maintenant par une boîte de dialogue : ce qui a été
|
||||
pris en compte, et ce que cela déclenche (l'installation démarre et sa
|
||||
progression s'affiche en bas de la fenêtre ; un plugin est installé et utilisable
|
||||
sans redémarrer). Un dépôt restait sinon silencieux dès que l'installation
|
||||
partait en arrière-plan.
|
||||
|
||||
Un fichier dont l'application est **déjà** installée est refusé avant toute
|
||||
exécution, avec la raison. Le nom est lu dans le fichier lui-même — section
|
||||
`[Flatpak Ref]` d'un `.flatpakref`, en-tête d'un `.flatpak`, manifeste d'un
|
||||
`.fwspacm` — puis comparé à ce que le fournisseur a déjà
|
||||
(`IPackageManager::fileTargetName()` / `isPackageInstalled()`). Sans cela,
|
||||
Flatpak se contentait de sauter l'installation et de renvoyer un succès que
|
||||
l'utilisateur n'avait pas ; réinstaller un paquet de plugin écrasait celui en
|
||||
place sans le dire. Rien n'est exécuté pour lire ces fichiers, et un fichier
|
||||
qu'on ne sait pas lire (dépôt, format inconnu) s'installe comme avant.
|
||||
|
||||
*Fichiers : `logging/log-manager.*`, `include/sdk/package-manager.h`,
|
||||
`providers/flatpak-provider/flatpak-manager.*`, `core/app-core.*`,
|
||||
`app/main-window.*`, les catalogues `translations/*.json`, et les tests
|
||||
`flatpak-manager-test` / `app-settings-test` / `app-core-test`.*
|
||||
|
||||
---
|
||||
|
||||
## V1.6.0
|
||||
|
||||
Toutes les modifications entre la **V1.5.0** (23/09/2026) et la version
|
||||
**1.6.0** (branche `release-1.6.0`, 33 commits, 95 fichiers touchés,
|
||||
+8 758 / −2 308 lignes).
|
||||
|
||||
|
||||
+79
-47
@@ -14,6 +14,22 @@ Package manager for **Arch Linux** based on **pacman**, with a Qt6 graphical int
|
||||
- 📥 **Flatpak files**: drop a `.flatpakref`, `.flatpakrepo` or `.flatpak` onto the window (or right-click → **Open with PacManager** in your file manager) to install it directly — with the bytes actually downloaded and the elapsed time shown live, since flatpak prints nothing while a runtime comes down
|
||||
- 🔁 **Several installations**: an application installed per-user *and* system-wide, or from two remotes, stays a **single row**; the details panel lists the copies and **Remove** opens one checkbox per installation so the user picks the ones to get rid of
|
||||
- ⚙️ **Settings**: when the admin password is asked, **where** the journal is written and how large it may grow, drag & drop of Flatpak files on or off, the interface language, and PacManager's own update policy (automatic check, block for 1 h / 24 h / 7 days / until cancelled)
|
||||
- ⌨️ **Command line**: `pacmanager search vlc` then `pacmanager install vlc` — the same logic as the window, without a screen (see [doc/cli.md](doc/cli.md))
|
||||
|
||||
## Command line
|
||||
|
||||
The same logic as the window can be used without opening an interface:
|
||||
|
||||
```bash
|
||||
pacmanager search vlc
|
||||
pacmanager install vlc
|
||||
pacmanager updates
|
||||
```
|
||||
|
||||
Commands: `search`, `install`, `remove`, `update`, `list`, `updates`, `info`,
|
||||
`refresh`, `cleanup`, `help`, `version` (French keywords accepted too). `-y` /
|
||||
`--yes` skips confirmations, `--help` prints the help. The details are in
|
||||
[doc/cli.md](doc/cli.md).
|
||||
|
||||
## Architecture
|
||||
|
||||
@@ -45,49 +61,52 @@ signals (`listFinished`, `actionProgress`, `actionFinished`, `statusMessage`…)
|
||||
Every operation that spawns a process is asynchronous.
|
||||
|
||||
```
|
||||
package-manager/
|
||||
├── CMakeLists.txt # Build root
|
||||
├── include/
|
||||
│ ├── app-core.h # LOGIC: everything the app does (no widget)
|
||||
│ ├── workers.h # Shared threads (search / listings / actions)
|
||||
│ ├── package-manager.h # Package manager interface (IPackageManager)
|
||||
│ ├── 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 # Plugin registry + shared-library loading
|
||||
│ ├── plugin-package.h # Installing a .fwspacm plugin package
|
||||
│ ├── zip-archive.h # Minimal ZIP reader (zlib)
|
||||
│ ├── main-window.h # INTERFACE: the window frame
|
||||
│ ├── history-manager.h # Action history
|
||||
│ ├── package-model.h # Qt model for the list
|
||||
│ └── update-manager.h # Self-update (releases)
|
||||
├── src/
|
||||
│ ├── main.cpp
|
||||
│ ├── app-core.cpp
|
||||
│ ├── workers.cpp
|
||||
│ ├── main-window.cpp
|
||||
│ ├── pacman-manager.cpp
|
||||
│ ├── plugin-manager.cpp
|
||||
│ ├── history-manager.cpp
|
||||
│ ├── package-model.cpp
|
||||
│ ├── update-manager.cpp
|
||||
│ └── app-logging.cpp
|
||||
PacManager/
|
||||
├── CMakeLists.txt # app, plugins and tests targets
|
||||
├── app/ # FRAME: the window and the entry point
|
||||
│ ├── main.cpp # entry point: journal, language, window, CLI
|
||||
│ └── main-window.h/.cpp # sidebar, menus, dialogs, stylesheet
|
||||
├── cli/ # COMMAND LINE (no widget)
|
||||
│ ├── cli-command.h/.cpp # accepted grammar (tested)
|
||||
│ └── cli-application.h/.cpp # execution on AppCore
|
||||
├── core/ # LOGIC: everything the app does
|
||||
│ ├── app-core.h/.cpp # the controller the screens delegate to
|
||||
│ ├── workers.h/.cpp # worker threads (search, listings, actions)
|
||||
│ └── package-model.h/.cpp # Qt model for the lists
|
||||
├── providers/ # package providers
|
||||
│ ├── pacman-manager.h/.cpp # pacman, built-in
|
||||
│ ├── flatpak-provider/ # Flatpak provider
|
||||
│ ├── aur-provider/ # AUR provider (yay/paru)
|
||||
│ ├── example-provider/ # provider template
|
||||
│ └── example-addon/ # extension template
|
||||
├── plugins/ # plugin host
|
||||
│ ├── plugin-manager.h/.cpp # registry + shared-library loading
|
||||
│ └── plugin-package.h/.cpp # installing a .fwspacm package
|
||||
├── preferences/ # what the user chose
|
||||
│ ├── app-settings.h/.cpp # the settings model
|
||||
│ └── language-manager.h/.cpp # interface and journal language
|
||||
├── logging/ # the journal
|
||||
│ ├── log-manager.h/.cpp # operations.log, read by the Logs screen
|
||||
│ └── app-logging.h/.cpp # qCDebug/qCInfo categories
|
||||
├── history/ # action history (CSV)
|
||||
├── update/ # PacManager self-update
|
||||
├── archive/ # minimal ZIP reader (zlib), for .fwspacm
|
||||
├── include/sdk/ # public plugin SDK (installed flat)
|
||||
│ ├── package-manager.h # IPackageManager interface + merge helpers
|
||||
│ ├── plugin.h # generic plugin contract (IPlugin)
|
||||
│ ├── provider-plugin.h # C ABI contract for external plugins
|
||||
│ ├── progress-tracker.h # progress read from the tools' output
|
||||
│ └── provider-trace.h # provider trace, journal only
|
||||
├── pages/ # INTERFACE: one file per screen
|
||||
│ ├── page.h/.cpp # Screen contract (Page) + helpers
|
||||
│ ├── ui-kit.h/.cpp # Shared widgets (tables, cards, badges)
|
||||
│ ├── dashboard-page.h/.cpp # Dashboard
|
||||
│ ├── browse-page.h/.cpp # Search / installed / updates
|
||||
│ ├── cleanup-page.h/.cpp # Cleanup
|
||||
│ ├── history-page.h/.cpp # History
|
||||
│ ├── logs-page.h/.cpp # pacman logs
|
||||
│ └── plugins-page.h/.cpp # Plugins
|
||||
├── plugins/
|
||||
│ ├── 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)
|
||||
├── make-plugin-package.py # Builds a .fwspacm package from a shared library
|
||||
├── tests/ # Unit tests (assert, no Qt)
|
||||
└── resources/
|
||||
│ ├── base/ # screen contract + shared widgets
|
||||
│ ├── packages/ # search, installed, updates, cleanup
|
||||
│ ├── overview/ # dashboard, history
|
||||
│ ├── system/ # logs, settings
|
||||
│ └── extensions/ # plugins
|
||||
├── translations/ # catalogues, one JSON per language (French is the source)
|
||||
├── doc/ # this documentation (source of the wiki)
|
||||
├── tests/ # unit and integration tests
|
||||
└── resources/ # icons and catalogues compiled into the binary
|
||||
```
|
||||
|
||||
## Compilation (Arch Linux)
|
||||
@@ -101,7 +120,7 @@ sudo pacman -S qt6-base cmake gcc base-devel
|
||||
### Build
|
||||
|
||||
```bash
|
||||
cd package-manager
|
||||
cd FWS-PacManage
|
||||
|
||||
# Configure and compile
|
||||
cmake -B build -DFWS_BUILD_EXAMPLE_PLUGIN=ON
|
||||
@@ -183,6 +202,19 @@ The method is picked automatically (no configuration):
|
||||
| **Prebuilt** | no build toolchain nor pacman, and the release has a prebuilt archive attached | that archive is downloaded and unpacked |
|
||||
| **Tarball** | no `git`, but a toolchain present or installable | missing build dependencies are installed first, the release sources are built and installed |
|
||||
|
||||
> ⚠️ **Updating from a version older than 1.5.0**: installing the build
|
||||
> dependencies automatically only exists from **1.5.0** on. A **1.4.3 or older**
|
||||
> build recompiles with whatever it finds: if `cmake`, `gcc`/`base-devel`, `git`
|
||||
> or `qt6-base` are missing, the update fails — or is not even offered (method
|
||||
> "None", releases page). Install them first:
|
||||
>
|
||||
> ```bash
|
||||
> sudo pacman -S --needed base-devel cmake gcc git qt6-base
|
||||
> ```
|
||||
>
|
||||
> Once on 1.5.0, PacManager handles it itself as soon as the sudo password is
|
||||
> entered. Full detail: [doc/mise-a-jour.md](doc/mise-a-jour.md).
|
||||
|
||||
Everything builds in a temporary directory: `sudo` is only used for the final
|
||||
binary replacement (when the target directory is root-owned) and for
|
||||
**automatically installing the build dependencies** — when `qt6-base`, `cmake`,
|
||||
@@ -211,7 +243,7 @@ The interface uses **Qt6** with a dark theme, a **navigation sidebar** and stack
|
||||
- ⬆️ **Updates**: outdated packages detected by `pacman -Qu`, **the check runs as soon as the tab opens** (no need to press "Update all" to see the list), "Update all" button
|
||||
- 🧹 **Cleanup**: **orphan** packages (`pacman -Qdt`, nothing requires them) and **legacy** ones (`pacman -Qm`, AUR / manual builds), bulk removal of the orphans, and cache trimming: `paccache` / `pacman -Sc` and unused Flatpak runtimes (`flatpak uninstall --unused`)
|
||||
- 📋 **History**: filterable table (installs / removals / updates / cleanups) + CSV export
|
||||
- 📜 **Logs**: built-in `/var/log/pacman.log` viewer with an instant filter
|
||||
- 📜 **Logs**: the application journal (`operations.log`: operations, command output, provider trace) **and** `/var/log/pacman.log`, selectable, with an instant filter
|
||||
- 🧩 **Plugins**: lists every plugin (package providers and extensions), enable / disable and plugin rescan
|
||||
- ⌨️ **Convenience**: system tray icon and keyboard shortcuts (Ctrl+F search, Ctrl+R / F5 refresh, Ctrl+U updates, Ctrl+E export, Ctrl+Q quit)
|
||||
- 🔒 **pacman lock**: when another manager (pamac, octopi, yay…) holds the database, PacManager names it (process + PID) and offers to close it and resume the operation, instead of waiting for it to finish; a leftover lock is removed the same way
|
||||
@@ -299,18 +331,18 @@ Search queries **all active providers at once**: every result shows its origin i
|
||||
|
||||
### 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/`, 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). A **Flatpak file** can also be installed directly, without going through search: drop it on the window or pick **Open with PacManager** in the file manager (`.flatpakref` and `.flatpak` start an install, `.flatpakrepo` registers the remote under the file's name). This is covered by an **integration test** that drives the real flatpak CLI (install, list, update, search, uninstall).
|
||||
**Pacman** is **built-in** (compiled into the application); **Flatpak** is an **external plugin** loaded at runtime from `plugins/` (source in `providers/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). A **Flatpak file** can also be installed directly, without going through search: drop it on the window or pick **Open with PacManager** in the file manager (`.flatpakref` and `.flatpak` start an install, `.flatpakrepo` registers the remote under the file's name). 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).
|
||||
1. Implement `IPackageManager` in a `.cpp` file (copy `providers/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 Plugins page.
|
||||
|
||||
**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, …).
|
||||
1. Implement `IPlugin` in a `.cpp` file (copy `providers/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.
|
||||
|
||||
@@ -14,6 +14,22 @@ Gestionnaire de paquets pour **Arch Linux** basé sur **pacman**, avec interface
|
||||
- 📥 **Fichiers Flatpak** : glissez-déposez un `.flatpakref`, `.flatpakrepo` ou `.flatpak` sur la fenêtre (ou clic droit → **Ouvrir avec PacManager** dans le gestionnaire de fichiers) pour l'installer directement — avec les octets réellement téléchargés et le temps écoulé affichés en direct, flatpak n'imprimant rien pendant le téléchargement d'un runtime
|
||||
- 🔁 **Installations multiples** : une application installée en utilisateur *et* en système, ou depuis deux dépôts, reste **une seule ligne** ; la fiche de détail énumère les copies et **Supprimer** ouvre une case par installation pour choisir celles à retirer
|
||||
- ⚙️ **Paramètres** : quand demander le mot de passe administrateur, **où** et à quelle taille maximale écrire le journal, activer ou désactiver le glisser-déposer Flatpak, la langue de l'interface, et la politique de mise à jour de PacManager (vérification automatique, blocage 1 h / 24 h / 7 jours / jusqu'à annulation)
|
||||
- ⌨️ **Ligne de commande** : `pacmanager recherche vlc` puis `pacmanager install vlc` — la même logique que la fenêtre, sans écran (voir [doc/cli.md](doc/cli.md))
|
||||
|
||||
## Ligne de commande
|
||||
|
||||
La même logique que la fenêtre s'utilise sans ouvrir d'interface :
|
||||
|
||||
```bash
|
||||
pacmanager recherche vlc
|
||||
pacmanager install vlc
|
||||
pacmanager maj-dispo
|
||||
```
|
||||
|
||||
Commandes : `recherche`, `install`, `supprimer`, `maj`, `liste`, `maj-dispo`,
|
||||
`info`, `refresh`, `nettoyage`, `aide`, `version` (alias anglais acceptés).
|
||||
`-y` / `--yes` saute les confirmations, `--help` affiche l'aide. Le détail est
|
||||
dans [doc/cli.md](doc/cli.md).
|
||||
|
||||
## Architecture
|
||||
|
||||
@@ -47,49 +63,52 @@ résultats reviennent par signaux (`listFinished`, `actionProgress`,
|
||||
asynchrone.
|
||||
|
||||
```
|
||||
package-manager/
|
||||
├── CMakeLists.txt # Build root
|
||||
├── include/
|
||||
│ ├── app-core.h # LOGIQUE : tout ce que l'app fait (sans widget)
|
||||
│ ├── workers.h # Threads partagés (recherche / listes / actions)
|
||||
│ ├── package-manager.h # Interface du gestionnaire de paquets (IPackageManager)
|
||||
│ ├── 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
|
||||
│ ├── plugin-package.h # Installation d'un paquet de plugin .fwspacm
|
||||
│ ├── zip-archive.h # Lecteur ZIP minimal (zlib)
|
||||
│ ├── main-window.h # INTERFACE : le cadre de la fenêtre
|
||||
│ ├── history-manager.h # Historique des actions
|
||||
│ ├── package-model.h # Modèle Qt pour la liste
|
||||
│ └── update-manager.h # Auto-mise à jour (releases)
|
||||
├── src/
|
||||
│ ├── main.cpp
|
||||
│ ├── app-core.cpp
|
||||
│ ├── workers.cpp
|
||||
│ ├── main-window.cpp
|
||||
│ ├── pacman-manager.cpp
|
||||
│ ├── plugin-manager.cpp
|
||||
│ ├── history-manager.cpp
|
||||
│ ├── package-model.cpp
|
||||
│ ├── update-manager.cpp
|
||||
│ └── app-logging.cpp
|
||||
PacManager/
|
||||
├── CMakeLists.txt # cible application, plugins, tests
|
||||
├── app/ # CADRE : la fenêtre et le point d'entrée
|
||||
│ ├── main.cpp # point d'entrée : journal, langue, fenêtre, CLI
|
||||
│ └── main-window.h/.cpp # barre latérale, menus, dialogues, feuille de style
|
||||
├── cli/ # LIGNE DE COMMANDE (sans widget)
|
||||
│ ├── cli-command.h/.cpp # grammaire acceptée (testée)
|
||||
│ └── cli-application.h/.cpp # exécution sur AppCore
|
||||
├── core/ # LOGIQUE : tout ce que l'app fait
|
||||
│ ├── app-core.h/.cpp # le contrôleur dont les écrans délèguent
|
||||
│ ├── workers.h/.cpp # threads de travail (recherche, listes, actions)
|
||||
│ └── package-model.h/.cpp # modèle Qt pour les listes
|
||||
├── providers/ # fournisseurs de paquets
|
||||
│ ├── pacman-manager.h/.cpp # pacman, intégré
|
||||
│ ├── flatpak-provider/ # fournisseur Flatpak
|
||||
│ ├── aur-provider/ # fournisseur AUR (yay/paru)
|
||||
│ ├── example-provider/ # modèle de fournisseur
|
||||
│ └── example-addon/ # modèle d'extension
|
||||
├── plugins/ # hôte des plugins
|
||||
│ ├── plugin-manager.h/.cpp # registre + chargement des bibliothèques
|
||||
│ └── plugin-package.h/.cpp # installation d'un paquet .fwspacm
|
||||
├── preferences/ # ce que l'utilisateur a choisi
|
||||
│ ├── app-settings.h/.cpp # le modèle des préférences
|
||||
│ └── language-manager.h/.cpp # langue de l'interface et du journal
|
||||
├── logging/ # le journal
|
||||
│ ├── log-manager.h/.cpp # operations.log, lu par l'écran Logs
|
||||
│ └── app-logging.h/.cpp # catégories qCDebug/qCInfo
|
||||
├── history/ # historique des opérations (CSV)
|
||||
├── update/ # auto-mise à jour de PacManager
|
||||
├── archive/ # lecteur ZIP minimal (zlib), pour .fwspacm
|
||||
├── include/sdk/ # SDK public des plugins (installé à plat)
|
||||
│ ├── package-manager.h # interface IPackageManager + helpers de fusion
|
||||
│ ├── plugin.h # contrat générique d'un plugin (IPlugin)
|
||||
│ ├── provider-plugin.h # contrat C ABI des plugins externes
|
||||
│ ├── progress-tracker.h # progression lue dans la sortie des outils
|
||||
│ └── provider-trace.h # trace des providers, réservée au journal
|
||||
├── pages/ # INTERFACE : un fichier par écran
|
||||
│ ├── page.h/.cpp # Contrat d'un écran (Page) + helpers
|
||||
│ ├── ui-kit.h/.cpp # Widgets partagés (tableaux, cartes, badges)
|
||||
│ ├── dashboard-page.h/.cpp # Tableau de bord
|
||||
│ ├── browse-page.h/.cpp # Recherche / installés / mises à jour
|
||||
│ ├── cleanup-page.h/.cpp # Nettoyage
|
||||
│ ├── history-page.h/.cpp # Historique
|
||||
│ ├── logs-page.h/.cpp # Logs pacman
|
||||
│ └── plugins-page.h/.cpp # Plugins
|
||||
├── plugins/
|
||||
│ ├── 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)
|
||||
├── make-plugin-package.py # Construit un paquet .fwspacm depuis une bibliothèque
|
||||
├── tests/ # Tests unitaires (assert, sans Qt)
|
||||
└── resources/
|
||||
│ ├── base/ # contrat d'un écran + widgets partagés
|
||||
│ ├── packages/ # recherche, installés, mises à jour, nettoyage
|
||||
│ ├── overview/ # tableau de bord, historique
|
||||
│ ├── system/ # logs, paramètres
|
||||
│ └── extensions/ # plugins
|
||||
├── translations/ # catalogues, un JSON par langue (le français est la source)
|
||||
├── doc/ # cette documentation (source du wiki)
|
||||
├── tests/ # tests unitaires et d'intégration
|
||||
└── resources/ # icônes et catalogues compilés dans le binaire
|
||||
```
|
||||
|
||||
## Compilation (Arch Linux)
|
||||
@@ -103,7 +122,7 @@ sudo pacman -S qt6-base cmake gcc base-devel
|
||||
### Build
|
||||
|
||||
```bash
|
||||
cd package-manager
|
||||
cd FWS-PacManage
|
||||
|
||||
# Configurer + compiler
|
||||
cmake -B build -DFWS_BUILD_EXAMPLE_PLUGIN=ON
|
||||
@@ -185,6 +204,20 @@ La méthode est choisie automatiquement (aucune configuration) :
|
||||
| **Prebuilt** | pas d'outillage de compilation ni de pacman, et une archive précompilée est attachée à la release | l'archive est téléchargée et décompressée |
|
||||
| **Tarball** | `git` absent mais un toolchain présent ou installable | les dépendances de compilation manquantes sont installées, les sources de la release sont compilées puis installées |
|
||||
|
||||
> ⚠️ **Mise à jour depuis une version antérieure à la 1.5.0** : l'installation
|
||||
> automatique des dépendances de compilation n'existe qu'à partir de la **1.5.0**.
|
||||
> Une version **1.4.3 ou avant** recompile avec ce qu'elle trouve : si `cmake`,
|
||||
> `gcc`/`base-devel`, `git` ou `qt6-base` manquent, la mise à jour échoue — ou
|
||||
> n'est même pas proposée (méthode « Aucune », page des releases). Installez-les
|
||||
> d'abord :
|
||||
>
|
||||
> ```bash
|
||||
> sudo pacman -S --needed base-devel cmake gcc git qt6-base
|
||||
> ```
|
||||
>
|
||||
> Une fois en 1.5.0, PacManager s'en charge lui-même dès que le mot de passe sudo
|
||||
> est saisi. Détail complet : [doc/mise-a-jour.md](doc/mise-a-jour.md).
|
||||
|
||||
Tout se compile dans un dossier temporaire : `sudo` n'intervient que pour
|
||||
l'installation finale du binaire (si le dossier cible appartient à root) et pour
|
||||
**l'installation automatique des dépendances de compilation** — quand `qt6-base`,
|
||||
@@ -214,7 +247,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`, **recherche lancée dès l'arrivée sur l'onglet** (plus besoin d'appuyer sur « Tout mettre à jour » pour voir la liste), bouton « Tout mettre à jour »
|
||||
- 🧹 **Nettoyage** : paquets **orphelins** (`pacman -Qdt`, rien ne les requiert) et **legacy** (`pacman -Qm`, AUR / compilation manuelle), suppression groupée des orphelins, et purge des caches : `paccache` / `pacman -Sc` et runtimes Flatpak inutilisés (`flatpak uninstall --unused`)
|
||||
- 📋 **Historique** : tableau filtrable (installations / suppressions / mises à jour / nettoyages) + export CSV
|
||||
- 📜 **Logs** : journal `/var/log/pacman.log` intégré, avec filtre instantané
|
||||
- 📜 **Logs** : journal de l'application (`operations.log` : opérations, sortie des commandes, trace des fournisseurs) **et** `/var/log/pacman.log`, sélectionnables, avec filtre instantané
|
||||
- 🧩 **Plugins** : liste de tous les plugins (fournisseurs de paquets et extensions), activation / désactivation et rechargement
|
||||
- ⌨️ **Confort** : icône de notification (tray) et raccourcis clavier (Ctrl+F rechercher, Ctrl+R / F5 rafraîchir, Ctrl+U mises à jour, Ctrl+E exporter, Ctrl+Q quitter)
|
||||
- 🔒 **Verrou pacman** : si un autre gestionnaire (pamac, octopi, yay…) tient la base, PacManager l'identifie (nom + PID) et propose de le fermer puis de reprendre l'opération automatiquement — au lieu d'attendre qu'il ait fini ; un verrou résiduel est supprimé de la même façon
|
||||
@@ -302,19 +335,19 @@ La recherche interroge **tous les fournisseurs actifs à la fois** : chaque rés
|
||||
|
||||
### 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/`, 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. Un **fichier Flatpak** s'installe aussi directement, sans passer par la recherche : glissez-le sur la fenêtre ou choisissez **Ouvrir avec PacManager** dans le gestionnaire de fichiers (`.flatpakref` et `.flatpak` lancent l'installation, `.flatpakrepo` enregistre le dépôt sous le nom du fichier). 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).
|
||||
**Pacman** est **intégré** (compilé dans l'application) ; **Flatpak** est un **plugin externe** chargé à l'exécution depuis `plugins/` (source dans `providers/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. Un **fichier Flatpak** s'installe aussi directement, sans passer par la recherche : glissez-le sur la fenêtre ou choisissez **Ouvrir avec PacManager** dans le gestionnaire de fichiers (`.flatpakref` et `.flatpak` lancent l'installation, `.flatpakrepo` enregistre le dépôt sous le nom du fichier). 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).
|
||||
1. Implémentez `IPackageManager` dans un fichier `.cpp` (copiez `providers/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 Plugins.
|
||||
|
||||
**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")`.
|
||||
1. Implémentez `IPlugin` dans un fichier `.cpp` (copiez `providers/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, …).
|
||||
12. 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.
|
||||
|
||||
|
||||
+117
-4
@@ -475,6 +475,10 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
|
||||
if (m_core->shouldCheckForAppUpdate()) {
|
||||
QTimer::singleShot(1500, this, &MainWindow::onCheckForUpdates);
|
||||
}
|
||||
|
||||
// Keep the login check's unit in sync with where this binary actually lives
|
||||
// (an update may have moved it). Silent and idempotent.
|
||||
m_core->ensureStartupAutostart();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() = default;
|
||||
@@ -837,6 +841,20 @@ void MainWindow::setupMenuBar() {
|
||||
connect(m_credLaunchAction, &QAction::triggered, this,
|
||||
[this]() { onCredentialModeRequested(true); });
|
||||
|
||||
// The login check: the core installs (or removes) the systemd user unit that
|
||||
// runs the headless pass, so the setting is what makes the feature exist on
|
||||
// the machine — nothing to configure by hand.
|
||||
settingsMenu->addSeparator();
|
||||
m_startupCheckAction = settingsMenu->addAction(tr("Vérifier les mises à jour au démarrage"));
|
||||
m_startupCheckAction->setCheckable(true);
|
||||
m_startupCheckAction->setChecked(m_core->checkUpdatesAtStartup());
|
||||
m_startupCheckAction->setToolTip(
|
||||
tr("Prévient par une notification à l'ouverture de session quand des mises à jour "
|
||||
"sont disponibles — sans mot de passe. Installe le service utilisateur associé."));
|
||||
connect(m_startupCheckAction, &QAction::toggled, this, [this](bool enabled) {
|
||||
m_core->setCheckUpdatesAtStartup(enabled);
|
||||
});
|
||||
|
||||
QMenu* helpMenu = menuBar->addMenu(tr("Aide"));
|
||||
helpMenu->addAction(tr("Vérifier les mises à jour"), this, &MainWindow::onCheckForUpdates);
|
||||
helpMenu->addSeparator();
|
||||
@@ -1052,14 +1070,36 @@ void MainWindow::dropEvent(QDropEvent* event) {
|
||||
void MainWindow::installLocalFiles(const QStringList& paths) {
|
||||
if (paths.isEmpty()) return;
|
||||
|
||||
QStringList files;
|
||||
QStringList files; // handed to a provider, one at a time
|
||||
QStringList plugins; // installed on the spot
|
||||
QStringList installedPackages; // already on the machine: refused
|
||||
QStringList installedPlugins;
|
||||
QStringList rejected;
|
||||
|
||||
for (const QString& path : paths) {
|
||||
// A file whose application is already there is refused before anything
|
||||
// runs: flatpak would skip it and report a success the user did not
|
||||
// get, and re-installing a plugin package would silently replace the
|
||||
// one in place.
|
||||
const AppCore::FileTarget target = m_core->fileTarget(path);
|
||||
if (target.installed) {
|
||||
(target.plugin ? installedPlugins : installedPackages) << target.name;
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("fichier"),
|
||||
tr("%1 : déjà installé, rien à faire").arg(target.name));
|
||||
continue;
|
||||
}
|
||||
|
||||
// A plugin package is installed by the core straight away: it needs no
|
||||
// provider, no password and no queue, and the registry is reloaded when
|
||||
// it lands (see AppCore::installPluginPackage).
|
||||
if (m_core->isPluginPackage(path)) {
|
||||
m_core->installPluginPackage(path);
|
||||
// Only announced when its manifest could be read: a package the
|
||||
// reader refuses installs nothing and is reported by the Plugins
|
||||
// screen, and the window must not promise an install that is not
|
||||
// happening.
|
||||
if (!target.name.isEmpty()) plugins << path;
|
||||
continue;
|
||||
}
|
||||
if (m_core->canInstallFile(path)) files << path;
|
||||
@@ -1076,6 +1116,11 @@ void MainWindow::installLocalFiles(const QStringList& paths) {
|
||||
.arg(QFileInfo(rejected.first()).fileName()));
|
||||
}
|
||||
|
||||
// Nothing else in the window would tell the user their gesture landed: a
|
||||
// drop starts a background install, or a plugin goes in without a sound.
|
||||
announceAcceptedFiles(files, plugins);
|
||||
announceInstalledFiles(installedPackages, installedPlugins);
|
||||
|
||||
if (files.isEmpty()) return;
|
||||
|
||||
LogManager::instance().logEvent(
|
||||
@@ -1085,6 +1130,61 @@ void MainWindow::installLocalFiles(const QStringList& paths) {
|
||||
if (!m_fileInstallRunning) startNextFileInstall();
|
||||
}
|
||||
|
||||
// What the window says about the files it just took. Without it, a drop that
|
||||
// starts a background install — or a plugin that lands silently — reads as a
|
||||
// gesture the application ignored.
|
||||
void MainWindow::announceAcceptedFiles(const QStringList& installing,
|
||||
const QStringList& plugins) {
|
||||
if (installing.isEmpty() && plugins.isEmpty()) return;
|
||||
|
||||
QStringList lines;
|
||||
for (const QString& path : installing) {
|
||||
lines << tr("<b>%1</b> pris en compte : l'installation démarre, sa "
|
||||
"progression s'affiche en bas de la fenêtre.")
|
||||
.arg(QFileInfo(path).fileName());
|
||||
}
|
||||
for (const QString& path : plugins) {
|
||||
lines << tr("<b>%1</b> pris en compte : le plugin est installé et "
|
||||
"utilisable sans redémarrer.")
|
||||
.arg(QFileInfo(path).fileName());
|
||||
}
|
||||
|
||||
QMessageBox box(this);
|
||||
box.setWindowTitle(tr("Fichiers pris en compte"));
|
||||
box.setIcon(QMessageBox::Information);
|
||||
box.setTextFormat(Qt::RichText);
|
||||
box.setText(lines.join(QStringLiteral("<br>")));
|
||||
box.setStandardButtons(QMessageBox::Ok);
|
||||
box.exec();
|
||||
}
|
||||
|
||||
// The other half of the answer: a file the machine already has is refused, and
|
||||
// the user is told which one it is and what to do instead.
|
||||
void MainWindow::announceInstalledFiles(const QStringList& packages,
|
||||
const QStringList& plugins) {
|
||||
if (packages.isEmpty() && plugins.isEmpty()) return;
|
||||
|
||||
QStringList lines;
|
||||
for (const QString& name : packages) {
|
||||
lines << tr("<b>%1</b> est déjà installé : il n'y a rien à installer. "
|
||||
"Sa mise à jour se fait depuis l'écran des mises à jour.")
|
||||
.arg(name);
|
||||
}
|
||||
for (const QString& name : plugins) {
|
||||
lines << tr("<b>%1</b> : ce plugin est déjà installé. Supprimez-le "
|
||||
"depuis l'écran Extensions pour en installer un autre.")
|
||||
.arg(name);
|
||||
}
|
||||
|
||||
QMessageBox box(this);
|
||||
box.setWindowTitle(tr("Déjà installé"));
|
||||
box.setIcon(QMessageBox::Information);
|
||||
box.setTextFormat(Qt::RichText);
|
||||
box.setText(lines.join(QStringLiteral("<br>")));
|
||||
box.setStandardButtons(QMessageBox::Ok);
|
||||
box.exec();
|
||||
}
|
||||
|
||||
void MainWindow::startNextFileInstall() {
|
||||
if (m_pendingFileInstalls.isEmpty()) {
|
||||
m_fileInstallRunning = false;
|
||||
@@ -1642,12 +1742,25 @@ void MainWindow::onCoreUpdateCheckFinished(bool hasUpdate, const QString& latest
|
||||
}
|
||||
|
||||
// Called when the background git pull + build finishes. A success hands over to
|
||||
// the freshly installed binary right away; a failure is reported in a dialog.
|
||||
// the freshly installed binary right away; a failure is reported in a dialog and
|
||||
// kept whole in the journal.
|
||||
void MainWindow::onCoreSelfUpdateFinished(bool success, const QString& message) {
|
||||
if (!success) {
|
||||
// A failing build prints far more than a dialog can hold, and the part
|
||||
// that gets cut is precisely the error line. The journal keeps the whole
|
||||
// output as a command block, so the Logs screen shows it and the file can
|
||||
// be sent as it is — without it, a failed update leaves no trace at all
|
||||
// (the outcome is not a provider command, so nothing else records it).
|
||||
LogManager& journal = LogManager::instance();
|
||||
journal.beginCommand(QStringLiteral("maj-app"),
|
||||
QStringLiteral("mise à jour de l'application"));
|
||||
journal.endCommand(false, message);
|
||||
qCWarning(pacmgrUpdate) << "self-update failed, output in" << journal.filePath();
|
||||
|
||||
QMessageBox::warning(this, tr("Échec de la mise à jour"),
|
||||
QString(tr("<p>La mise à jour a échoué :</p><pre>%1</pre>"))
|
||||
.arg(message.toHtmlEscaped()));
|
||||
QString(tr("<p>La mise à jour a échoué :</p><pre>%1</pre>"
|
||||
"<p>Le journal complet est dans <code>%2</code>.</p>"))
|
||||
.arg(message.toHtmlEscaped(), journal.filePath().toHtmlEscaped()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -58,7 +58,9 @@ public:
|
||||
// Installs the Flatpak files handed over by the desktop: dropped on the
|
||||
// window, or opened from the file manager ("Ouvrir avec PacManager", which
|
||||
// passes them on the command line). One install runs at a time; the rest
|
||||
// wait in line. Paths the core does not recognise are reported and skipped.
|
||||
// wait in line. Paths the core does not recognise are reported and skipped,
|
||||
// a file the machine already has is refused, and both answers are told to
|
||||
// the user in a dialog — the gesture is the only thing they see.
|
||||
void installLocalFiles(const QStringList& paths);
|
||||
|
||||
protected:
|
||||
@@ -174,6 +176,12 @@ private:
|
||||
// Takes the next queued file and asks the core to install it. A core busy
|
||||
// with another operation leaves it queued: onCoreActionFinished calls back.
|
||||
void startNextFileInstall();
|
||||
// What the user is told about the files just handed over: which ones were
|
||||
// taken (and what each of them starts), and which ones were refused because
|
||||
// the machine already has them. Two dialogs, since the two answers ask for
|
||||
// different things from the user.
|
||||
void announceAcceptedFiles(const QStringList& installing, const QStringList& plugins);
|
||||
void announceInstalledFiles(const QStringList& packages, const QStringList& plugins);
|
||||
|
||||
// Logic layer: it owns the providers, the workers, the history, the
|
||||
// credentials and the self-updater. The frame never talks to them directly.
|
||||
@@ -242,4 +250,5 @@ private:
|
||||
// Menu
|
||||
QAction* m_credLaunchAction = nullptr;
|
||||
QAction* m_credEachTimeAction = nullptr;
|
||||
QAction* m_startupCheckAction = nullptr;
|
||||
};
|
||||
+62
-4
@@ -1,15 +1,74 @@
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
#include <QLoggingCategory>
|
||||
#include <QStringList>
|
||||
#include <QTimer>
|
||||
|
||||
#include "app-settings.h"
|
||||
#include "cli-application.h"
|
||||
#include "cli-command.h"
|
||||
#include "language-manager.h"
|
||||
#include "log-manager.h"
|
||||
#include "main-window.h"
|
||||
#include "startup-check.h"
|
||||
#include "update-manager.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// The arguments as the command-line grammar wants them: program name excluded.
|
||||
QStringList commandLineArguments(int argc, char* argv[]) {
|
||||
QStringList arguments;
|
||||
if (argc > 1) arguments.reserve(argc - 1);
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
arguments << QString::fromLocal8Bit(argv[i]);
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
const QStringList arguments = commandLineArguments(argc, argv);
|
||||
|
||||
// The login check runs headless, from the systemd user unit the app installs
|
||||
// itself (Paramètres → « Vérifier les mises à jour au démarrage »). It is
|
||||
// detected before any QApplication: that unit has no display, and building a
|
||||
// GUI application there would abort on the platform plugin. It also comes
|
||||
// before the command line, which would otherwise read the option as an
|
||||
// unknown command.
|
||||
if (arguments.contains(QStringLiteral("--check-updates"))) {
|
||||
QCoreApplication app(argc, argv);
|
||||
app.setApplicationName("PacManager");
|
||||
app.setApplicationVersion(UpdateManager::currentVersion());
|
||||
app.setOrganizationName("Freebuff");
|
||||
QLoggingCategory::setFilterRules(QStringLiteral("pacmgr.*=true"));
|
||||
LogManager::installQtMessageHandler();
|
||||
return StartupCheck().run();
|
||||
}
|
||||
|
||||
// The command line is decided before any widget exists: `pacmanager install
|
||||
// vlc` has to work on a machine with no display, so it runs on a
|
||||
// QCoreApplication and never builds the window.
|
||||
if (cli::isCliInvocation(arguments)) {
|
||||
QCoreApplication app(argc, argv);
|
||||
app.setApplicationName("PacManager");
|
||||
app.setApplicationVersion(UpdateManager::currentVersion());
|
||||
app.setOrganizationName("Freebuff");
|
||||
|
||||
LogManager::installQtMessageHandler();
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("app"),
|
||||
QCoreApplication::translate("main", "session démarrée (v%1)")
|
||||
.arg(UpdateManager::currentVersion()));
|
||||
|
||||
const int code = cli::run(arguments);
|
||||
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("app"),
|
||||
QCoreApplication::translate("main", "session terminée (code %1)").arg(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("PacManager");
|
||||
app.setApplicationVersion(UpdateManager::currentVersion());
|
||||
@@ -44,10 +103,9 @@ int main(int argc, char* argv[]) {
|
||||
// Files the desktop handed over ("Ouvrir avec PacManager", the desktop
|
||||
// entry declares %U): installed once the event loop runs, so the window is
|
||||
// visible and any dialog has a parent.
|
||||
const QStringList fileArgs = app.arguments().mid(1);
|
||||
if (!fileArgs.isEmpty()) {
|
||||
QTimer::singleShot(0, &window, [&window, fileArgs] {
|
||||
window.installLocalFiles(fileArgs);
|
||||
if (!arguments.isEmpty()) {
|
||||
QTimer::singleShot(0, &window, [&window, arguments] {
|
||||
window.installLocalFiles(arguments);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,450 @@
|
||||
#include "cli-application.h"
|
||||
|
||||
#include "app-core.h"
|
||||
#include "cli-command.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QEventLoop>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace {
|
||||
|
||||
// ---- Output -----------------------------------------------------------------
|
||||
// stdio rather than QTextStream: the command line is meant to be piped, and a
|
||||
// byte-per-byte fputs keeps the exit status and the stdout/stderr split exactly
|
||||
// what a shell script expects.
|
||||
void printLine(const QString& text) {
|
||||
std::fputs(text.toUtf8().constData(), stdout);
|
||||
std::fputc('\n', stdout);
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
||||
void printErr(const QString& text) {
|
||||
std::fputs(text.toUtf8().constData(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
std::fflush(stderr);
|
||||
}
|
||||
|
||||
QString providerName(const PackageInfo& package) {
|
||||
if (!package.provider.empty()) return QString::fromStdString(package.provider);
|
||||
if (!package.providers.empty()) return QString::fromStdString(package.providers.front());
|
||||
return QStringLiteral("?");
|
||||
}
|
||||
|
||||
// ---- Terminal interaction ---------------------------------------------------
|
||||
// The password is read with echo off, the way sudo does, and never leaves the
|
||||
// process: it goes straight to the core and is dropped after the operation.
|
||||
QString readPassword(const QString& prompt) {
|
||||
std::fputs(prompt.toUtf8().constData(), stderr);
|
||||
std::fflush(stderr);
|
||||
|
||||
const bool interactive = isatty(STDIN_FILENO) == 1;
|
||||
termios saved{};
|
||||
const bool restore = interactive && tcgetattr(STDIN_FILENO, &saved) == 0;
|
||||
if (restore) {
|
||||
termios hidden = saved;
|
||||
hidden.c_lflag &= ~static_cast<tcflag_t>(ECHO);
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &hidden);
|
||||
}
|
||||
|
||||
std::string line;
|
||||
char buffer[256];
|
||||
if (std::fgets(buffer, sizeof(buffer), stdin)) line = buffer;
|
||||
|
||||
if (restore) {
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &saved);
|
||||
std::fputc('\n', stderr);
|
||||
}
|
||||
|
||||
QString password = QString::fromUtf8(line.c_str());
|
||||
password.remove(QLatin1Char('\n'));
|
||||
password.remove(QLatin1Char('\r'));
|
||||
return password;
|
||||
}
|
||||
|
||||
// A confirmation is only asked on a terminal: a pipe that did not pass --yes is
|
||||
// refused rather than left waiting forever on stdin.
|
||||
bool confirm(const QString& question, bool assumeYes) {
|
||||
if (assumeYes) return true;
|
||||
if (isatty(STDIN_FILENO) != 1) {
|
||||
printErr(QStringLiteral("%1 — refusé : confirmez avec --yes dans un script.")
|
||||
.arg(question));
|
||||
return false;
|
||||
}
|
||||
|
||||
std::fputs((question + QStringLiteral(" [o/N] ")).toUtf8().constData(), stderr);
|
||||
std::fflush(stderr);
|
||||
|
||||
char buffer[64];
|
||||
if (!std::fgets(buffer, sizeof(buffer), stdin)) return false;
|
||||
const QString answer = QString::fromUtf8(buffer).trimmed().toLower();
|
||||
return answer == QLatin1String("o") || answer == QLatin1String("oui")
|
||||
|| answer == QLatin1String("y") || answer == QLatin1String("yes");
|
||||
}
|
||||
|
||||
// ---- Tables -----------------------------------------------------------------
|
||||
void printPackages(const std::vector<PackageInfo>& packages, bool withRepository) {
|
||||
if (packages.empty()) {
|
||||
printLine(QStringLiteral("Aucun paquet."));
|
||||
return;
|
||||
}
|
||||
|
||||
// Seeded with the header labels so the columns line up even when every
|
||||
// value is shorter than its heading.
|
||||
int nameWidth = static_cast<int>(QStringLiteral("NOM").size());
|
||||
int versionWidth = static_cast<int>(QStringLiteral("VERSION").size());
|
||||
int providerWidth = static_cast<int>(QStringLiteral("FOURNISSEUR").size());
|
||||
int repoWidth = static_cast<int>(QStringLiteral("DÉPÔT").size());
|
||||
for (const PackageInfo& package : packages) {
|
||||
nameWidth = std::max(nameWidth, static_cast<int>(package.name.size()));
|
||||
versionWidth = std::max(versionWidth, static_cast<int>(package.version.size()));
|
||||
providerWidth = std::max(providerWidth, static_cast<int>(providerName(package).size()));
|
||||
repoWidth = std::max(repoWidth, static_cast<int>(package.repository.size()));
|
||||
}
|
||||
|
||||
auto row = [&](const QString& name, const QString& version, const QString& provider,
|
||||
const QString& repository, const QString& state) {
|
||||
QString line = name.leftJustified(nameWidth)
|
||||
+ QLatin1String(" ") + version.leftJustified(versionWidth)
|
||||
+ QLatin1String(" ") + provider.leftJustified(providerWidth);
|
||||
if (withRepository) {
|
||||
line += QLatin1String(" ") + repository.leftJustified(repoWidth);
|
||||
}
|
||||
if (!state.isEmpty()) line += QLatin1String(" ") + state;
|
||||
return line;
|
||||
};
|
||||
|
||||
printLine(row(QStringLiteral("NOM"), QStringLiteral("VERSION"),
|
||||
QStringLiteral("FOURNISSEUR"),
|
||||
withRepository ? QStringLiteral("DÉPÔT") : QString(),
|
||||
QStringLiteral("ÉTAT")));
|
||||
for (const PackageInfo& package : packages) {
|
||||
// A cleanup row carries its reason; a regular one its installed/outdated
|
||||
// state, so the same table serves every listing.
|
||||
QString state;
|
||||
if (!package.cleanupReason.empty()) {
|
||||
state = QString::fromStdString(package.cleanupReason);
|
||||
} else if (package.updateAvailable) {
|
||||
state = QStringLiteral("mise à jour dispo");
|
||||
} else if (package.installed) {
|
||||
state = QStringLiteral("installé");
|
||||
}
|
||||
printLine(row(QString::fromStdString(package.name),
|
||||
QString::fromStdString(package.version), providerName(package),
|
||||
QString::fromStdString(package.repository), state));
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Waiting for the asynchronous core --------------------------------------
|
||||
// AppCore reports through signals on the event loop; the command line waits for
|
||||
// the one it asked for. The loop is the connection's context, so every
|
||||
// connection is dropped as soon as the wait is over.
|
||||
bool collectSearch(AppCore& core, const QString& query, std::vector<PackageInfo>* results,
|
||||
QString* error) {
|
||||
QEventLoop loop;
|
||||
QObject::connect(&core, &AppCore::searchFinished, &loop,
|
||||
[&](std::vector<PackageInfo> found) {
|
||||
*results = std::move(found);
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
const AppCore::StartResult started = core.search(query);
|
||||
if (!started.started) {
|
||||
if (error) *error = started.error;
|
||||
return false;
|
||||
}
|
||||
loop.exec();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Turns a name typed on the command line into the package the core can act on:
|
||||
// a search, then the exact match. The provider is the one that search tagged,
|
||||
// so `install` routes to pacman or Flatpak without the user naming either.
|
||||
bool resolvePackage(AppCore& core, const QString& name, PackageInfo* package, QString* error) {
|
||||
std::vector<PackageInfo> results;
|
||||
if (!collectSearch(core, name.trimmed(), &results, error)) return false;
|
||||
|
||||
const QString wanted = name.trimmed().toLower();
|
||||
for (const PackageInfo& candidate : results) {
|
||||
if (QString::fromStdString(candidate.name).toLower() == wanted) {
|
||||
*package = candidate;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
*error = QStringLiteral("Paquet introuvable : %1").arg(name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
struct Outcome {
|
||||
bool success = false;
|
||||
bool locked = false;
|
||||
QString error;
|
||||
};
|
||||
|
||||
// Starts an action, answers the sudo prompt when the core asks for one, and
|
||||
// waits for the verdict. Progress lines are forwarded so a long install reads
|
||||
// like a terminal session — the same output the journal keeps.
|
||||
Outcome runAction(AppCore& core, const QString& label,
|
||||
const std::function<AppCore::StartResult()>& start) {
|
||||
Outcome outcome;
|
||||
|
||||
QEventLoop loop;
|
||||
QObject::connect(&core, &AppCore::actionProgress, &loop,
|
||||
[](const QString& message, int percent) {
|
||||
Q_UNUSED(percent);
|
||||
if (!message.isEmpty()) printLine(QStringLiteral(" %1").arg(message));
|
||||
});
|
||||
QObject::connect(&core, &AppCore::actionFinished, &loop,
|
||||
[&](const QString&, const QString&, bool success,
|
||||
const QString& error, bool locked) {
|
||||
outcome.success = success;
|
||||
outcome.error = error;
|
||||
outcome.locked = locked;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
AppCore::StartResult started = start();
|
||||
if (!started.started && started.needsPassword) {
|
||||
const QString password =
|
||||
readPassword(QStringLiteral("Mot de passe sudo pour %1 : ").arg(label));
|
||||
if (password.isEmpty()) {
|
||||
outcome.error = QStringLiteral("Opération annulée : identifiants requis.");
|
||||
return outcome;
|
||||
}
|
||||
core.setSudoPassword(password);
|
||||
started = core.retryPendingRequest();
|
||||
}
|
||||
if (!started.started) {
|
||||
// Refused before running: the reason is the one the window would show.
|
||||
outcome.error = started.error;
|
||||
outcome.locked = started.locked;
|
||||
return outcome;
|
||||
}
|
||||
|
||||
loop.exec();
|
||||
return outcome;
|
||||
}
|
||||
|
||||
int reportAction(const Outcome& outcome, const QString& successText) {
|
||||
if (outcome.success) {
|
||||
printLine(successText);
|
||||
return 0;
|
||||
}
|
||||
if (outcome.locked) {
|
||||
printErr(QStringLiteral("Base pacman verrouillée : %1").arg(outcome.error));
|
||||
} else if (!outcome.error.isEmpty()) {
|
||||
printErr(outcome.error);
|
||||
} else {
|
||||
printErr(QStringLiteral("L'opération a échoué."));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ---- Commands ---------------------------------------------------------------
|
||||
int runSearch(AppCore& core, const cli::Parsed& parsed) {
|
||||
std::vector<PackageInfo> results;
|
||||
QString error;
|
||||
if (!collectSearch(core, parsed.operands.join(QLatin1Char(' ')), &results, &error)) {
|
||||
printErr(error);
|
||||
return 1;
|
||||
}
|
||||
printPackages(results, /*withRepository=*/true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int runInstall(AppCore& core, const cli::Parsed& parsed) {
|
||||
for (const QString& name : parsed.operands) {
|
||||
PackageInfo package;
|
||||
QString error;
|
||||
if (!resolvePackage(core, name, &package, &error)) {
|
||||
printErr(error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printLine(QStringLiteral("Installation de %1 via %2...")
|
||||
.arg(name, providerName(package)));
|
||||
const Outcome outcome = runAction(core, name, [&core, &package] {
|
||||
return core.install(package);
|
||||
});
|
||||
if (reportAction(outcome, QStringLiteral("%1 installé.").arg(name)) != 0) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int runRemove(AppCore& core, const cli::Parsed& parsed) {
|
||||
for (const QString& name : parsed.operands) {
|
||||
PackageInfo package;
|
||||
QString error;
|
||||
if (!resolvePackage(core, name, &package, &error)) {
|
||||
printErr(error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!confirm(QStringLiteral("Supprimer %1 (%2) ?").arg(name, providerName(package)),
|
||||
parsed.assumeYes)) {
|
||||
printLine(QStringLiteral("Suppression annulée."));
|
||||
continue;
|
||||
}
|
||||
|
||||
printLine(QStringLiteral("Suppression de %1...").arg(name));
|
||||
const Outcome outcome = runAction(core, name, [&core, &package] {
|
||||
return core.remove(package);
|
||||
});
|
||||
if (reportAction(outcome, QStringLiteral("%1 supprimé.").arg(name)) != 0) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int runUpdate(AppCore& core, const cli::Parsed& parsed) {
|
||||
// With no operand, everything is updated — the one shape that can take
|
||||
// minutes, so it is confirmed first.
|
||||
if (parsed.operands.isEmpty()) {
|
||||
if (!confirm(QStringLiteral("Mettre à jour tous les paquets ?"), parsed.assumeYes)) {
|
||||
printLine(QStringLiteral("Mise à jour annulée."));
|
||||
return 0;
|
||||
}
|
||||
printLine(QStringLiteral("Mise à jour de tous les paquets..."));
|
||||
const Outcome outcome = runAction(core, QStringLiteral("tous les paquets"),
|
||||
[&core] { return core.updateAll(); });
|
||||
return reportAction(outcome, QStringLiteral("Tous les paquets sont à jour."));
|
||||
}
|
||||
|
||||
const QString name = parsed.operands.first();
|
||||
PackageInfo package;
|
||||
QString error;
|
||||
if (!resolvePackage(core, name, &package, &error)) {
|
||||
printErr(error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printLine(QStringLiteral("Mise à jour de %1 via %2...").arg(name, providerName(package)));
|
||||
const Outcome outcome = runAction(core, name, [&core, &package] {
|
||||
return core.update(package);
|
||||
});
|
||||
return reportAction(outcome, QStringLiteral("Mise à jour terminée."));
|
||||
}
|
||||
|
||||
int runList(AppCore& core, AppCore::ListMode mode, bool withRepository) {
|
||||
QEventLoop loop;
|
||||
std::vector<PackageInfo> results;
|
||||
QObject::connect(&core, &AppCore::listFinished, &loop,
|
||||
[&](AppCore::ListMode finished, std::vector<PackageInfo> found) {
|
||||
if (finished != mode) return;
|
||||
results = std::move(found);
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
const AppCore::StartResult started =
|
||||
mode == AppCore::ListMode::Installed ? core.loadInstalled()
|
||||
: mode == AppCore::ListMode::Updates ? core.loadUpdates()
|
||||
: core.loadCleanup();
|
||||
if (!started.started) {
|
||||
printErr(started.error);
|
||||
return 1;
|
||||
}
|
||||
loop.exec();
|
||||
|
||||
printPackages(results, withRepository);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int runInfo(AppCore& core, const cli::Parsed& parsed) {
|
||||
const QString name = parsed.operands.first();
|
||||
PackageInfo package;
|
||||
QString error;
|
||||
if (!resolvePackage(core, name, &package, &error)) {
|
||||
printErr(error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printLine(QStringLiteral("%1 — %2").arg(QString::fromStdString(package.name),
|
||||
QString::fromStdString(package.version)));
|
||||
printLine(QStringLiteral("Fournisseur : %1").arg(providerName(package)));
|
||||
if (!package.repository.empty()) {
|
||||
printLine(QStringLiteral("Dépôt : %1").arg(QString::fromStdString(package.repository)));
|
||||
}
|
||||
printLine(package.installed ? QStringLiteral("État : installé")
|
||||
: QStringLiteral("État : non installé"));
|
||||
if (!package.description.empty()) {
|
||||
printLine(QString::fromStdString(package.description));
|
||||
}
|
||||
|
||||
// The extra block comes from pacman (-Qi / -Si) and is empty for providers
|
||||
// that do not expose it; the summary above is then all there is to show.
|
||||
const QString details = core.packageDetails(package);
|
||||
if (!details.isEmpty()) {
|
||||
printLine(QString());
|
||||
printLine(details);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int runRefresh(AppCore& core) {
|
||||
printLine(QStringLiteral("Rafraîchissement des bases de données..."));
|
||||
const Outcome outcome = runAction(core, QStringLiteral("sources"),
|
||||
[&core] { return core.refresh(); });
|
||||
return reportAction(outcome, QStringLiteral("Sources rafraîchies."));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace cli {
|
||||
|
||||
int run(const QStringList& args) {
|
||||
const Parsed parsed = parse(args);
|
||||
|
||||
switch (parsed.command) {
|
||||
case Command::None:
|
||||
// Nothing to do: the caller only routes here when a command exists.
|
||||
return 0;
|
||||
case Command::Help:
|
||||
printLine(helpText());
|
||||
return 0;
|
||||
case Command::Version:
|
||||
printLine(QStringLiteral("PacManager %1")
|
||||
.arg(QCoreApplication::applicationVersion()));
|
||||
return 0;
|
||||
case Command::Unknown:
|
||||
printErr(parsed.error);
|
||||
printErr(QStringLiteral("Essayez « pacmanager --help »."));
|
||||
return 2;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
AppCore core;
|
||||
if (!core.hasAvailableProvider()) {
|
||||
printErr(QStringLiteral("Aucun gestionnaire de paquets disponible sur ce système."));
|
||||
return 1;
|
||||
}
|
||||
|
||||
switch (parsed.command) {
|
||||
case Command::Search: return runSearch(core, parsed);
|
||||
case Command::Install: return runInstall(core, parsed);
|
||||
case Command::Remove: return runRemove(core, parsed);
|
||||
case Command::Update: return runUpdate(core, parsed);
|
||||
case Command::List:
|
||||
return runList(core, AppCore::ListMode::Installed, /*withRepository=*/true);
|
||||
case Command::Updates:
|
||||
return runList(core, AppCore::ListMode::Updates, /*withRepository=*/false);
|
||||
case Command::Cleanup:
|
||||
return runList(core, AppCore::ListMode::Cleanup, /*withRepository=*/false);
|
||||
case Command::Info: return runInfo(core, parsed);
|
||||
case Command::Refresh: return runRefresh(core);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
// Runs a parsed command line against the logic layer (AppCore) and prints the
|
||||
// result. No widget is built: the command line works on a machine without a
|
||||
// display, and the operations are exactly the ones the window runs.
|
||||
namespace cli {
|
||||
|
||||
// `args` is the command line, program name excluded. Returns the process exit
|
||||
// code: 0 on success, 1 when an operation failed, 2 on a usage error.
|
||||
int run(const QStringList& args);
|
||||
|
||||
} // namespace cli
|
||||
@@ -0,0 +1,212 @@
|
||||
#include "cli-command.h"
|
||||
|
||||
#include <QHash>
|
||||
|
||||
namespace {
|
||||
|
||||
// Every keyword a command answers to, French first. Kept in one table so the
|
||||
// help text and the parser cannot drift apart.
|
||||
const QHash<QString, cli::Command>& keywords() {
|
||||
static const QHash<QString, cli::Command> table = {
|
||||
{QStringLiteral("recherche"), cli::Command::Search},
|
||||
{QStringLiteral("search"), cli::Command::Search},
|
||||
{QStringLiteral("cherche"), cli::Command::Search},
|
||||
|
||||
{QStringLiteral("install"), cli::Command::Install},
|
||||
{QStringLiteral("installer"), cli::Command::Install},
|
||||
|
||||
{QStringLiteral("supprimer"), cli::Command::Remove},
|
||||
{QStringLiteral("remove"), cli::Command::Remove},
|
||||
{QStringLiteral("uninstall"), cli::Command::Remove},
|
||||
{QStringLiteral("désinstaller"), cli::Command::Remove},
|
||||
{QStringLiteral("desinstaller"), cli::Command::Remove},
|
||||
|
||||
{QStringLiteral("maj"), cli::Command::Update},
|
||||
{QStringLiteral("update"), cli::Command::Update},
|
||||
{QStringLiteral("upgrade"), cli::Command::Update},
|
||||
|
||||
{QStringLiteral("liste"), cli::Command::List},
|
||||
{QStringLiteral("list"), cli::Command::List},
|
||||
|
||||
{QStringLiteral("maj-dispo"), cli::Command::Updates},
|
||||
{QStringLiteral("updates"), cli::Command::Updates},
|
||||
|
||||
{QStringLiteral("info"), cli::Command::Info},
|
||||
{QStringLiteral("détails"), cli::Command::Info},
|
||||
{QStringLiteral("details"), cli::Command::Info},
|
||||
|
||||
{QStringLiteral("refresh"), cli::Command::Refresh},
|
||||
{QStringLiteral("rafraîchir"), cli::Command::Refresh},
|
||||
{QStringLiteral("rafraichir"), cli::Command::Refresh},
|
||||
{QStringLiteral("sync"), cli::Command::Refresh},
|
||||
|
||||
{QStringLiteral("nettoyage"), cli::Command::Cleanup},
|
||||
{QStringLiteral("cleanup"), cli::Command::Cleanup},
|
||||
|
||||
{QStringLiteral("aide"), cli::Command::Help},
|
||||
{QStringLiteral("help"), cli::Command::Help},
|
||||
|
||||
{QStringLiteral("version"), cli::Command::Version},
|
||||
};
|
||||
return table;
|
||||
}
|
||||
|
||||
bool isYesFlag(const QString& token) {
|
||||
return token == QLatin1String("--yes") || token == QLatin1String("-y");
|
||||
}
|
||||
|
||||
bool isHelpFlag(const QString& token) {
|
||||
return token == QLatin1String("--help") || token == QLatin1String("-h")
|
||||
|| token == QLatin1String("-?");
|
||||
}
|
||||
|
||||
bool isVersionFlag(const QString& token) {
|
||||
return token == QLatin1String("--version") || token == QLatin1String("-V")
|
||||
|| token == QLatin1String("-v");
|
||||
}
|
||||
|
||||
cli::Command commandFor(const QString& token) {
|
||||
const auto it = keywords().constFind(token.toLower());
|
||||
return it == keywords().constEnd() ? cli::Command::Unknown : it.value();
|
||||
}
|
||||
|
||||
cli::Parsed refuse(const QString& error) {
|
||||
cli::Parsed parsed;
|
||||
parsed.command = cli::Command::Unknown;
|
||||
parsed.error = error;
|
||||
return parsed;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace cli {
|
||||
|
||||
bool isCliInvocation(const QStringList& args) {
|
||||
if (args.isEmpty()) return false;
|
||||
|
||||
const QString first = args.first();
|
||||
// Any leading option, or a known keyword, is aimed at the command line.
|
||||
if (first.startsWith(QLatin1Char('-')) || commandFor(first) != Command::Unknown) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// A path, or a file with one of the extensions the window knows how to
|
||||
// install, is what the desktop hands over ("Ouvrir avec PacManager", the
|
||||
// desktop entry declares %U): the window is wanted for those.
|
||||
const QString lower = first.toLower();
|
||||
const bool looksLikePath = first.contains(QLatin1Char('/'))
|
||||
|| first.startsWith(QLatin1Char('~'));
|
||||
const bool looksLikeFile = lower.endsWith(QLatin1String(".flatpak"))
|
||||
|| lower.endsWith(QLatin1String(".flatpakref"))
|
||||
|| lower.endsWith(QLatin1String(".flatpakrepo"))
|
||||
|| lower.endsWith(QLatin1String(".fwspacm"));
|
||||
if (looksLikePath || looksLikeFile) return false;
|
||||
|
||||
// A bare word that is not a command is a mistyped command: the command line
|
||||
// says so, which is friendlier than opening a window that can do nothing
|
||||
// with it.
|
||||
return true;
|
||||
}
|
||||
|
||||
Parsed parse(const QStringList& args) {
|
||||
Parsed parsed;
|
||||
if (args.isEmpty()) return parsed; // Command::None: the window
|
||||
|
||||
// --help/--version win wherever they stand, like every command line.
|
||||
for (const QString& token : args) {
|
||||
if (isHelpFlag(token)) {
|
||||
parsed.command = Command::Help;
|
||||
return parsed;
|
||||
}
|
||||
if (isVersionFlag(token)) {
|
||||
parsed.command = Command::Version;
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
|
||||
QStringList tokens;
|
||||
for (const QString& token : args) {
|
||||
// -y is a modifier, not an operand: it is read wherever it appears.
|
||||
if (isYesFlag(token)) {
|
||||
parsed.assumeYes = true;
|
||||
continue;
|
||||
}
|
||||
tokens << token;
|
||||
}
|
||||
|
||||
const QString first = tokens.takeFirst();
|
||||
parsed.command = commandFor(first);
|
||||
if (parsed.command == Command::Unknown) {
|
||||
if (first.startsWith(QLatin1Char('-'))) {
|
||||
return refuse(QStringLiteral("Option inconnue : %1").arg(first));
|
||||
}
|
||||
return refuse(QStringLiteral("Commande inconnue : %1").arg(first));
|
||||
}
|
||||
|
||||
parsed.operands = tokens;
|
||||
|
||||
// What each command needs to be runnable, checked here so the runner never
|
||||
// has to guess what a missing operand means.
|
||||
const int count = tokens.size();
|
||||
switch (parsed.command) {
|
||||
case Command::Search:
|
||||
case Command::Install:
|
||||
case Command::Remove:
|
||||
if (count == 0) {
|
||||
return refuse(
|
||||
QStringLiteral("« %1 » attend au moins un nom de paquet.").arg(first));
|
||||
}
|
||||
break;
|
||||
case Command::Info:
|
||||
if (count != 1) {
|
||||
return refuse(QStringLiteral("« %1 » attend un nom de paquet.").arg(first));
|
||||
}
|
||||
break;
|
||||
case Command::Update:
|
||||
if (count > 1) {
|
||||
return refuse(QStringLiteral(
|
||||
"« %1 » ne met à jour qu'un paquet à la fois (ou tous sans nom).")
|
||||
.arg(first));
|
||||
}
|
||||
break;
|
||||
case Command::List:
|
||||
case Command::Updates:
|
||||
case Command::Refresh:
|
||||
case Command::Cleanup:
|
||||
case Command::Help:
|
||||
case Command::Version:
|
||||
if (count != 0) {
|
||||
return refuse(QStringLiteral("« %1 » n'accepte pas d'argument.").arg(first));
|
||||
}
|
||||
break;
|
||||
case Command::None:
|
||||
case Command::Unknown:
|
||||
break;
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
QString helpText() {
|
||||
return QStringLiteral(
|
||||
"PacManager — gestionnaire de paquets en ligne de commande\n"
|
||||
"\n"
|
||||
"Usage : pacmanager <commande> [paquet...] [--yes]\n"
|
||||
"\n"
|
||||
"Commandes :\n"
|
||||
" recherche <terme> chercher des paquets\n"
|
||||
" install <paquet...> installer un ou plusieurs paquets\n"
|
||||
" supprimer <paquet...> supprimer un ou plusieurs paquets\n"
|
||||
" maj [paquet] mettre à jour un paquet, ou tout sans nom\n"
|
||||
" liste lister les paquets installés\n"
|
||||
" maj-dispo lister les mises à jour disponibles\n"
|
||||
" info <paquet> détails d'un paquet\n"
|
||||
" refresh rafraîchir les bases de données\n"
|
||||
" nettoyage lister les paquets inutilisés et legacy\n"
|
||||
" aide | version cette aide, ou la version installée\n"
|
||||
"\n"
|
||||
"Alias anglais : search, remove, update, list, updates, details, cleanup, help.\n"
|
||||
" -y, --yes ne pas demander confirmation (suppression, maj globale)");
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
// Command-line front-end: what `pacmanager <commande>` asks for, parsed apart
|
||||
// from everything that runs it so the grammar can be unit-tested without a
|
||||
// package manager, a display or a single process spawned.
|
||||
//
|
||||
// The wording is the one of the issue that asked for it: a simplified pacman,
|
||||
// `pacmanager recherche vlc` then `pacmanager install vlc`. French is the
|
||||
// language the rest of the interface is written in, so its keywords come first;
|
||||
// the English ones are accepted as aliases because the second half of that same
|
||||
// sentence is English.
|
||||
namespace cli {
|
||||
|
||||
enum class Command {
|
||||
// No argument at all: the window is wanted.
|
||||
None,
|
||||
Search,
|
||||
Install,
|
||||
Remove,
|
||||
// No operand updates everything; one operand updates that package.
|
||||
Update,
|
||||
List,
|
||||
Updates,
|
||||
Info,
|
||||
Refresh,
|
||||
Cleanup,
|
||||
Help,
|
||||
Version,
|
||||
// Something was typed that is not a command: `error` says what.
|
||||
Unknown,
|
||||
};
|
||||
|
||||
struct Parsed {
|
||||
Command command = Command::None;
|
||||
// Package names, or the search term for Search.
|
||||
QStringList operands;
|
||||
// Skip the confirmation of a destructive command.
|
||||
bool assumeYes = false;
|
||||
// Why parsing refused, when command == Unknown.
|
||||
QString error;
|
||||
};
|
||||
|
||||
// True when the arguments ask for the command line rather than the window.
|
||||
// The absence of a known keyword is what keeps
|
||||
// "pacmanager /chemin/app.flatpak" opening the window, the way the desktop
|
||||
// entry hands a file over.
|
||||
bool isCliInvocation(const QStringList& args);
|
||||
|
||||
// Parses the arguments, program name excluded.
|
||||
Parsed parse(const QStringList& args);
|
||||
|
||||
// The text `pacmanager --help` prints.
|
||||
QString helpText();
|
||||
|
||||
} // namespace cli
|
||||
@@ -1,8 +1,11 @@
|
||||
#include "app-core.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QStandardPaths>
|
||||
#include <QTimer>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -16,6 +19,7 @@
|
||||
#include "log-manager.h"
|
||||
#include "plugin-package.h"
|
||||
#include "provider-trace.h"
|
||||
#include "startup-check.h"
|
||||
#include "workers.h"
|
||||
|
||||
namespace {
|
||||
@@ -540,6 +544,36 @@ bool AppCore::isPluginPackage(const QString& path) const {
|
||||
return PluginPackage::isPackagePath(path);
|
||||
}
|
||||
|
||||
AppCore::FileTarget AppCore::fileTarget(const QString& path) const {
|
||||
FileTarget target;
|
||||
const QString clean = path.trimmed();
|
||||
if (clean.isEmpty()) return target;
|
||||
|
||||
// A plugin package names itself in its own manifest, and the registry knows
|
||||
// whether that plugin is already there. Read only: nothing is written
|
||||
// before the window has decided what to tell the user.
|
||||
if (isPluginPackage(clean)) {
|
||||
QString error;
|
||||
const PluginPackage::Contents contents = PluginPackage::read(clean, &error);
|
||||
if (!error.isEmpty()) return target; // unusable: nothing to announce
|
||||
target.name = contents.manifest.id;
|
||||
target.plugin = true;
|
||||
target.installed = m_packages->isInstalled(target.name);
|
||||
return target;
|
||||
}
|
||||
|
||||
// A provider file: the provider owning the format names the application it
|
||||
// would install, and answers whether it is already deployed.
|
||||
for (IPackageManager* pm : availableProviders()) {
|
||||
const std::string name = pm->fileTargetName(clean.toStdString());
|
||||
if (name.empty()) continue;
|
||||
target.name = QString::fromStdString(name);
|
||||
target.installed = pm->isPackageInstalled(name);
|
||||
return target;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
AppCore::StartResult AppCore::removePackages(const std::vector<PackageInfo>& packages,
|
||||
const QString& description) { Request request;
|
||||
request.action = QStringLiteral("cleanup");
|
||||
@@ -1273,6 +1307,84 @@ bool AppCore::applySelfUpdate(const QString& sudoPassword, QString* error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Startup update check
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
|
||||
// Directory the systemd user unit is written under. GenericConfigLocation is
|
||||
// ~/.config, honouring XDG_CONFIG_HOME, which is exactly where systemd looks.
|
||||
QString userConfigDir() {
|
||||
QString dir = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
|
||||
if (dir.isEmpty()) dir = QDir::homePath() + "/.config";
|
||||
return dir;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool AppCore::checkUpdatesAtStartup() const {
|
||||
return m_settings.value("updates/checkAtStartup", true).toBool();
|
||||
}
|
||||
|
||||
void AppCore::setCheckUpdatesAtStartup(bool enabled) {
|
||||
m_settings.setValue("updates/checkAtStartup", enabled);
|
||||
|
||||
const QString configDir = userConfigDir();
|
||||
QString error;
|
||||
|
||||
if (enabled) {
|
||||
// The unit runs the executable that is doing the installing, so the
|
||||
// check follows an app installed anywhere (~/.local/bin, /usr/bin...).
|
||||
const QString program =
|
||||
UpdateManager::restartProgram(QCoreApplication::applicationDirPath());
|
||||
if (program.isEmpty() ||
|
||||
!StartupCheck::installAutostart(configDir, program, &error)) {
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("config"),
|
||||
QStringLiteral("autostart des mises à jour impossible : %1")
|
||||
.arg(error.isEmpty() ? QStringLiteral("binaire introuvable") : error));
|
||||
emit statusMessage(tr("Impossible d'installer la vérification au démarrage."));
|
||||
return;
|
||||
}
|
||||
StartupCheck::reloadUserManager();
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("config"),
|
||||
QStringLiteral("vérification des mises à jour au démarrage activée"));
|
||||
emit statusMessage(tr(
|
||||
"Vérification des mises à jour au démarrage activée (notification à l'ouverture de session)."));
|
||||
} else {
|
||||
StartupCheck::removeAutostart(configDir, &error);
|
||||
StartupCheck::reloadUserManager();
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("config"),
|
||||
QStringLiteral("vérification des mises à jour au démarrage désactivée"));
|
||||
emit statusMessage(tr("Vérification des mises à jour au démarrage désactivée."));
|
||||
}
|
||||
}
|
||||
|
||||
void AppCore::ensureStartupAutostart() {
|
||||
if (!checkUpdatesAtStartup()) return;
|
||||
|
||||
const QString program =
|
||||
UpdateManager::restartProgram(QCoreApplication::applicationDirPath());
|
||||
if (program.isEmpty()) return;
|
||||
|
||||
const QString configDir = userConfigDir();
|
||||
const bool wasEnabled = StartupCheck::autostartEnabled(configDir);
|
||||
|
||||
// Rewriting the unit on every launch keeps the executable path current (the
|
||||
// app may have moved), but only a fresh install needs systemd to be told.
|
||||
QString error;
|
||||
if (!StartupCheck::installAutostart(configDir, program, &error)) {
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("config"),
|
||||
QStringLiteral("autostart des mises à jour non installé : %1").arg(error));
|
||||
return;
|
||||
}
|
||||
if (!wasEnabled) StartupCheck::reloadUserManager();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// pacman's database lock
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -121,6 +121,23 @@ public:
|
||||
// by a provider: they carry a plugin, they are not packages to install, so
|
||||
// they never take the sudo gate and never enter the file install queue.
|
||||
bool isPluginPackage(const QString& path) const;
|
||||
|
||||
// What a file the user drops (or opens with PacManager) would install, and
|
||||
// whether that application is already on the machine. Read before anything
|
||||
// runs, so the view can refuse a file the provider would only skip — or an
|
||||
// install that would silently do nothing — and say why.
|
||||
struct FileTarget {
|
||||
// Application id for a provider file ("com.example.App"), plugin id for
|
||||
// a .fwspacm. Empty when the file names no single application: a
|
||||
// .flatpakrepo registers a remote, and an unreadable file names
|
||||
// nothing at all.
|
||||
QString name;
|
||||
bool installed = false;
|
||||
// A .fwspacm carries a plugin, not a package: the two are refused with
|
||||
// different advice.
|
||||
bool plugin = false;
|
||||
};
|
||||
FileTarget fileTarget(const QString& path) const;
|
||||
// Bulk removal: one command per provider, run one provider at a time
|
||||
// (pacman locks its database for the whole operation).
|
||||
StartResult removePackages(const std::vector<PackageInfo>& packages,
|
||||
@@ -184,6 +201,18 @@ public:
|
||||
// when the update cannot run (no method available).
|
||||
bool applySelfUpdate(const QString& sudoPassword, QString* error);
|
||||
|
||||
// ---- Startup update check ----
|
||||
// Whether the app installs its login check: a systemd user unit that runs
|
||||
// `PacManager --check-updates` and pops a notification when updates are
|
||||
// pending — no window, no sudo password. On by default, since the point is
|
||||
// to warn the user without them opening the app.
|
||||
bool checkUpdatesAtStartup() const;
|
||||
void setCheckUpdatesAtStartup(bool enabled);
|
||||
// Refreshes the installed unit when the setting is on, in case the binary
|
||||
// moved since it was written. Idempotent; called once at window startup so
|
||||
// an update of the app keeps the login check pointing at the real file.
|
||||
void ensureStartupAutostart();
|
||||
|
||||
// ---- pacman's database lock ----
|
||||
bool databaseLocked() const;
|
||||
// What currently holds the lock, so the view can name the process it offers
|
||||
|
||||
@@ -0,0 +1,347 @@
|
||||
#include "startup-check.h"
|
||||
#include "log-manager.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
#include <QStandardPaths>
|
||||
#include <QThread>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
namespace {
|
||||
|
||||
// Package prefixes that make an update worth interrupting the user for. Kept
|
||||
// short and documented: widening it is a judgement call, not a bug fix.
|
||||
bool startsWithAny(const QString& name, std::initializer_list<const char*> prefixes) {
|
||||
for (const char* prefix : prefixes) {
|
||||
if (name.startsWith(QLatin1String(prefix))) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool toolExists(const QString& program) {
|
||||
return !QStandardPaths::findExecutable(program).isEmpty();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
StartupCheck::StartupCheck(QObject* parent) : QObject(parent) {}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Pure helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
QStringList StartupCheck::parseUpdates(const QString& output) {
|
||||
QStringList packages;
|
||||
const QStringList lines = output.split(QLatin1Char('\n'), Qt::SkipEmptyParts);
|
||||
|
||||
for (const QString& line : lines) {
|
||||
// "linux 6.9.1.arch1-1 -> 6.9.2.arch1-1" (checkupdates) and
|
||||
// "linux 6.9.2.arch1-1" (pacman -Qu) share the same head: the first
|
||||
// whitespace-separated token is the package name.
|
||||
const QStringList tokens = line.split(QLatin1Char(' '), Qt::SkipEmptyParts);
|
||||
if (tokens.isEmpty()) continue;
|
||||
packages << tokens.first();
|
||||
}
|
||||
|
||||
packages.removeDuplicates();
|
||||
return packages;
|
||||
}
|
||||
|
||||
bool StartupCheck::isCritical(const QString& package) {
|
||||
return startsWithAny(package, {
|
||||
"linux", // the kernel itself, its headers and its firmware
|
||||
"glibc", // everything links against it
|
||||
"systemd", // init and its libraries
|
||||
"mesa", // graphics stack: a broken update loses the session
|
||||
"nvidia", // out-of-tree driver built against the running kernel
|
||||
"xorg-server",
|
||||
"wayland",
|
||||
"pacman", // a broken pacman leaves no way to repair
|
||||
"openssl",
|
||||
});
|
||||
}
|
||||
|
||||
bool StartupCheck::isRebootRequired(const QString& package) {
|
||||
// Only the kernel (and its firmware, which "linux" also covers) plus the
|
||||
// out-of-tree graphics driver built against the running kernel leave the
|
||||
// system on the old code until it restarts.
|
||||
return startsWithAny(package, {"linux", "nvidia"});
|
||||
}
|
||||
|
||||
QStringList StartupCheck::criticalPackages(const QStringList& packages) {
|
||||
QStringList critical;
|
||||
for (const QString& package : packages) {
|
||||
if (isCritical(package)) critical << package;
|
||||
}
|
||||
return critical;
|
||||
}
|
||||
|
||||
QString StartupCheck::notificationTitle(const Result& result) {
|
||||
if (result.rebootRequired) return QStringLiteral("Mise à jour du noyau disponible");
|
||||
if (result.anyCritical) return QStringLiteral("Mises à jour importantes disponibles");
|
||||
return QStringLiteral("Mises à jour disponibles");
|
||||
}
|
||||
|
||||
QString StartupCheck::notificationBody(const Result& result) {
|
||||
const int count = result.updateCount;
|
||||
QString body = count == 1 ? QStringLiteral("1 mise à jour disponible.")
|
||||
: QStringLiteral("%1 mises à jour disponibles.").arg(count);
|
||||
|
||||
// Name the critical packages, but keep the bubble readable: a system with a
|
||||
// pending toolchain refresh can have a dozen of them.
|
||||
const QStringList critical = criticalPackages(result.packages);
|
||||
if (!critical.isEmpty()) {
|
||||
const int shown = qMin(critical.size(), 5);
|
||||
QStringList listed = critical.mid(0, shown);
|
||||
if (critical.size() > shown) listed << QStringLiteral("…");
|
||||
body += QStringLiteral("\nPaquets sensibles : %1.").arg(listed.join(QStringLiteral(", ")));
|
||||
}
|
||||
|
||||
body += result.rebootRequired
|
||||
? QStringLiteral("\nUn redémarrage sera nécessaire après l'installation.")
|
||||
: QStringLiteral("\nOuvrez PacManager pour les installer.");
|
||||
return body;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Check
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
QString StartupCheck::runTool(const QString& program, const QStringList& args,
|
||||
int timeoutMs, int* exitCode, QString* stderrText) {
|
||||
if (exitCode) *exitCode = -1;
|
||||
if (stderrText) stderrText->clear();
|
||||
|
||||
QProcess process;
|
||||
// Separate channels: stdout is the package list, stderr is diagnostics. A
|
||||
// merged stream would turn "warning: database file..." into a package name.
|
||||
process.setProcessChannelMode(QProcess::SeparateChannels);
|
||||
process.start(program, args);
|
||||
if (!process.waitForStarted(5000)) return {};
|
||||
|
||||
const bool finished = process.waitForFinished(timeoutMs);
|
||||
if (!finished) {
|
||||
process.kill();
|
||||
process.waitForFinished(2000);
|
||||
}
|
||||
|
||||
const QString out = QString::fromUtf8(process.readAllStandardOutput());
|
||||
if (stderrText) *stderrText = QString::fromUtf8(process.readAllStandardError()).trimmed();
|
||||
if (exitCode) *exitCode = finished ? process.exitCode() : -1;
|
||||
return out;
|
||||
}
|
||||
|
||||
StartupCheck::Result StartupCheck::check() {
|
||||
Result result;
|
||||
|
||||
QString output;
|
||||
QString stderrText;
|
||||
int code = 0;
|
||||
|
||||
if (toolExists(QStringLiteral("checkupdates"))) {
|
||||
// checkupdates refreshes a throwaway copy of the databases, so it needs
|
||||
// no root and cannot leave the real database half-synced. It exits 0
|
||||
// with updates, 2 when there is nothing to do, and anything else on a
|
||||
// real failure (no network, broken database...).
|
||||
output = runTool(QStringLiteral("checkupdates"), {}, 120000, &code, &stderrText);
|
||||
if (code != 0 && code != 2) {
|
||||
result.error = stderrText.isEmpty()
|
||||
? QStringLiteral("checkupdates a échoué (code %1).").arg(code)
|
||||
: QStringLiteral("checkupdates a échoué (code %1) : %2")
|
||||
.arg(code).arg(stderrText);
|
||||
return result;
|
||||
}
|
||||
} else if (toolExists(QStringLiteral("pacman"))) {
|
||||
// Fallback: read the already-synced database. It needs no root either,
|
||||
// but it only knows what the last `pacman -Sy` saw, so it can miss
|
||||
// updates — which `error` records rather than hiding.
|
||||
output = runTool(QStringLiteral("pacman"), {QStringLiteral("-Qu")}, 30000, &code,
|
||||
&stderrText);
|
||||
// pacman -Qu exits 1 when nothing matches (= no update at all).
|
||||
if (code != 0 && code != 1) {
|
||||
result.error = stderrText.isEmpty()
|
||||
? QStringLiteral("pacman -Qu a échoué (code %1).").arg(code)
|
||||
: QStringLiteral("pacman -Qu a échoué (code %1) : %2").arg(code).arg(stderrText);
|
||||
return result;
|
||||
}
|
||||
result.error = QStringLiteral(
|
||||
"checkupdates est absent (paquet pacman-contrib) : les mises à jour "
|
||||
"peuvent être manquées tant que la base n'est pas synchronisée.");
|
||||
} else {
|
||||
result.error = QStringLiteral("Ni checkupdates ni pacman n'est disponible.");
|
||||
return result;
|
||||
}
|
||||
|
||||
result.packages = parseUpdates(output);
|
||||
result.updateCount = result.packages.size();
|
||||
for (const QString& package : result.packages) {
|
||||
result.anyCritical = result.anyCritical || isCritical(package);
|
||||
result.rebootRequired = result.rebootRequired || isRebootRequired(package);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int StartupCheck::run() {
|
||||
const Result result = check();
|
||||
|
||||
if (!result.error.isEmpty()) {
|
||||
LogManager::instance().logEvent(QStringLiteral("maj-verif"), result.error);
|
||||
}
|
||||
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("maj-verif"),
|
||||
result.updateCount == 0
|
||||
? QStringLiteral("aucune mise à jour en attente")
|
||||
: QStringLiteral("%1 mise(s) à jour en attente : %2")
|
||||
.arg(result.updateCount)
|
||||
.arg(result.packages.join(QStringLiteral(", "))));
|
||||
|
||||
if (result.updateCount > 0) {
|
||||
notify(result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Notification
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
bool StartupCheck::sendNotification(const QString& title, const QString& body, bool urgent) {
|
||||
if (!toolExists(QStringLiteral("notify-send"))) return false;
|
||||
|
||||
QStringList args{QStringLiteral("-a"), QStringLiteral("PacManager")};
|
||||
if (urgent) {
|
||||
// A critical notification that never times out: the user should not be
|
||||
// able to miss a pending kernel update.
|
||||
args << QStringLiteral("-u") << QStringLiteral("critical")
|
||||
<< QStringLiteral("-t") << QStringLiteral("0");
|
||||
} else {
|
||||
args << QStringLiteral("-t") << QStringLiteral("10000");
|
||||
}
|
||||
args << title << body;
|
||||
|
||||
// A login unit can beat the notification daemon (mako, dunst...) to the
|
||||
// session bus, in which case the first sends fail. Retry for a few seconds
|
||||
// instead of dropping the notification silently.
|
||||
for (int attempt = 0; attempt < 30; ++attempt) {
|
||||
QProcess process;
|
||||
process.start(QStringLiteral("notify-send"), args);
|
||||
if (process.waitForStarted(3000) && process.waitForFinished(5000) &&
|
||||
process.exitCode() == 0) {
|
||||
return true;
|
||||
}
|
||||
QThread::msleep(1000);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StartupCheck::notify(const Result& result) {
|
||||
if (result.updateCount <= 0) return false;
|
||||
|
||||
const bool urgent = result.rebootRequired || result.anyCritical;
|
||||
const bool sent = sendNotification(notificationTitle(result),
|
||||
notificationBody(result), urgent);
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("maj-verif"),
|
||||
sent ? QStringLiteral("notification envoyée")
|
||||
: QStringLiteral("notification impossible (aucun démon de notification)"));
|
||||
return sent;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Autostart
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
QString StartupCheck::autostartUnitPath(const QString& configDir) {
|
||||
if (configDir.isEmpty()) return {};
|
||||
return configDir + QStringLiteral("/systemd/user/pacmanager-check-updates.service");
|
||||
}
|
||||
|
||||
QString StartupCheck::autostartWantsPath(const QString& configDir) {
|
||||
if (configDir.isEmpty()) return {};
|
||||
return configDir +
|
||||
QStringLiteral("/systemd/user/default.target.wants/pacmanager-check-updates.service");
|
||||
}
|
||||
|
||||
bool StartupCheck::installAutostart(const QString& configDir, const QString& program,
|
||||
QString* error) {
|
||||
if (configDir.isEmpty() || program.isEmpty()) {
|
||||
if (error) *error = QStringLiteral("répertoire de configuration ou programme manquant.");
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString unitPath = autostartUnitPath(configDir);
|
||||
const QString wantsPath = autostartWantsPath(configDir);
|
||||
|
||||
if (!QDir().mkpath(QFileInfo(unitPath).absolutePath()) ||
|
||||
!QDir().mkpath(QFileInfo(wantsPath).absolutePath())) {
|
||||
if (error) *error = QStringLiteral("impossible de créer %1").arg(configDir);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Quoted because a path may contain spaces; systemd accepts the quotes.
|
||||
const QString unit = QStringLiteral(
|
||||
"[Unit]\n"
|
||||
"Description=PacManager — mises à jour disponibles au démarrage\n"
|
||||
"Documentation=man:PacManager(1)\n"
|
||||
"After=network-online.target\n"
|
||||
"Wants=network-online.target\n"
|
||||
"\n"
|
||||
"[Service]\n"
|
||||
"Type=oneshot\n"
|
||||
"ExecStart=\"%1\" --check-updates\n"
|
||||
"\n"
|
||||
"[Install]\n"
|
||||
"WantedBy=default.target\n").arg(program);
|
||||
|
||||
QFile file(unitPath);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate) ||
|
||||
file.write(unit.toUtf8()) != unit.toUtf8().size()) {
|
||||
if (error) *error = QStringLiteral("impossible d'écrire %1").arg(unitPath);
|
||||
return false;
|
||||
}
|
||||
file.close();
|
||||
|
||||
// The symlink is what `systemctl --user enable` would create; writing it
|
||||
// directly keeps the install free of any systemd call.
|
||||
QFile::remove(wantsPath);
|
||||
if (!QFile::link(unitPath, wantsPath)) {
|
||||
if (error) *error = QStringLiteral("impossible de créer le lien %1").arg(wantsPath);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StartupCheck::removeAutostart(const QString& configDir, QString* error) {
|
||||
if (configDir.isEmpty()) {
|
||||
if (error) *error = QStringLiteral("répertoire de configuration manquant.");
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile::remove(autostartWantsPath(configDir));
|
||||
QFile::remove(autostartUnitPath(configDir));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StartupCheck::autostartEnabled(const QString& configDir) {
|
||||
const QString wantsPath = autostartWantsPath(configDir);
|
||||
if (wantsPath.isEmpty()) return false;
|
||||
const QFileInfo info(wantsPath);
|
||||
// A symlink whose target is missing would report exists() == false, so the
|
||||
// link itself is checked too: a stale link is still an installed setting.
|
||||
return info.isSymLink() || info.exists();
|
||||
}
|
||||
|
||||
bool StartupCheck::reloadUserManager() {
|
||||
if (!toolExists(QStringLiteral("systemctl"))) return false;
|
||||
|
||||
QProcess process;
|
||||
process.start(QStringLiteral("systemctl"),
|
||||
{QStringLiteral("--user"), QStringLiteral("daemon-reload")});
|
||||
if (!process.waitForStarted(3000)) return false;
|
||||
return process.waitForFinished(10000) && process.exitCode() == 0;
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
// The headless pass that answers "does this machine have pending updates?" and,
|
||||
// when it does, raises a desktop notification.
|
||||
//
|
||||
// It exists because the graphical window is not running when the machine
|
||||
// starts: the app installs a systemd user unit (see the autostart helpers here)
|
||||
// that runs `PacManager --check-updates` at login, and that call lands here.
|
||||
//
|
||||
// Two guarantees drive the implementation:
|
||||
// - no password: the check goes through `checkupdates` (pacman-contrib), which
|
||||
// syncs into a throwaway database and therefore needs no root, instead of a
|
||||
// `pacman -Sy` the login unit could never authenticate;
|
||||
// - no display: everything here is Qt Core only, so the unit runs with no
|
||||
// DISPLAY, no Wayland socket and no widget.
|
||||
//
|
||||
// The pure parts (parsing, classification, notification text, unit contents)
|
||||
// are static so they are unit-tested without a package manager, a network or a
|
||||
// session bus.
|
||||
class StartupCheck : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Outcome of one check, so the caller (and the tests) can inspect what
|
||||
// happened without parsing console output.
|
||||
struct Result {
|
||||
int updateCount = 0;
|
||||
bool anyCritical = false; // kernel, glibc, init, graphics stack...
|
||||
bool rebootRequired = false; // a kernel or its firmware is pending
|
||||
QStringList packages;
|
||||
// Non-empty when the check failed, or when it could only run in a
|
||||
// degraded way (the pacman -Qu fallback, which reads a database only
|
||||
// root can refresh). Never a reason to skip the notification.
|
||||
QString error;
|
||||
};
|
||||
|
||||
explicit StartupCheck(QObject* parent = nullptr);
|
||||
|
||||
// Runs the whole headless pass (check, then notify when something is
|
||||
// pending) and returns the exit code for main(). Always 0: a background
|
||||
// check that fails must not fill the user's journal with failed units.
|
||||
int run();
|
||||
|
||||
// ---- Pure helpers (unit-tested) ----
|
||||
// Parses the checked tool's output. `checkupdates` prints
|
||||
// "name oldver -> newver" and `pacman -Qu` prints "name newver"; only the
|
||||
// package name is needed and it is the first whitespace-separated token of
|
||||
// every line, so one parser accepts both. Duplicates are dropped.
|
||||
static QStringList parseUpdates(const QString& output);
|
||||
|
||||
// A package whose update deserves an urgent notification rather than the
|
||||
// ordinary one: the kernel and its firmware, the C library and init, the
|
||||
// graphics stack, pacman itself — the updates that either need a reboot or
|
||||
// can break the session when they fall behind. Prefix-based on purpose: a
|
||||
// package nobody thought about simply gets the normal notification.
|
||||
static bool isCritical(const QString& package);
|
||||
|
||||
// A package whose update only takes effect after a reboot: the kernel and
|
||||
// the out-of-tree driver built against the running one.
|
||||
static bool isRebootRequired(const QString& package);
|
||||
|
||||
// The critical subset of a list, so the notification can name what matters.
|
||||
static QStringList criticalPackages(const QStringList& packages);
|
||||
|
||||
// Notification title and body for a set of pending updates.
|
||||
static QString notificationTitle(const Result& result);
|
||||
static QString notificationBody(const Result& result);
|
||||
|
||||
// ---- Check and notify (touch the machine) ----
|
||||
// Pending updates, using `checkupdates` when available and falling back to
|
||||
// the already-synced `pacman -Qu` otherwise. Never needs root; the fallback
|
||||
// reads a database only root can refresh, so it may miss updates — which is
|
||||
// what `error` records rather than hiding.
|
||||
static Result check();
|
||||
|
||||
// Sends the notification through notify-send, waiting briefly for the
|
||||
// notification daemon (the login unit can start before mako). Returns false
|
||||
// when nothing could be sent.
|
||||
static bool notify(const Result& result);
|
||||
|
||||
// ---- Autostart: a systemd user unit the app installs itself ----
|
||||
// The unit lives under `configDir` (XDG_CONFIG_HOME, i.e. ~/.config) and is
|
||||
// enabled by a symlink in default.target.wants, which is the per-user
|
||||
// equivalent of `systemctl --user enable` without shelling out to it.
|
||||
// Passing the directory lets the unit test drive install/remove inside a
|
||||
// temporary tree instead of the user's own ~/.config.
|
||||
static QString autostartUnitPath(const QString& configDir);
|
||||
static QString autostartWantsPath(const QString& configDir);
|
||||
|
||||
// Writes the unit and the enabling symlink. `program` is the binary to run
|
||||
// with --check-updates (the running executable, so it follows the install
|
||||
// wherever it is). Filesystem only: no systemd call, so tests stay hermetic.
|
||||
static bool installAutostart(const QString& configDir, const QString& program,
|
||||
QString* error = nullptr);
|
||||
static bool removeAutostart(const QString& configDir, QString* error = nullptr);
|
||||
static bool autostartEnabled(const QString& configDir);
|
||||
|
||||
// Asks the user's systemd manager to re-read its units, so a fresh install
|
||||
// takes effect without waiting for the next boot. Best effort; a system
|
||||
// without a running user manager (a test, a container) is not an error.
|
||||
static bool reloadUserManager();
|
||||
|
||||
private:
|
||||
// Runs a tool to completion, returning its stdout. stderr is kept out of it
|
||||
// on purpose: a pacman warning is not a package name, so folding the two
|
||||
// would feed the parser lines it must not see — `stderrText` receives them
|
||||
// for the error message instead. `exitCode` receives the status, or -1 when
|
||||
// the process could not be started or timed out.
|
||||
static QString runTool(const QString& program, const QStringList& args,
|
||||
int timeoutMs, int* exitCode, QString* stderrText = nullptr);
|
||||
|
||||
// Waits (bounded) for the session's notification daemon, then sends through
|
||||
// notify-send with the given urgency.
|
||||
static bool sendNotification(const QString& title, const QString& body, bool urgent);
|
||||
};
|
||||
+5
-2
@@ -16,10 +16,11 @@ déboguer ou brancher un plugin.
|
||||
| [installation.md](installation.md) | Dépendances, compilation, options CMake, installation dans le bureau, fichiers créés sur le système |
|
||||
| [architecture.md](architecture.md) | La coupure logique / interface, le flux d'un appel, où ajouter du code |
|
||||
| [interface.md](interface.md) | Les écrans, la navigation, les raccourcis clavier, le thème (tokens du site FWS) |
|
||||
| [cli.md](cli.md) | La ligne de commande : commandes, résolution du fournisseur, mot de passe, codes de sortie |
|
||||
| [operations.md](operations.md) | Le déroulé d'une opération : sudo, verrou pacman, progression, providers multiples |
|
||||
| [plugins.md](plugins.md) | Fournisseurs et extensions : contrats, ABI C, emplacements, écriture d'un plugin |
|
||||
| [paquets-de-plugin.md](paquets-de-plugin.md) | Les paquets `.fwspacm` : format du manifeste, dépôt d'un fichier, sécurité, création |
|
||||
| [mise-a-jour.md](mise-a-jour.md) | L'auto-mise à jour : version, méthodes, redémarrage |
|
||||
| [mise-a-jour.md](mise-a-jour.md) | L'auto-mise à jour : version, compatibilité entre versions, dépendances de compilation, méthodes, procédure manuelle de secours, redémarrage |
|
||||
| [tests.md](tests.md) | Les cibles de test et ce qu'elles couvrent, comment en ajouter |
|
||||
| [depannage.md](depannage.md) | Problèmes courants et comment les diagnostiquer |
|
||||
|
||||
@@ -29,11 +30,13 @@ déboguer ou brancher un plugin.
|
||||
| --- | --- |
|
||||
| `core/app-core.h`, `core/app-core.cpp` | **La logique** : providers, workers, historique, plugins, sudo, verrou pacman, auto-update. Aucun widget. |
|
||||
| `app/main-window.h`, `app/main-window.cpp` | **Le cadre** : barre latérale, en-tête, barre de statut, menus, tray, dialogues, feuille de style. |
|
||||
| `cli/cli-command.*`, `cli/cli-application.*` | **La ligne de commande** : la grammaire (testée) puis l'exécution sur `AppCore`, sans widget. |
|
||||
| `pages/` | **Les écrans**, un fichier par écran, plus `page.h` (contrat) et `ui-kit.*` (widgets partagés). |
|
||||
| `include/sdk/progress-tracker.h` | La progression d'une opération, lue dans la sortie des outils. |
|
||||
| `include/sdk/provider-trace.h` | Le point d'entrée sans Qt par lequel un fournisseur trace ses commandes dans le journal. |
|
||||
| `plugins/plugin-package.h`, `plugins/plugin-package.cpp` | L'installation d'un paquet de plugin `.fwspacm` (avec `zip-archive.*` pour lire l'archive). |
|
||||
| `core/workers.h`, `core/workers.cpp` | Les threads de travail (recherche, listes, actions). |
|
||||
| `plugins/` | Les plugins livrés : `flatpak-provider`, `aur-provider`, et les deux exemples. |
|
||||
| `providers/` | Les fournisseurs livrés : `flatpak-provider`, `aur-provider`, et les deux modèles (`example-provider`, `example-addon`). `plugins/` ne contient que l'hôte : le registre et les paquets `.fwspacm`. |
|
||||
| `make-plugin-package.py` | Le script qui transforme une bibliothèque compilée en paquet `.fwspacm`. |
|
||||
|
||||
## Conventions du projet
|
||||
|
||||
+10
-3
@@ -4,7 +4,9 @@
|
||||
|
||||
Le projet tient sur une seule séparation, et elle est stricte : **toute la
|
||||
logique vit dans `AppCore`, toute l'interface vit dans `pages/`**. La fenêtre Qt
|
||||
(`MainWindow`) n'est qu'un cadre autour des écrans.
|
||||
(`MainWindow`) n'est qu'un cadre autour des écrans, et la ligne de commande
|
||||
(`cli/`) est un **second consommateur** de la même logique : elle parle à
|
||||
`AppCore` sans construire la moindre fenêtre (voir [cli.md](cli.md)).
|
||||
|
||||
| Couche | Fichiers | Ce qu'elle a le droit de faire |
|
||||
| --- | --- | --- |
|
||||
@@ -24,8 +26,11 @@ Deux conséquences directement vérifiables :
|
||||
```
|
||||
├── CMakeLists.txt # cible application, plugins, tests
|
||||
├── app/ # CADRE : la fenêtre et le point d'entrée
|
||||
│ ├── main.cpp # point d'entrée : journal, langue, fenêtre
|
||||
│ ├── main.cpp # point d'entrée : journal, langue, fenêtre, CLI
|
||||
│ └── main-window.h/.cpp # barre latérale, menus, dialogues, feuille de style
|
||||
├── cli/ # LIGNE DE COMMANDE (sans widget)
|
||||
│ ├── cli-command.h/.cpp # grammaire acceptée (testée)
|
||||
│ └── cli-application.h/.cpp # exécution sur AppCore
|
||||
├── core/ # LOGIQUE : tout ce que l'app fait
|
||||
│ ├── app-core.h/.cpp # le contrôleur dont les écrans délèguent
|
||||
│ ├── workers.h/.cpp # threads de travail (recherche, listes, actions)
|
||||
@@ -55,7 +60,8 @@ Deux conséquences directement vérifiables :
|
||||
│ ├── package-manager.h # interface IPackageManager + helpers de fusion
|
||||
│ ├── plugin.h # contrat générique d'un plugin (IPlugin)
|
||||
│ ├── provider-plugin.h # contrat C ABI des plugins externes
|
||||
│ └── progress-tracker.h # progression lue dans la sortie des outils
|
||||
│ ├── progress-tracker.h # progression lue dans la sortie des outils
|
||||
│ └── provider-trace.h # trace des fournisseurs, réservée au journal
|
||||
├── pages/ # INTERFACE : un fichier par écran
|
||||
│ ├── base/ # ce sur quoi tous les écrans reposent
|
||||
│ │ ├── page.h/.cpp # contrat d'un écran (Page) + helpers
|
||||
@@ -158,6 +164,7 @@ refusée tant que la première tourne. Voir [operations.md](operations.md).
|
||||
| Une nouvelle opération | Une méthode dans `AppCore` qui construit une `Request` et appelle `startRequest()` ; un `InstallWorker::Op` ; sa ligne dans `startMessage()`, `successMessage()`, `failureMessage()`. |
|
||||
| Une nouvelle liste | Une valeur dans `AppCore::ListMode`, un mode dans `ListWorker`, un slot dans `listFinished`. |
|
||||
| Un nouveau provider | Un plugin externe (voir [plugins.md](plugins.md)) — jamais une modification du cœur. |
|
||||
| Une nouvelle commande en ligne de commande | Un mot-clé dans `cli::parse()` (`cli/cli-command.cpp`), son exécution dans `cli::run()` (`cli/cli-application.cpp`) et sa ligne dans `helpText()`. La grammaire est couverte par `cli-command-test` ; voir [cli.md](cli.md). |
|
||||
| Un nouveau réglage | Une propriété dans `AppSettings` (`preferences/app-settings.h`), lue par la couche logique et exposée par l'écran Paramètres. Le mode d'identification reste dans `AppCore` (il fait partie de l'état des opérations privilégiées) ; `credentials/mode` et `plugins/<id>/enabled` sont les autres clés historiques. |
|
||||
| Une nouvelle langue | Un `translations/<code>.json` (clé = la chaîne source, valeur = la traduction), une entrée dans `resources/resources.qrc` pour l'embarquer, et une entrée dans `AppSettings::knownLanguages()` avec son endonyme. |
|
||||
|
||||
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
# Ligne de commande
|
||||
|
||||
PacManager a une **ligne de commande simplifiée**, en plus de la fenêtre : le
|
||||
même paquet se cherche et s'installe sans ouvrir d'interface, ce qui rend le
|
||||
gestionnaire utilisable dans un script ou sur une machine sans écran.
|
||||
|
||||
```bash
|
||||
pacmanager recherche vlc
|
||||
pacmanager install vlc
|
||||
```
|
||||
|
||||
## Comment elle est branchée
|
||||
|
||||
Le choix se fait dans `app/main.cpp`, **avant qu'aucun widget n'existe** :
|
||||
`cli::isCliInvocation()` reconnaît une commande ou une option, et l'exécution
|
||||
part alors sur un `QCoreApplication`. Une machine sans serveur graphique peut
|
||||
donc lancer une opération ; aucune fenêtre n'est construite.
|
||||
|
||||
C'est exactement la même logique que l'interface : la commande parle à
|
||||
`AppCore` (`core/app-core.h`) et rien d'autre. Elle bénéficie donc des mêmes
|
||||
providers (pacman, Flatpak, AUR…), du même verrou pacman, du même journal et du
|
||||
même historique.
|
||||
|
||||
| Fichier | Rôle |
|
||||
| --- | --- |
|
||||
| `cli/cli-command.h/.cpp` | **La grammaire** : quels arguments demandent la ligne de commande, et ce que chaque mot-clé donne. Pur, sans processus lancé — c'est ce que teste `cli-command-test`. |
|
||||
| `cli/cli-application.h/.cpp` | **L'exécution** : lancer la commande sur `AppCore`, attendre la fin (signaux + boucle d'événements), afficher le résultat. |
|
||||
|
||||
## Commandes
|
||||
|
||||
Les mots-clés français viennent en premier (le reste de l'interface est écrit
|
||||
dans cette langue) ; les alias anglais sont acceptés.
|
||||
|
||||
| Commande | Alias | Effet |
|
||||
| --- | --- | --- |
|
||||
| `recherche <terme>` | `search`, `cherche` | Cherche dans tous les fournisseurs et affiche une ligne par paquet. |
|
||||
| `install <paquet...>` | `installer` | Installe un ou plusieurs paquets. |
|
||||
| `supprimer <paquet...>` | `remove`, `uninstall`, `désinstaller` | Supprime (confirmation demandée). |
|
||||
| `maj [paquet]` | `update`, `upgrade` | Met à jour un paquet ; **sans nom, tout** (confirmation demandée). |
|
||||
| `liste` | `list` | Liste les paquets installés. |
|
||||
| `maj-dispo` | `updates` | Liste les mises à jour disponibles. |
|
||||
| `info <paquet>` | `détails`, `details` | Détails d'un paquet (`-Qi` / `-Si` quand le fournisseur les expose). |
|
||||
| `refresh` | `rafraîchir`, `sync` | Rafraîchit les bases de données. |
|
||||
| `nettoyage` | `cleanup` | Liste les paquets inutilisés (orphelins) et legacy. |
|
||||
| `aide` | `help`, `-h`, `--help` | L'aide. |
|
||||
| `version` | `-v`, `--version` | La version installée. |
|
||||
|
||||
Options :
|
||||
|
||||
- `-y`, `--yes` : ne pas demander confirmation (suppression, mise à jour
|
||||
globale). Sans cette option, une commande destructive lancée depuis un tube
|
||||
(pas de terminal) est **refusée** plutôt que laissée à attendre sur `stdin`.
|
||||
|
||||
## Résolution du paquet et du fournisseur
|
||||
|
||||
`install`, `supprimer`, `maj` et `info` prennent un **nom de paquet**, pas un
|
||||
identifiant de fournisseur : le nom est cherché, puis comparé **exactement**
|
||||
(insensible à la casse) à un résultat. Le fournisseur retenu est celui que la
|
||||
recherche a associé au paquet, donc `install vlc` part vers pacman et une
|
||||
application Flatpak vers Flatpak, sans que l'utilisateur ait à le dire.
|
||||
|
||||
Un nom introuvable est une erreur (« Paquet introuvable : … »), avec le code de
|
||||
sortie 1.
|
||||
|
||||
## Mot de passe et sortie
|
||||
|
||||
- Le mot de passe sudo est demandé **sur le terminal**, avec l'écho coupé comme
|
||||
`sudo` ; il n'est jamais relu depuis un tube et n'est pas conservé après
|
||||
l'opération.
|
||||
- La sortie des commandes (ce que pacman imprime) est retransmise au fil de
|
||||
l'eau, préfixée de deux espaces, exactement comme dans le journal.
|
||||
- Les données (tableaux, résultats) vont sur **stdout** ; les messages du
|
||||
journal Qt et les invites (`Mot de passe…`, confirmations) vont sur
|
||||
**stderr** : `pacmanager recherche vlc 2>/dev/null` ne laisse que le tableau.
|
||||
|
||||
## Codes de sortie
|
||||
|
||||
| Code | Sens |
|
||||
| --- | --- |
|
||||
| `0` | Commande réussie. |
|
||||
| `1` | Échec d'une opération, ou paquet introuvable. |
|
||||
| `2` | Erreur d'usage (commande ou option inconnue, argument manquant). |
|
||||
|
||||
## Ce qu'elle ne fait pas (volontairement)
|
||||
|
||||
- Ce n'est **pas** pacman : pas de `-Syu`, pas d'options brutes, pas de
|
||||
résolution de dépendances fine. C'est un raccourci pour les gestes courants.
|
||||
- Pas de menus interactifs : chaque commande fait une chose et se termine.
|
||||
- Le nettoyage **liste** les candidats ; la suppression groupée reste le fait de
|
||||
l'interface (et de `supprimer`, paquet par paquet).
|
||||
|
||||
## Tester
|
||||
|
||||
```bash
|
||||
./build/PacManager --help
|
||||
./build/PacManager recherche vlc
|
||||
./build/PacManager info vlc
|
||||
```
|
||||
|
||||
Les commandes de lecture (`recherche`, `liste`, `maj-dispo`, `info`,
|
||||
`nettoyage`) ne modifient rien et se testent sans risque ; `install` et
|
||||
`supprimer` demandent le mot de passe et modifient le système. La grammaire
|
||||
est couverte par `ctest -R cli-command`.
|
||||
+23
-7
@@ -31,13 +31,18 @@ fichier.
|
||||
## Logs
|
||||
|
||||
Les messages sont rangés par catégorie : `pacmgr.ui`, `pacmgr.op` (opérations),
|
||||
`pacmgr.plugin`, `pacmgr.update` (mises à jour et réseau). Par défaut, seuls les
|
||||
avertissements et erreurs s'affichent. Pour tout voir :
|
||||
`pacmgr.plugin`, `pacmgr.update` (mises à jour et réseau). L'application active
|
||||
**toutes** ces catégories pour son propre journal (`pacmgr.*=true` avant
|
||||
l'installation du gestionnaire de messages) : l'écran **Logs** montre donc le
|
||||
détail complet — opérations, vraies commandes `$ …`, sortie des outils — sans
|
||||
rien avoir à régler.
|
||||
|
||||
Pour la sortie console, `QT_LOGGING_RULES` garde la main :
|
||||
|
||||
```bash
|
||||
QT_LOGGING_RULES="pacmgr.*=true" ./PacManager
|
||||
QT_LOGGING_RULES="pacmgr.*=true" ./PacManager # tout, y compris sur la console
|
||||
QT_LOGGING_RULES="pacmgr.op.debug=true" ./PacManager # une seule catégorie
|
||||
QT_LOGGING_RULES="pacmgr.*.debug=false" ./PacManager # trop bavard : on calme
|
||||
QT_LOGGING_RULES="pacmgr.*.debug=false" ./PacManager # trop bavard : on calme
|
||||
```
|
||||
|
||||
Depuis un paquet installé, la sortie part dans le journal :
|
||||
@@ -46,8 +51,19 @@ Depuis un paquet installé, la sortie part dans le journal :
|
||||
journalctl --user -f | grep pacmgr
|
||||
```
|
||||
|
||||
Les lignes de commande exécutées et leur code de retour sont tracés en
|
||||
`pacmgr.op`, ce qui permet de reproduire l'échec à la main dans un terminal.
|
||||
Le journal de l'application **ne reprend pas** la sortie interne de Qt : les
|
||||
catégories de la couche graphique (`qt.qpa.*`, par exemple
|
||||
`qt.qpa.wayland.textinput`, qui redit un avertissement de focus à chaque boîte de
|
||||
dialogue ouverte sous Wayland) décrivent le serveur d'affichage, pas
|
||||
l'application, et noieraient le journal sous des lignes sur lesquelles
|
||||
l'utilisateur ne peut rien. Elles restent sur la sortie standard — c'est là
|
||||
qu'un développeur les cherche — et tout ce que l'application journalise
|
||||
d'elle-même (événements, commandes, `pacmgr.*`) y est toujours.
|
||||
|
||||
Les commandes réellement lancées par les fournisseurs y sont tracées (ligne
|
||||
`$ …`, cache `cache · …`, compteurs de résultats), ce qui permet de reproduire
|
||||
l'échec à la main dans un terminal. Le détail est dans
|
||||
[operations.md](operations.md).
|
||||
|
||||
## Problèmes courants
|
||||
|
||||
@@ -211,7 +227,7 @@ prend du temps sans produire d'octets.
|
||||
Ouvrir une issue sur le dépôt FWS avec :
|
||||
|
||||
1. la version affichée en bas de la barre latérale (elle provient du binaire et du fichier `version` voisin, voir [mise-a-jour.md](mise-a-jour.md)) ;
|
||||
2. la sortie complète avec `QT_LOGGING_RULES="pacmgr.*=true" ./PacManager` ;
|
||||
2. le journal de l'application (`operations.log`, écran **Logs**) ou la sortie complète avec `QT_LOGGING_RULES="pacmgr.*=true" ./PacManager` ;
|
||||
3. l'action exacte qui a échoué et le message affiché ;
|
||||
4. les versions des outils concernés : `pacman --version`, `flatpak --version`,
|
||||
`yay --version` / `paru --version`.
|
||||
+23
-5
@@ -13,7 +13,7 @@ Chaque entrée correspond à un écran de `pages/` (ou à un mode d'un écran).
|
||||
| ⬆️ Mises à jour | `browse-page` (mode mises à jour) | Paquets obsolètes (`pacman -Qu`), mise à jour unitaire ou globale. Le nombre est repris dans la barre latérale. |
|
||||
| 🧹 Nettoyage | `cleanup-page` | Orphelins et paquets étrangers, suppression groupée ou unitaire, purge des caches. |
|
||||
| 📋 Historique | `history-page` | Toutes les actions, filtrables, export CSV. |
|
||||
| 📜 Logs | `logs-page` | `/var/log/pacman.log`, avec filtre instantané. |
|
||||
| 📜 Logs | `logs-page` | Le journal de l'application (`operations.log` : opérations, sortie des commandes, trace des fournisseurs) **et** `/var/log/pacman.log`, sélectionnables, avec filtre instantané. |
|
||||
| 🧩 Plugins | `plugins-page` | Plugins installés (activation, rechargement, installation de l'outil manquant) **et paquets `.fwspacm`** (voir [paquets-de-plugin.md](paquets-de-plugin.md)). |
|
||||
|
||||
Trois de ces entrées (Recherche, Installés, Mises à jour) partagent le même
|
||||
@@ -64,6 +64,24 @@ d'un coup s'installent **un par un** (le core n'accepte qu'une opération à la
|
||||
fois) ; un paquet `.fwspacm`, lui, s'installe immédiatement, sans mot de passe
|
||||
ni file d'attente.
|
||||
|
||||
Un fichier accepté est **confirmé par une boîte de dialogue** : elle nomme ce qui
|
||||
vient d'être pris en compte et ce que cela déclenche (l'installation démarre et
|
||||
sa progression s'affiche en bas de la fenêtre, ou le plugin est installé et
|
||||
utilisable tout de suite). Sans elle, un dépôt qui lance une installation en
|
||||
arrière-plan — ou qui pose un plugin sans un bruit — se lit comme un geste
|
||||
ignoré.
|
||||
|
||||
Le cadre refuse en revanche un fichier que la machine possède **déjà**. Le
|
||||
fournisseur nomme l'application que le fichier installerait
|
||||
(`fileTargetName()`) et répond s'il l'a déjà (`isPackageInstalled()`), sans rien
|
||||
lancer : le nom est lu dans le fichier lui-même (section `[Flatpak Ref]` d'un
|
||||
`.flatpakref`, en-tête d'un `.flatpak`, manifeste d'un `.fwspacm`) et comparé à
|
||||
ce qui est installé. La boîte de dialogue dit alors quel fichier est déjà
|
||||
installé et quoi faire à la place : mettre à jour depuis l'écran des mises à
|
||||
jour, ou supprimer le plugin depuis l'écran Extensions. Sans ce contrôle,
|
||||
Flatpak se contenterait de sauter l'installation et de renvoyer un succès que
|
||||
l'utilisateur n'a pas eu.
|
||||
|
||||
Certains widgets refusent le dépôt (`setAcceptDrops(false)`) : un `.fwspacm`
|
||||
lâché sur le champ de recherche ou sur celui des logs doit être traité par la
|
||||
fenêtre, pas collé dans le filtre.
|
||||
@@ -109,7 +127,7 @@ sans redémarrage.
|
||||
| Mot de passe administrateur | À chaque opération / une fois au lancement | Passe par `AppCore::setCredentialMode()`. Demander maintenant, c'est le cadre qui possède la boîte de dialogue : l'écran émet `credentialModeRequested` et le cadre applique le mode (et met la case à cocher du menu en accord). |
|
||||
| Journal | Dossier, taille maximale | `LogManager` écrit dans le dossier choisi. Changer de dossier **déplace** le journal existant, et la limite fait tourner le fichier (`operations.log.1` conserve la version précédente). Un dossier illisible retombe sur celui par défaut plutôt que de laisser l'application sans log. |
|
||||
| Glisser-déposer | Accepter / refuser les fichiers Flatpak | Le dépôt est refusé par la fenêtre. « Ouvrir avec PacManager » continue de fonctionner : ce sont deux chemins d'entrée distincts. |
|
||||
| Langue | Système / Français / English | Voir [La langue](#la-langue). |
|
||||
| Langue | Système / Français / English / Español / Deutsch / Italiano | Voir [La langue](#la-langue). |
|
||||
| Mises à jour de PacManager | Vérification automatique, blocage | Voir [Bloquer les mises à jour](#bloquer-les-mises-à-jour). |
|
||||
|
||||
### La langue
|
||||
@@ -132,9 +150,9 @@ Un catalogue posé par l'utilisateur est cherché avant celui fourni :
|
||||
2. `~/.local/share/PacManager/translations` ;
|
||||
3. `translations/` à côté de l'exécutable (arbre de compilation).
|
||||
|
||||
Les catalogues fournis sont **compilés dans le binaire** par
|
||||
`resources/resources.qrc` : rien à copier ni à installer à côté, et la langue
|
||||
fonctionne quelle que soit l'installation. Un `.qm` compilé depuis un `.ts`
|
||||
Les catalogues fournis — **anglais, espagnol, allemand et italien** — sont
|
||||
**compilés dans le binaire** par `resources/resources.qrc` : rien à copier ni à
|
||||
installer à côté, et la langue fonctionne quelle que soit l'installation. Un `.qm` compilé depuis un `.ts`
|
||||
avec Qt Linguist reste accepté, pour qui préfère cet outil.
|
||||
|
||||
Le changement est **immédiat** : `LanguageManager::apply()` retire l'ancien
|
||||
|
||||
+249
-16
@@ -1,13 +1,35 @@
|
||||
# Mise à jour de l'application
|
||||
|
||||
PacManager se met à jour lui-même : au lancement puis une fois par jour, il
|
||||
interroge la dernière release du dépôt et propose de l'installer. Toute la
|
||||
logique est dans `update/update-manager.h` / `update/update-manager.cpp`.
|
||||
PacManager se met à jour lui-même : au lancement puis **au plus une fois par
|
||||
jour**, il interroge la dernière release du dépôt et propose de l'installer.
|
||||
Toute la logique est dans `update/update-manager.h` / `update/update-manager.cpp`.
|
||||
|
||||
L'utilisateur peut couper ce contrôle, et le suspendre pour un temps, depuis
|
||||
Deux choses distinctes se jouent ici, et les confondre est la source de la
|
||||
plupart des questions :
|
||||
|
||||
| | Rôle | Ce qui l'arrête |
|
||||
| --- | --- | --- |
|
||||
| **Le contrôle** | demander à l'API Gitea le dernier tag publié et le comparer à la version installée | le réglage de vérification, un blocage en cours, `lastCheckDate` de moins de 24 h |
|
||||
| **L'application** | reconstruire ou décompresser la nouvelle version et l'installer dans le dossier du binaire | l'absence d'outillage **ou** de dépendances de compilation, les droits d'écriture du dossier cible |
|
||||
|
||||
L'utilisateur peut couper le contrôle, et le suspendre pour un temps, depuis
|
||||
l'écran **Paramètres → Mises à jour de PacManager** (voir
|
||||
[interface.md](interface.md)). Ces deux réglages ne concernent que PacManager :
|
||||
les mises à jour des paquets du système ne sont jamais bloquées.
|
||||
les mises à jour des paquets du système ne sont jamais bloquées. Un contrôle
|
||||
peut aussi être forcé à la main : menu **Aide → Vérifier les mises à jour**, ou
|
||||
le menu du tray.
|
||||
|
||||
## En bref
|
||||
|
||||
1. L'API Gitea renvoie un tag (`V1.5.5`) plus récent que la version installée.
|
||||
2. Le dialogue annonce la version, la **méthode** qui sera employée et le
|
||||
**dossier cible** (`methodDescription()`).
|
||||
3. Un mot de passe sudo est demandé quand il est nécessaire : dossier cible non
|
||||
inscriptible, ou dépendances de compilation manquantes.
|
||||
4. La compilation tourne dans un dossier temporaire ; le binaire en cours
|
||||
d'exécution n'est pas touché.
|
||||
5. Le nouveau binaire est installé (copie vers un fichier voisin puis `rename`),
|
||||
et PacManager **redémarre** dessus.
|
||||
|
||||
## La version
|
||||
|
||||
@@ -22,8 +44,38 @@ Le fichier `version` à la racine du dépôt est la **source unique de vérité*
|
||||
(`newestVersion()`). C'est ce qui évite de proposer pour toujours une version
|
||||
déjà installée quand l'une des deux sources retarde — un binaire recompilé sans
|
||||
reconfiguration, ou une installation plus ancienne que le binaire. Le résultat de
|
||||
`isNewerVersion()` (comparaison de versions pointées) décide s'il y a une mise à
|
||||
jour à proposer.
|
||||
`isNewerVersion()` (comparaison de versions pointées, `1.10.2` > `1.9.1`, un `v`
|
||||
de tête étant ignoré) décide s'il y a une mise à jour à proposer.
|
||||
|
||||
Conséquence pratique : **poser un `version` plus récent que celui du code fait
|
||||
passer l'application pour une version qu'elle n'est pas**. C'est exactement ce que
|
||||
le paquet `fws-pacmanage` corrige dans son `prepare()` quand le fichier `version`
|
||||
de l'amont est en retard sur la livraison.
|
||||
|
||||
## Compatibilité des versions
|
||||
|
||||
Toutes les versions **ne savent pas** s'installer leurs dépendances de
|
||||
compilation. C'est la distinction qui compte avant de mettre à jour une machine
|
||||
qui n'a jamais été mise à jour :
|
||||
|
||||
| Version installée | Installation des dépendances de compilation | Ce qui se passe sans outillage complet |
|
||||
| --- | --- | --- |
|
||||
| **1.4.3 et avant** | ❌ **aucune** | *Clone* et *Tarball* exigent `cmake` **et** un compilateur déjà présents (`chooseUpdateMethod()` ne connaît pas `canInstallPackages`). S'il en manque un, la méthode est **Aucune** : le dialogue propose d'ouvrir la page des releases au lieu d'un bouton qui échouerait. Si l'outillage est là mais qu'un **paquet** manque (`qt6-base`, `git`…), la compilation démarre et **échoue en route**. |
|
||||
| **1.5.0 → 1.5.5** | ✅ automatique | `pacman -T` liste ce qui manque, la mise à jour l'installe via `sudo pacman -S --needed --noconfirm`, puis recompile. Le dialogue demande le mot de passe sudo **aussi** pour cette raison et l'explique. |
|
||||
| **1.6.0** (branche `release-1.6.0`) | ✅ automatique | Idem, plus : la sortie complète d'une mise à jour qui échoue est conservée dans le journal (`maj-app`), au lieu du seul dialogue — qui la coupe à l'écran. |
|
||||
|
||||
> ⚠️ **Avant de mettre à jour depuis la 1.4.3 ou plus ancien**, installez les
|
||||
> dépendances à la main : la mise à jour de l'époque ne sait pas le faire, et un
|
||||
> simple paquet manquant (`qt6-base` est le plus fréquent) suffit à casser la
|
||||
> compilation.
|
||||
>
|
||||
> ```bash
|
||||
> sudo pacman -S --needed base-devel cmake gcc git qt6-base
|
||||
> ```
|
||||
|
||||
L'installation automatique est arrivée avec le commit `b204d68`
|
||||
(« feat(update): install missing build dependencies before rebuilding »),
|
||||
livré pour la première fois dans **V1.5.0**.
|
||||
|
||||
## L'état de contrôle
|
||||
|
||||
@@ -34,11 +86,24 @@ jour à proposer.
|
||||
| `lastCheckDate` | Date du dernier contrôle réussi : un seul appel réseau par jour. |
|
||||
| `latestRemoteVersion` | Dernière version vue sur le serveur, affichable même sans réseau. |
|
||||
|
||||
Supprimer ce fichier force un nouveau contrôle au prochain lancement.
|
||||
|
||||
## Les dépendances de compilation
|
||||
|
||||
Les méthodes *Checkout*, *Clone* et *Tarball* recompilent l'application : elles
|
||||
ont besoin de **base-devel, cmake, gcc, git et qt6-base**. Plutôt que de les
|
||||
exiger à l'avance, la mise à jour les installe elle-même :
|
||||
Seules les méthodes qui **recompilent** en ont besoin — *Checkout*, *Clone* et
|
||||
*Tarball*. *Prebuilt*, quand elle s'applique, ne demande rien d'autre que `curl`
|
||||
ou `wget` et `tar`.
|
||||
|
||||
| Paquet | Pourquoi |
|
||||
| --- | --- |
|
||||
| `base-devel` | le métapaquet d'Arch : `make`, `sudo`, l'outillage de base |
|
||||
| `cmake` | configure et compile le projet (il est dans `base-devel` sur Arch courant, listé à part pour une machine allégée) |
|
||||
| `gcc` | le compilateur C++ |
|
||||
| `git` | méthode *Clone* : récupérer les sources |
|
||||
| `qt6-base` | les modules Widgets (l'interface) et Network (l'appel à l'API Gitea) |
|
||||
|
||||
Depuis la **1.5.0**, plutôt que de les exiger à l'avance, la mise à jour les
|
||||
installe elle-même :
|
||||
|
||||
1. Le dialogue de mise à jour demande le mot de passe sudo dès que `pacman -T`
|
||||
signale un paquet manquant (en plus du cas « dossier cible non accessible en
|
||||
@@ -51,13 +116,16 @@ Sur une machine complète, aucune étape de plus : `pacman -T` ne renvoie rien e
|
||||
le bloc est sauté. `pacman -T` n'est interrogé qu'une fois par lancement
|
||||
(`missingBuildDependencies()`), et le choix de méthode considère alors la
|
||||
machine comme « constructible » même sans cmake ni compilateur installés :
|
||||
``canInstallPackages`` suffit, puisque pacman peut combler le manque.
|
||||
`canInstallPackages` suffit, puisque pacman peut combler le manque.
|
||||
|
||||
Sur une version **antérieure à la 1.5.0**, ce bloc n'existe pas : les paquets
|
||||
ci-dessus doivent être présents avant de lancer la mise à jour.
|
||||
|
||||
## Les quatre méthodes d'installation
|
||||
|
||||
Toutes installent **au même endroit : le dossier de l'exécutable en cours
|
||||
d'exécution** (`binDir()`). L'application ne suppose donc aucun préfixe — elle se
|
||||
met à jour dans `~/.local/bin`, `/usr/bin`, un dossier décompressé ou un
|
||||
met à jour dans `~/.local/bin`, `/usr/bin`, un dossier décompressé ou une
|
||||
arborescence de build de la même façon.
|
||||
|
||||
| Méthode | Quand elle est choisie | Ce qui se passe |
|
||||
@@ -70,7 +138,18 @@ arborescence de build de la même façon.
|
||||
|
||||
Le choix est une **fonction pure** (`chooseUpdateMethod()` sur
|
||||
`UpdateCapabilities` : checkout utilisable, `git`, `cmake`, compilateur, archive
|
||||
précompilée, tarball), ce qui permet de le tester sans réseau ni outillage.
|
||||
précompilée, tarball, pacman présent), ce qui permet de le tester sans réseau ni
|
||||
outillage. L'ordre exact est :
|
||||
|
||||
1. un *checkout* utilisable autour du binaire → **Checkout** ;
|
||||
2. `git` **et** (`cmake` + compilateur, **ou** pacman capable de les installer)
|
||||
→ **Clone** ;
|
||||
3. une archive précompilée attachée à la release → **Prebuilt** ;
|
||||
4. un tarball de sources **et** une machine constructible → **Tarball** ;
|
||||
5. sinon → **Aucune**.
|
||||
|
||||
En pratique, sur une Arch complète, c'est toujours **Clone** qui gagne — le
|
||||
chemin *Prebuilt* n'est atteint que si pacman est absent ou inutile.
|
||||
|
||||
## Le déroulé
|
||||
|
||||
@@ -92,7 +171,79 @@ précompilée, tarball), ce qui permet de le tester sans réseau ni outillage.
|
||||
L'installation copie chaque fichier vers un fichier temporaire voisin **puis le
|
||||
renomme** (`stagedInstallScript()`) : c'est ce qui permet d'écraser un binaire
|
||||
(ou un plugin) actuellement utilisé, cas où un `cp` direct échoue avec
|
||||
`ETXTBSY` (« Text file busy »).
|
||||
`ETXTBSY` (« Text file busy »). Le script pose aussi le fichier `version` de la
|
||||
release, sans quoi `newestVersion()` retomberait sur la version compilée et la
|
||||
même release serait proposée à chaque lancement.
|
||||
|
||||
## Mettre à jour à la main (secours)
|
||||
|
||||
Indispensable quand l'application installée est trop ancienne pour s'installer
|
||||
ses dépendances, ou quand un échec n'a laissé aucune trace exploitable. Ce sont
|
||||
**exactement** les commandes de la méthode *Clone*, à lancer dans un terminal.
|
||||
|
||||
```bash
|
||||
# 0. les dépendances de compilation (obligatoire avant 1.5.0)
|
||||
sudo pacman -S --needed base-devel cmake gcc git qt6-base
|
||||
|
||||
SRC="$HOME/.local/share/PacManager/src"
|
||||
|
||||
# 1. récupérer les sources
|
||||
if [ -d "$SRC/.git" ]; then
|
||||
git -C "$SRC" fetch --depth 1 origin main
|
||||
git -C "$SRC" reset --hard FETCH_HEAD
|
||||
else
|
||||
git clone --depth 1 --branch main \
|
||||
https://gitea.nocode-var.tech/FWS/FWS-PacManage.git "$SRC"
|
||||
fi
|
||||
|
||||
# 2. compiler
|
||||
cmake -S "$SRC" -B "$SRC/build" -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build "$SRC/build" -j"$(nproc)"
|
||||
|
||||
# 3. installer dans un dossier de transit
|
||||
cmake --install "$SRC/build" --prefix /tmp/pm-stage
|
||||
```
|
||||
|
||||
Si l'étape 2 échoue, sa sortie **est** le diagnostic : c'est elle que la boîte
|
||||
de dialogue tronquait (voir la section Dépannage). Si elle passe, il ne reste
|
||||
qu'à recopier l'arbre installé dans le dossier du binaire — avec `sudo` quand ce
|
||||
dossier appartient à root, et en passant par un fichier voisin renommé, comme le
|
||||
fait l'application :
|
||||
|
||||
```bash
|
||||
BIN_DIR=/usr/lib/fws-pacmanage # le dossier du binaire à remplacer
|
||||
|
||||
sudo mkdir -p "$BIN_DIR/plugins"
|
||||
for f in /tmp/pm-stage/bin/PacManager /tmp/pm-stage/bin/version; do
|
||||
sudo cp "$f" "$BIN_DIR/$(basename "$f").new" \
|
||||
&& sudo mv -f "$BIN_DIR/$(basename "$f").new" "$BIN_DIR/$(basename "$f")"
|
||||
done
|
||||
for so in /tmp/pm-stage/bin/plugins/*.so; do
|
||||
sudo cp "$so" "$BIN_DIR/plugins/$(basename "$so").new" \
|
||||
&& sudo mv -f "$BIN_DIR/plugins/$(basename "$so").new" "$BIN_DIR/plugins/$(basename "$so")"
|
||||
done
|
||||
```
|
||||
|
||||
Relancer ensuite l'application : le binaire qui tourne mappe encore l'ancien
|
||||
inode, seule une relance prend le nouveau.
|
||||
|
||||
## Installations gérées par un paquet
|
||||
|
||||
Quand PacManager est installé par un paquet (`fws-pacmanage` de l'ISO FWS, qui
|
||||
pose binaire, `version` et plugins dans `/usr/lib/fws-pacmanage`), l'auto-mise à
|
||||
jour **écrit dans un dossier géré par pacman**. Elle y arrive — le dossier
|
||||
appartient à root, donc l'installation passe par `sudo` — mais deux effets sont
|
||||
à connaître :
|
||||
|
||||
- `pacman -Qkk fws-pacmanage` signale des fichiers modifiés, et une
|
||||
réinstallation du paquet (montée de version de l'ISO, `pacman -S fws-pacmanage`)
|
||||
**écrase la version auto-installée** ;
|
||||
- la version annoncée par l'application (fichier `version`) et celle de la base
|
||||
pacman (`pacman -Q`) peuvent alors diverger, ce qui se voit dans un rapport de
|
||||
bug.
|
||||
|
||||
Rien n'est cassé, mais la mise à jour par paquet reste la voie propre : préférez
|
||||
`pacman -Syu` ou le paquet de l'ISO quand il en existe un.
|
||||
|
||||
## Ce qui n'est jamais fait automatiquement
|
||||
|
||||
@@ -103,26 +254,108 @@ d'être sur Arch) et de fournir le mot de passe sudo — `git`, `cmake`, le
|
||||
compilateur et `qt6-base` sont installés par la mise à jour elle-même. Une
|
||||
installation hors Arch sans outillage ni archive ouvre la page des releases.
|
||||
|
||||
Le script **ne met jamais à niveau le système** : `pacman -Syu` n'est pas lancé,
|
||||
la base pacman n'est pas modifiée et aucune configuration n'est réécrite. La
|
||||
seule écriture de paquets est l'installation des dépendances de compilation
|
||||
manquantes (`pacman -S --needed`), et uniquement pour pouvoir compiler. Le
|
||||
dossier temporaire de travail est supprimé en sortie, quel que soit le résultat
|
||||
(`trap ... EXIT`).
|
||||
|
||||
## Vérifier à la main
|
||||
|
||||
| Action | Où |
|
||||
| --- | --- |
|
||||
| Forcer un contrôle | Menu **Aide → Vérifier les mises à jour**, ou le menu du tray. |
|
||||
| Voir la version installée | Bas de la barre latérale. |
|
||||
| Comprendre un échec | Le journal applicatif : `QT_LOGGING_RULES="pacmgr.update.debug=true" PacManager`. |
|
||||
| Voir l'état du contrôle | `~/.local/share/PacManager/update-state.json`. |
|
||||
| Voir la version que pacman connaît | `pacman -Q fws-pacmanage` (installation par paquet). |
|
||||
| Comprendre un échec | L'écran **Logs** : le bloc `maj-app` contient la sortie complète du script. |
|
||||
| Voir le détail live | `QT_LOGGING_RULES="pacmgr.update.debug=true" PacManager`. |
|
||||
| Repartir de zéro | Supprimer `~/.local/share/PacManager/update-state.json`. |
|
||||
|
||||
## Dépannage
|
||||
|
||||
| Symptôme | Cause probable |
|
||||
| --- | --- |
|
||||
| Le dialogue n'apparaît jamais | Dernier contrôle de moins de 24 h (`lastCheckDate`). |
|
||||
| Le dialogue n'apparaît jamais | Dernier contrôle de moins de 24 h (`lastCheckDate`), ou contrôle désactivé / bloqué dans les Paramètres. |
|
||||
| « Aucune release trouvée sur le serveur » | Le dépôt n'a pas de release publiée. |
|
||||
| « Impossible de contacter le serveur » | Réseau ou API Gitea injoignable. Le dernier tag connu reste affiché. |
|
||||
| La compilation échoue sur une version **antérieure à 1.5.0** | Les dépendances de compilation manquaient et cette version ne les installe pas : `sudo pacman -S --needed base-devel cmake gcc git qt6-base`, puis relancer (voir la procédure manuelle). |
|
||||
| Le dialogue d'échec est coupé et la fin du build manque | La boîte ne montre que ce qui tient sur l'écran. La sortie **complète** du script est écrite dans le journal sous le bloc `maj-app` (`⟶ échec` puis les lignes brutes) : la lire depuis l'écran **Logs**, ou ouvrir le fichier donné dans le dialogue. Sur une version plus ancienne qui ne journalise pas cet échec, passer par la procédure manuelle. |
|
||||
| La mise à jour annonce échouer alors que le binaire a changé | Écriture impossible sans droits : vérifier les droits du dossier du binaire, ou relancer en acceptant la demande `sudo`. |
|
||||
| L'application redémarre sur l'ancienne version | Le `version` voisin du binaire n'a pas pu être réécrit : sans lui, `newestVersion()` retombe sur la version compilée, souvent plus ancienne. Vérifier les droits du fichier. |
|
||||
| Recompilation interminable | Méthode *Clone*/*Tarball* : c'est le comportement attendu sans archive précompilée attachée à la release. |
|
||||
| « sudo: a password is required » dans le journal | La mise à jour a tourné sans mot de passe et le dossier cible (ou l'installation des déps) le demandait : relancer et saisir le mot de passe dans le dialogue. |
|
||||
| La version est proposée à nouveau après un `pacman -Syu` | Le paquet a réécrit le dossier du binaire : sa version fait de nouveau autorité, et une release plus récente reste à installer. |
|
||||
|
||||
Voir aussi [installation.md](installation.md) pour les chemins concernés et
|
||||
[operations.md](operations.md) pour le rôle de `sudo` dans le reste de
|
||||
l'application.
|
||||
|
||||
## Vérification des mises à jour au démarrage
|
||||
|
||||
L'application peut aussi **vérifier les mises à jour disponibles à chaque
|
||||
ouverture de session**, sans rien demander — et afficher une notification
|
||||
quand certains paquets sont en attente, en particulier le noyau
|
||||
(`linux`, `linux-lts`, …), la glibc ou systemd.
|
||||
|
||||
- L'application installe **soi-même** son service systemd `--user` :
|
||||
`~/.config/systemd/user/pacmanager-check-updates.service`, activé
|
||||
(`default.target.wants`). Il suffit de l'ouvrir une fois pour que le
|
||||
comportement existe, et le menu ci-dessous pour l'activer/désactiver.
|
||||
- Le service s'exécute avec **`checkupdates`** (paquet `pacman-contrib`),
|
||||
qui synchronise une base temporaire : **aucun mot de passe, aucun sudo**,
|
||||
pas de risque de base pacman half-synchro. Si `checkupdates` est absent,
|
||||
le service retombe sur `pacman -Qu` (base déjà synchronisée) et avertit
|
||||
dans le journal que les résultats peuvent être moins précis.
|
||||
- La notification est **urgente** quand un paquet critique est en attente
|
||||
(noyau, firmware, glibc, systemd, pilote `nvidia`…) et indique qu'un
|
||||
redémarrage sera nécessaire. Le démon de notification (mako) doit être
|
||||
lancé, et le service attend son lancement avant d'envoyer.
|
||||
- La couche logique est testable sans écran, sans système, sans système de
|
||||
fichiers utilisateur : elle s'exécute dans un dossier temporaire.
|
||||
|
||||
Le code est dans `core/startup-check.h` / `core/startup-check.cpp` et le
|
||||
mode CLI est `PacManager --check-updates` (pas de fenêtre, pas de dépôt).
|
||||
|
||||
### Réglage
|
||||
|
||||
Menu **Paramètres → Vérifier les mises à jour au démarrage**.
|
||||
Coché par défaut : l'unité est installée à chaque ouverture.
|
||||
|
||||
| Action | Où |
|
||||
| --- | --- |
|
||||
| Activer / désactiver la vérification | Paramètres |
|
||||
| Forcer un contrôle maintenant | Menu **Aide → Vérifier les mises à jour** |
|
||||
| Voir les mises à jour disponibles | Page **Mises à jour** |
|
||||
|
||||
Le service est aussi utilisable manuellement :
|
||||
|
||||
```sh
|
||||
# exécuter la vérification maintenant (sans passer par le menu)
|
||||
systemctl --user start pacmanager-check-updates.service
|
||||
systemctl --user status pacmanager-check-updates.service --no-pager
|
||||
```
|
||||
|
||||
### Ce qui n'est jamais fait automatiquement
|
||||
|
||||
- Le contrôle n'**interrompt** jamais l'ouverture de la fenêtre.
|
||||
- La vérification n'**installe jamais** de paquet : elle fait juste
|
||||
remonter le nombre et le type de mises à jour.
|
||||
- Le service n'**attend jamais** le démon de notification : s'il n'est
|
||||
pas là, la vérification se termine sans notifier.
|
||||
|
||||
## Références
|
||||
|
||||
| Élément | Rôle |
|
||||
| --- | --- |
|
||||
| `UpdateManager::checkForUpdates()` | L'appel à l'API Gitea, le choix de l'asset (précompilé, sinon tarball) et l'enregistrement de l'état. |
|
||||
| `UpdateManager::currentVersion()` | La plus récente des deux versions connues. |
|
||||
| `UpdateManager::chooseUpdateMethod()` | Le choix de méthode, fonction pure testable. |
|
||||
| `UpdateManager::missingBuildDependencies()` | `pacman -T`, mis en cache pour la durée du processus. |
|
||||
| `UpdateManager::performSelfUpdate()` | L'aiguillage vers l'une des quatre méthodes. |
|
||||
| `UpdateManager::stagedInstallScript()` | L'installation fichier par fichier, via un temporaire renommé. |
|
||||
| `UpdateManager::dependencyInstallScript()` | L'installation des paquets manquants (depuis 1.5.0). |
|
||||
| `UpdateManager::restartProgram()` | Le binaire sur lequel redémarrer après l'installation. |
|
||||
| `MainWindow::onCoreUpdateCheckFinished()` | Le dialogue « mise à jour disponible », le mot de passe et le lancement. |
|
||||
| `MainWindow::onCoreSelfUpdateFinished()` | Le redémarrage, ou l'échec consigné dans le journal. |
|
||||
@@ -31,6 +31,35 @@ la base pacman et à l'attente de l'utilisateur.
|
||||
détails invalidé, identifiants éventuellement oubliés, puis
|
||||
`actionFinished(...)`. Les écrans se rafraîchissent sur ce signal.
|
||||
|
||||
## La trace des fournisseurs
|
||||
|
||||
Le journal ne dit pas seulement qu'une opération a réussi ou échoué : il montre
|
||||
**ce que les outils ont réellement exécuté**. Chaque fournisseur rapporte ses
|
||||
commandes et ses décisions par un petit point d'entrée sans Qt,
|
||||
`include/sdk/provider-trace.h` :
|
||||
|
||||
```cpp
|
||||
provider_trace::report("pacman", "$ sudo pacman -S --noconfirm vlc");
|
||||
```
|
||||
|
||||
Le fournisseur ignore où va le message ; `AppCore` installe le récepteur au
|
||||
moment où il est construit et le route vers `LogManager`. C'est ce qui garde la
|
||||
couche logique sans dépendance à Qt Widgets (voir
|
||||
[architecture.md](architecture.md)) tout en remplissant le journal.
|
||||
|
||||
Ce qui apparaît ainsi dans `operations.log` et dans l'écran **Logs** :
|
||||
|
||||
| Trace | Quand |
|
||||
| --- | --- |
|
||||
| `$ <commande>` | Avant chaque commande lancée (`pacman -Ss`, `flatpak install`…). |
|
||||
| `$ sudo <commande>` | Avant une opération privilégiée ; **le mot de passe n'est jamais tracé**, seulement la commande. |
|
||||
| `cache · <commande>` | Quand une lecture pacman coûteuse est servie par le cache de 10 s au lieu d'être relancée. |
|
||||
| Les compteurs de résultats | Après une recherche ou une liste (`-Ss`, `-Q`, `-Qu`, `flatpak search`…). |
|
||||
| Les décisions du fournisseur | Dépôt ajouté, repli en installation utilisateur, application déjà installée ignorée, copies ambiguës résolues. |
|
||||
|
||||
Un utilisateur qui ouvre une issue peut donc recopier la ligne `$ …` et rejouer
|
||||
la commande à la main dans un terminal, sans deviner ce que l'application a fait.
|
||||
|
||||
## Identifiants sudo
|
||||
|
||||
| Mode | Réglage | Comportement |
|
||||
|
||||
+9
-2
@@ -81,7 +81,7 @@ l'outil »** : le plugin dit par exemple `"flatpak"`, et l'application lance
|
||||
## Écrire un fournisseur
|
||||
|
||||
Un fournisseur implémente `IPackageManager` (`include/sdk/package-manager.h`).
|
||||
Copiez `plugins/example-provider/example-provider.cpp` comme point de départ.
|
||||
Copiez `providers/example-provider/example-provider.cpp` comme point de départ.
|
||||
|
||||
| Méthode | Obligatoire | Rôle |
|
||||
| --- | --- | --- |
|
||||
@@ -96,6 +96,7 @@ Copiez `plugins/example-provider/example-provider.cpp` comme point de départ.
|
||||
| `canListCleanup()`, `listCleanupCandidates()`, `canCleanCache()`, `cleanCache()` | non | Page Nettoyage. Un fournisseur qui ne les implémente pas est simplement ignoré. |
|
||||
| `removePackages(names, callback)` | non | Suppression groupée en une commande. Le défaut (un `remove()` par entrée) convient aux `target` d'un paquet installé plusieurs fois (voir plus bas). |
|
||||
| `canInstallFile(path)`, `installFile(path, callback)` | non | Installation depuis un fichier du bureau (glisser-déposer, « Ouvrir avec PacManager »). Le fournisseur ne revendique que **ses** formats : Flatpak accepte `.flatpakref`, `.flatpakrepo` et `.flatpak`, et ignore le reste. |
|
||||
| `fileTargetName(path)`, `isPackageInstalled(name)` | non | L'application qu'un fichier installerait, et si elle est déjà là. Lue dans le fichier sans rien exécuter (section `[Flatpak Ref]` d'une référence, en-tête d'un bundle), pour refuser un fichier déjà installé au lieu de lancer une installation qui ne ferait rien. Une chaîne vide (dépôt, format inconnu, fichier illisible) signifie « rien à comparer » : le fichier s'installe normalement. |
|
||||
|
||||
`update("")` signifie **tout mettre à jour** : c'est ce que le worker appelle pour
|
||||
l'opération globale.
|
||||
@@ -151,6 +152,12 @@ bool MyManager::update(const std::string& package, ProgressCallback cb) {
|
||||
`output` reste la sortie complète de la commande : c'est elle qu'on inspecte
|
||||
après coup pour décider du succès et remplir `lastError()`.
|
||||
|
||||
Un fournisseur peut aussi **tracer ce qu'il exécute** dans le journal, sans
|
||||
connaître la couche qui l'écrit : `provider_trace::report("montool", "$ montool
|
||||
upgrade …")` (`include/sdk/provider-trace.h`). C'est ce qui donne à l'écran Logs
|
||||
les vraies lignes de commande (voir [operations.md](operations.md)) ; un
|
||||
fournisseur peut l'ignorer sans rien casser.
|
||||
|
||||
### Positionner l'origine d'un paquet
|
||||
|
||||
`PackageInfo.provider` est renseigné automatiquement par les workers avec
|
||||
@@ -169,7 +176,7 @@ Une extension implémente `IPlugin` (`include/sdk/plugin.h`) :
|
||||
| `isAvailable()` | À l'affichage | `true` par défaut ; à surcharger si l'extension dépend d'un outil. |
|
||||
| `onUiReady(QMainWindow*)` | Une fois la fenêtre créée | Attacher ses widgets (barre de statut, boutons…). Appelé à nouveau si l'extension est réactivée en cours de session. |
|
||||
|
||||
Copiez `plugins/example-addon/example-addon.cpp` : il ajoute un badge dans la
|
||||
Copiez `providers/example-addon/example-addon.cpp` : il ajoute un badge dans la
|
||||
barre de statut et le retire proprement au déchargement.
|
||||
|
||||
## Compiler et installer un plugin
|
||||
|
||||
+20
-11
@@ -16,16 +16,18 @@ lance qu'une partie (`ctest -R progress`).
|
||||
| Cible | Ce qu'elle couvre | Dépendances |
|
||||
| --- | --- | --- |
|
||||
| `pacman-manager-test` | Parsing de la sortie pacman : listes, mises à jour, orphelins/étrangers, commandes construites (`removePackagesCommand`, `cleanCacheCommand`) et détection des échecs (mot de passe, verrou). | Aucune (pas de pacman). |
|
||||
| `flatpak-manager-test` | Parsing de la sortie Flatpak : recherche, listes, colonnes ; reconnaissance des formats de fichier (`.flatpakref`, `.flatpakrepo`, `.flatpak`, casse et URL) et commandes construites pour l'installation depuis un fichier (chemins entre guillemets compris) ; **installations multiples** : chaque copie nommée (`<installation>:<ref>`, version absente qui ne décale pas les colonnes), copies conservées après fusion des lignes, commandes de désinstallation et de mise à jour ciblant une copie. | Aucune. |
|
||||
| `flatpak-manager-test` | Parsing de la sortie Flatpak : recherche, listes, colonnes ; reconnaissance des formats de fichier (`.flatpakref`, `.flatpakrepo`, `.flatpak`, casse et URL) et commandes construites pour l'installation depuis un fichier (chemins entre guillemets compris) ; **installations multiples** : chaque copie nommée (`<installation>:<ref>`, version absente qui ne décale pas les colonnes), copies conservées après fusion des lignes, commandes de désinstallation et de mise à jour ciblant une copie ; **ce qu'un fichier installerait** : application lue dans la section `[Flatpak Ref]` d'un `.flatpakref` et dans l'en-tête d'un `.flatpak` (octets réels d'un bundle), refus d'un nom absent, d'un identifiant non conforme (injection comprise), d'une magie absente ou d'un en-tête tronqué. | Aucune. |
|
||||
| `flatpak-integration-test` | **Le vrai CLI flatpak** : installation et désinstallation d'une petite application, liste, recherche, mise à jour — donc aussi le `DownloadWatcher` en conditions réelles. | `flatpak` (le test se saute s'il est absent). |
|
||||
| `aur-manager-test` | Parsing du helper AUR (yay/paru) et nettoyage des séquences ANSI. | Aucune. |
|
||||
| `package-utils-test` | Logique partagée de `package-manager.h` : fusion des doublons entre fournisseurs, tri par fournisseur puis par nom. | Aucune. |
|
||||
| `progress-tracker-test` | `ProgressTracker` : compteurs pacman/Flatpak, pourcentages seuls, phases pondérées, étapes non identifiables, monotonie, faux positifs ; exécution d'une commande (`/bin/sh` en une ligne) : suppression des séquences ANSI, remontage d'une sortie au fil de l'eau, dernière ligne sans retour à la ligne, jalons de progression d'une jauge « sur place ». | Aucune, **même pas Qt**. |
|
||||
| `plugin-package-test` | Le format `.fwspacm` : lecture d'une archive valide, les deux méthodes de compression, refus d'un manifeste illisible / sans `id` / d'un format inconnu / d'une bibliothèque absente ou à nom dangereux, somme de contrôle non conforme, bibliothèque vide ; recherche de la bibliothèque par suffixe et ambiguïté ; installation, réinstallation, désinstallation, et le fait qu'une bibliothèque copiée à la main n'est jamais supprimée. | Qt Core + zlib, aucun accès réseau. |
|
||||
| `app-core-test` | La couche logique : portes d'entrée (opération en cours, mot de passe, providers), file d'attente des listes, historique, mode d'identification, refus d'un fichier qu'aucun fournisseur ne sait installer ; **porte du mot de passe** : chaque chemin privilégié (install, suppression, mise à jour, globale, rafraîchissement, caches, nettoyage groupé, suppression d'une ou de plusieurs installations, libération du verrou) s'arrête là, sans lancer de commande, et sa demande reste rejouable. | Qt Core seulement — **pas** QtWidgets. |
|
||||
| `app-core-test` | La couche logique : portes d'entrée (opération en cours, mot de passe, providers), file d'attente des listes, historique, mode d'identification, refus d'un fichier qu'aucun fournisseur ne sait installer, et `fileTarget()` — un fichier illisible ou qu'aucun fournisseur ne revendique ne nomme rien, donc n'est jamais refusé à tort ; **porte du mot de passe** : chaque chemin privilégié (install, suppression, mise à jour, globale, rafraîchissement, caches, nettoyage groupé, suppression d'une ou de plusieurs installations, libération du verrou) s'arrête là, sans lancer de commande, et sa demande reste rejouable. | Qt Core seulement — **pas** QtWidgets. |
|
||||
| `update-manager-test` | Comparaison de versions, choix de la méthode de mise à jour, et le script d'installation, exécuté pour de vrai contre un binaire en cours d'exécution. | Qt Core + Network. |
|
||||
| `startup-check-test` | La **vérification au démarrage** : parsing des deux formats (`checkupdates` puis le repli `pacman -Qu`), classement d'un paquet comme critique ou nécessitant un redémarrage, texte de la notification (dont le plafond des paquets cités), et l'unité systemd écrite **dans une arborescence temporaire** — installation, activation, suppression — jamais dans le `~/.config` de l'utilisateur. | Qt Core seulement. |
|
||||
| `language-manager-test` | La langue : ce que le réglage résout (un code connu, un code inconnu, « système » suivant `LC_ALL`/`LC_MESSAGES`/`LANG` puis `/etc/locale.conf`, le suffixe `@mod` ignoré, une locale non couverte qui retombe sur la langue d'écriture) ; le catalogue JSON en'core (installé, chaîne traduite, chaîne inconnue qui retombe sur la source, une clé seule servie à tous les contextes) ; un catalogue cassé ou sans chaîne **refusé**, l'interface restant entière ; et la couverture : le catalogue anglais doit contenir **toute** chaîne que le code demande, sinon une chaîne se lirait en français dans une interface anglaise. | Qt Core + les ressources, aucun affichage. |
|
||||
| `app-settings-test` | Les préférences : valeurs par défaut, valeurs refusées (dossier vide, langue inconnue, taille de journal aberrante), persistance après relecture, un réglage qui n'émet que s'il change, la politique de blocage des mises à jour (durée, expiration, indefini) et — pour de vrai — le **journal** : il atterrit dans le dossier choisi, accompagne un changement de dossier, tourne au plafond de taille et garde une version précédente. | Qt Core seulement. |
|
||||
| `app-settings-test` | Les préférences : valeurs par défaut, valeurs refusées (dossier vide, langue inconnue, taille de journal aberrante), persistance après relecture, un réglage qui n'émet que s'il change, la politique de blocage des mises à jour (durée, expiration, indefini) et — pour de vrai — le **journal** : il atterrit dans le dossier choisi, accompagne un changement de dossier, tourne au plafond de taille et garde une version précédente ; le bavardage de la couche graphique de Qt (`qt.qpa.*`) reste sur la sortie standard au lieu de le remplir, alors que les alertes de l'application (et une `qCWarning` sans catégorie) y sont. | Qt Core seulement. |
|
||||
| `cli-command-test` | La **grammaire de la ligne de commande** : ce qui demande la CLI plutôt que la fenêtre (mot-clé ou option, contre un chemin ou un fichier `.flatpak`/`.fwspacm`) et ce que chaque mot-clé donne — recherche à plusieurs mots, install/suppression de plusieurs paquets, `maj` avec ou sans nom, commandes de lecture sans argument, `-y` lu partout, `--help`/`--version` prioritaires, commande ou option inconnue. | Qt Core seulement, rien n'est lancé. |
|
||||
|
||||
### Pourquoi `app-core-test` ne lie pas QtWidgets
|
||||
|
||||
@@ -63,8 +65,8 @@ est donc autant une vérification de comportement qu'un garde-fou d'architecture
|
||||
2. Déclarer la cible dans `CMakeLists.txt` :
|
||||
|
||||
```cmake
|
||||
add_executable(mon-sujet-test tests/mon-sujet.test.cpp src/ce-qu-il-test.cpp)
|
||||
target_include_directories(mon-sujet-test PRIVATE include)
|
||||
add_executable(mon-sujet-test tests/mon-sujet.test.cpp core/ce-qu-il-test.cpp)
|
||||
target_include_directories(mon-sujet-test PRIVATE include include/sdk)
|
||||
target_link_libraries(mon-sujet-test PRIVATE Qt6::Core) # si nécessaire
|
||||
add_test(NAME mon-sujet-test COMMAND mon-sujet-test)
|
||||
```
|
||||
@@ -72,20 +74,27 @@ est donc autant une vérification de comportement qu'un garde-fou d'architecture
|
||||
3. Deux pièges rencontrés dans ce projet :
|
||||
|
||||
- **AUTOMOC** : un en-tête contenant `Q_OBJECT` doit être **listé dans les
|
||||
sources de la cible de test** (`include/mon-sujet.h`), sinon la cible ne
|
||||
sources de la cible de test** (`core/mon-sujet.h`), sinon la cible ne
|
||||
trouve ni `staticMetaObject` ni la vtable ;
|
||||
- **la couche logique** : si la cible teste `AppCore`, elle doit compiler tout
|
||||
ce que `app-core.cpp` utilise (`workers.cpp`, `pacman-manager.cpp`,
|
||||
`plugin-manager.cpp`, `history-manager.cpp`, `update-manager.cpp`,
|
||||
`plugin-package.cpp`, `zip-archive.cpp`, `app-logging.cpp`).
|
||||
ce que `app-core.cpp` utilise (`core/workers.cpp`,
|
||||
`providers/pacman-manager.cpp`, `plugins/plugin-manager.cpp`,
|
||||
`history/history-manager.cpp`, `update/update-manager.cpp`,
|
||||
`plugins/plugin-package.cpp`, `archive/zip-archive.cpp`,
|
||||
`logging/app-logging.cpp`, `logging/log-manager.cpp`,
|
||||
`preferences/app-settings.cpp`) et **lister les en-têtes `Q_OBJECT`** pour
|
||||
AUTOMOC ; la cible `app-core-test` de `CMakeLists.txt` en donne un exemple
|
||||
complet.
|
||||
|
||||
## Ce qui n'est pas testé
|
||||
|
||||
- L'interface, y compris le glisser-déposer sur la fenêtre (fichiers Flatpak et
|
||||
paquets `.fwspacm`) : elle est vérifiée à la main (`./build/PacManager`). Le
|
||||
reste du chemin est couvert (reconnaissance des formats, refus d'un fichier
|
||||
inconnu, lecture d'un paquet, commandes construites) ; seul le geste de la
|
||||
souris ne l'est pas. Un aperçu
|
||||
inconnu, lecture d'un paquet, commandes construites, application visée par le
|
||||
fichier et présence sur la machine) ; seul le geste de la souris et les deux
|
||||
boîtes de dialogue qui y répondent (prise en compte, déjà installé) ne sont
|
||||
pas automatisés. Un aperçu
|
||||
hors écran reste possible en rendant la fenêtre avec
|
||||
`QT_QPA_PLATFORM=offscreen`, ce qui est utile pour vérifier une feuille de style
|
||||
(aucune alerte de parsing, couleurs attendues) sans écran.
|
||||
|
||||
@@ -236,6 +236,26 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
// The application a file would install, as this provider names it
|
||||
// internally ("com.example.App" for flatpak): a reference file spells it
|
||||
// out, a bundle embeds it. Empty when the format is not this provider's,
|
||||
// when the file names no single application (a .flatpakrepo only defines a
|
||||
// remote), or when nothing can be read from it. Read without running
|
||||
// anything, so the app can tell the user a file is already installed
|
||||
// instead of starting an install that would do nothing.
|
||||
virtual std::string fileTargetName(const std::string& path) const {
|
||||
(void)path;
|
||||
return {};
|
||||
}
|
||||
|
||||
// Whether the provider already has that application, in any of its
|
||||
// installations. A single lookup through the provider's own tool, cheap
|
||||
// enough to run while the user is dropping a file.
|
||||
virtual bool isPackageInstalled(const std::string& packageName) const {
|
||||
(void)packageName;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the package manager is available on the system
|
||||
virtual bool isAvailable() const = 0;
|
||||
|
||||
|
||||
+25
-14
@@ -229,6 +229,13 @@ bool LogManager::hasEntries() const {
|
||||
return !readFile().isEmpty();
|
||||
}
|
||||
|
||||
bool LogManager::journalsQtCategory(const QString& category) {
|
||||
// Only the platform plugin is filtered. A category the application chose
|
||||
// (pacmgr.*, the "default" one a bare qCWarning carries) describes what the
|
||||
// app did and stays in the journal.
|
||||
return !category.startsWith(QStringLiteral("qt.qpa"));
|
||||
}
|
||||
|
||||
void LogManager::installQtMessageHandler() {
|
||||
// Make sure the singleton is created on the calling (main) thread before any
|
||||
// worker emits a log message.
|
||||
@@ -237,23 +244,27 @@ void LogManager::installQtMessageHandler() {
|
||||
qInstallMessageHandler([](QtMsgType type, const QMessageLogContext& context,
|
||||
const QString& message) {
|
||||
// Keep the usual console output too, so a developer still sees the logs
|
||||
// in a terminal.
|
||||
const char* category = context.category ? context.category : "default";
|
||||
std::fprintf(stderr, "[%s] %s\n", category, message.toLocal8Bit().constData());
|
||||
// in a terminal — including the platform chatter the journal leaves
|
||||
// out.
|
||||
const char* rawCategory = context.category ? context.category : "default";
|
||||
std::fprintf(stderr, "[%s] %s\n", rawCategory, message.toLocal8Bit().constData());
|
||||
|
||||
QString level;
|
||||
switch (type) {
|
||||
case QtDebugMsg: level = QStringLiteral("debug"); break;
|
||||
case QtInfoMsg: level = QStringLiteral("info"); break;
|
||||
case QtWarningMsg: level = QCoreApplication::translate("LogManager", "avertissement"); break;
|
||||
case QtCriticalMsg: level = QCoreApplication::translate("LogManager", "critique"); break;
|
||||
case QtFatalMsg: level = QStringLiteral("fatal"); break;
|
||||
const QString category = QString::fromLatin1(rawCategory);
|
||||
if (journalsQtCategory(category)) {
|
||||
QString level;
|
||||
switch (type) {
|
||||
case QtDebugMsg: level = QStringLiteral("debug"); break;
|
||||
case QtInfoMsg: level = QStringLiteral("info"); break;
|
||||
case QtWarningMsg: level = QCoreApplication::translate("LogManager", "avertissement"); break;
|
||||
case QtCriticalMsg: level = QCoreApplication::translate("LogManager", "critique"); break;
|
||||
case QtFatalMsg: level = QStringLiteral("fatal"); break;
|
||||
}
|
||||
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("qt/%1").arg(category),
|
||||
QStringLiteral("%1: %2").arg(level, message));
|
||||
}
|
||||
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("qt/%1").arg(QString::fromLatin1(category)),
|
||||
QStringLiteral("%1: %2").arg(level, message));
|
||||
|
||||
if (type == QtFatalMsg) std::abort();
|
||||
});
|
||||
}
|
||||
+12
-1
@@ -33,7 +33,9 @@
|
||||
//
|
||||
// Every Qt log message (qCDebug/qCInfo/qCWarning/qCCritical) is funnelled into
|
||||
// the same journal by installQtMessageHandler(), so the categories already used
|
||||
// across the code base feed it without extra plumbing.
|
||||
// across the code base feed it without extra plumbing. Qt's own platform
|
||||
// categories (`qt.qpa.*`) are the one exception: they describe the display
|
||||
// server, not the application, and stay on stderr (see journalsQtCategory).
|
||||
//
|
||||
// The file lives in the user's own data tree (XDG_CONFIG_HOME / home) so it is
|
||||
// never lost when a sandbox is rebuilt, and both that directory and a size cap
|
||||
@@ -87,6 +89,15 @@ public:
|
||||
// QApplication exists. Safe to call more than once.
|
||||
static void installQtMessageHandler();
|
||||
|
||||
// Whether a Qt log category belongs in the journal at all. Qt's platform
|
||||
// plugins (`qt.qpa.*`: xcb, wayland, ...) narrate the display server, not
|
||||
// the application: the Wayland one, for instance, repeats a warning about
|
||||
// its text-input focus for every dialog the user opens, which is a line the
|
||||
// user can neither read nor act on. Those keep going to stderr, where a
|
||||
// developer looks for them; everything the application itself logs — its
|
||||
// own categories, and a bare qCWarning — still lands in the journal.
|
||||
static bool journalsQtCategory(const QString& category);
|
||||
|
||||
signals:
|
||||
// The journal changed on disk and a fresh copy of its content is available.
|
||||
void fileUpdated();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
@@ -363,6 +364,15 @@ static bool endsWith(const std::string& text, const std::string& suffix) {
|
||||
&& text.compare(text.size() - suffix.size(), suffix.size(), suffix) == 0;
|
||||
}
|
||||
|
||||
// Leading and trailing blanks removed, for the INI lines of a .flatpakref.
|
||||
static std::string trimmed(const std::string& text) {
|
||||
std::size_t begin = 0;
|
||||
std::size_t end = text.size();
|
||||
while (begin < end && std::isspace(static_cast<unsigned char>(text[begin]))) ++begin;
|
||||
while (end > begin && std::isspace(static_cast<unsigned char>(text[end - 1]))) --end;
|
||||
return text.substr(begin, end - begin);
|
||||
}
|
||||
|
||||
// Quote one argument for the shell popen() runs, so a dropped file whose name
|
||||
// contains spaces or quotes still reaches flatpak as a single argument.
|
||||
static std::string shellQuote(const std::string& value) {
|
||||
@@ -536,6 +546,88 @@ std::string FlatpakManager::repoNamespace(const std::string& path) {
|
||||
return name.empty() ? "flatpak-repo" : name;
|
||||
}
|
||||
|
||||
std::string FlatpakManager::appIdFromRef(const std::string& ref) {
|
||||
const std::size_t typeEnd = ref.find('/');
|
||||
if (typeEnd == std::string::npos) return {};
|
||||
const std::size_t idEnd = ref.find('/', typeEnd + 1);
|
||||
if (idEnd == std::string::npos) return {};
|
||||
|
||||
// A ref is "<kind>/<id>/<arch>/<branch>", and only the two kinds flatpak
|
||||
// installs name an application here.
|
||||
const std::string kind = ref.substr(0, typeEnd);
|
||||
if (kind != "app" && kind != "runtime") return {};
|
||||
|
||||
const std::string id = ref.substr(typeEnd + 1, idEnd - typeEnd - 1);
|
||||
return isAppId(id) ? id : std::string();
|
||||
}
|
||||
|
||||
std::string FlatpakManager::appIdFromRefFile(const std::string& path) {
|
||||
std::ifstream file(path);
|
||||
if (!file) return {};
|
||||
|
||||
// A .flatpakref is an INI file whose [Flatpak Ref] section names the
|
||||
// application flatpak will resolve (`Name=com.example.App`); the rest of it
|
||||
// describes the remote. Only that section is read.
|
||||
bool inRefSection = false;
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
const std::string text = trimmed(line);
|
||||
if (text.empty() || text[0] == '#' || text[0] == ';') continue;
|
||||
if (text[0] == '[') {
|
||||
inRefSection = toLower(text) == "[flatpak ref]";
|
||||
continue;
|
||||
}
|
||||
if (!inRefSection) continue;
|
||||
|
||||
const std::size_t equals = text.find('=');
|
||||
if (equals == std::string::npos) continue;
|
||||
if (toLower(trimmed(text.substr(0, equals))) != "name") continue;
|
||||
|
||||
// Refused rather than handed back when it is not an application id:
|
||||
// this comes straight out of a file the user dropped, and the caller
|
||||
// passes it to flatpak.
|
||||
const std::string id = trimmed(text.substr(equals + 1));
|
||||
return isAppId(id) ? id : std::string();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string FlatpakManager::appIdFromBundle(const std::string& path) {
|
||||
// A bundle opens with a header of its own: the magic, then the exact ref it
|
||||
// installs and the application metadata, both NUL-terminated. The header is
|
||||
// all that is read — the payload behind it weighs tens of megabytes and
|
||||
// nothing there would answer the question.
|
||||
std::ifstream file(path, std::ios::binary);
|
||||
if (!file) return {};
|
||||
|
||||
std::array<char, 8192> buffer{};
|
||||
file.read(buffer.data(), static_cast<std::streamsize>(buffer.size()));
|
||||
const std::string header(buffer.data(), static_cast<std::size_t>(file.gcount()));
|
||||
|
||||
const std::string magic("flatpak\0", 8);
|
||||
if (header.size() <= magic.size() || header.compare(0, magic.size(), magic) != 0) {
|
||||
// An OCI bundle, or a file that is not one: nothing is guessed at, so
|
||||
// the caller installs it the ordinary way.
|
||||
return {};
|
||||
}
|
||||
|
||||
// The ref sits behind a "ref" key. Skipping the framing between the two —
|
||||
// flatpak writes sizes there of its own choosing — is what keeps this
|
||||
// readable across the versions of the format.
|
||||
const std::string key("ref\0", 4);
|
||||
for (std::size_t at = header.find(key, magic.size()); at != std::string::npos;
|
||||
at = header.find(key, at + key.size())) {
|
||||
std::size_t value = at + key.size();
|
||||
while (value < header.size() && header[value] == '\0') ++value;
|
||||
const std::size_t end = header.find('\0', value);
|
||||
if (end == std::string::npos) break;
|
||||
|
||||
const std::string id = appIdFromRef(header.substr(value, end - value));
|
||||
if (!id.empty()) return id;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string FlatpakManager::installFileCommand(FileKind kind, const std::string& path,
|
||||
bool userScope) {
|
||||
const std::string scope = userScope ? "--user " : "";
|
||||
@@ -642,7 +734,7 @@ std::vector<PackageInfo> FlatpakManager::listUpdates() {
|
||||
return results;
|
||||
}
|
||||
|
||||
bool FlatpakManager::isInstalled(const std::string& appId) {
|
||||
bool FlatpakManager::isInstalled(const std::string& appId) const {
|
||||
std::string cmd = "flatpak info " + appId + " > /dev/null 2>&1";
|
||||
return system(cmd.c_str()) == 0;
|
||||
}
|
||||
@@ -942,6 +1034,22 @@ bool FlatpakManager::canInstallFile(const std::string& path) const {
|
||||
return classifyFile(path) != FileKind::None;
|
||||
}
|
||||
|
||||
// What the user is about to install, named the way flatpak names it. A
|
||||
// `.flatpakrepo` answers nothing: it registers a remote and installs no
|
||||
// application, so there is nothing that could already be there.
|
||||
std::string FlatpakManager::fileTargetName(const std::string& path) const {
|
||||
switch (classifyFile(path)) {
|
||||
case FileKind::Ref: return appIdFromRefFile(path);
|
||||
case FileKind::Bundle: return appIdFromBundle(path);
|
||||
default: return {};
|
||||
}
|
||||
}
|
||||
|
||||
bool FlatpakManager::isPackageInstalled(const std::string& packageName) const {
|
||||
if (packageName.empty()) return false;
|
||||
return isInstalled(packageName);
|
||||
}
|
||||
|
||||
bool FlatpakManager::installFile(const std::string& path,
|
||||
ProgressCallback progressCallback) {
|
||||
m_lastError.clear();
|
||||
|
||||
@@ -66,6 +66,18 @@ public:
|
||||
// types in `flatpak install <name> <app>`.
|
||||
static std::string repoNamespace(const std::string& path);
|
||||
|
||||
// Application a file would install. A `.flatpakref` spells it out in its
|
||||
// `[Flatpak Ref]` section; a `.flatpak` bundle carries the exact ref it
|
||||
// installs in its own header. Both are read without running flatpak — the
|
||||
// file is already on disk — so the answer is available before anything is
|
||||
// started. Empty when the file names no application or cannot be read, in
|
||||
// which case the caller simply installs it.
|
||||
static std::string appIdFromRefFile(const std::string& path);
|
||||
static std::string appIdFromBundle(const std::string& path);
|
||||
// The application id inside a ref ("app/com.example.App/x86_64/stable" ->
|
||||
// "com.example.App"). Empty when the string is not a ref.
|
||||
static std::string appIdFromRef(const std::string& ref);
|
||||
|
||||
std::vector<PackageInfo> search(const std::string& query) override;
|
||||
bool install(const std::string& packageName,
|
||||
ProgressCallback progressCallback) override;
|
||||
@@ -88,6 +100,8 @@ public:
|
||||
// URL, so flatpak resolves the remote itself.
|
||||
bool canInstallFile(const std::string& path) const override;
|
||||
bool installFile(const std::string& path, ProgressCallback progressCallback) override;
|
||||
std::string fileTargetName(const std::string& path) const override;
|
||||
bool isPackageInstalled(const std::string& packageName) const 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
|
||||
@@ -102,7 +116,9 @@ public:
|
||||
void integrateAllInstalled();
|
||||
|
||||
private:
|
||||
bool isInstalled(const std::string& appId);
|
||||
// Whether that application is deployed, in any installation (flatpak info
|
||||
// looks them all up). Exposed through isPackageInstalled().
|
||||
bool isInstalled(const std::string& appId) const;
|
||||
|
||||
std::string m_lastError;
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QStringList>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
@@ -252,6 +253,35 @@ void testDatabaseLockIsQueryable() {
|
||||
}
|
||||
}
|
||||
|
||||
// What a file the user drops would install. Only the half that needs no
|
||||
// provider is asserted here (the Flatpak side is covered by that provider's own
|
||||
// test, on the bytes a bundle really carries): an unreadable package names
|
||||
// nothing, so the window installs it and lets the reader report the reason.
|
||||
void testFileTargetAnswersNothingForWhatItCannotRead() {
|
||||
AppCore core;
|
||||
|
||||
assert(core.fileTarget(QString()).name.isEmpty());
|
||||
assert(!core.fileTarget(QString()).installed);
|
||||
assert(!core.fileTarget(QStringLiteral(" ")).installed);
|
||||
// No provider claims a text document, so there is nothing to name.
|
||||
assert(core.fileTarget(QStringLiteral("/tmp/liste-de-courses.txt")).name.isEmpty());
|
||||
|
||||
QTemporaryDir dir;
|
||||
assert(dir.isValid());
|
||||
const QString broken = dir.filePath(QStringLiteral("casse.fwspacm"));
|
||||
QFile file(broken);
|
||||
assert(file.open(QIODevice::WriteOnly));
|
||||
file.write("pas une archive");
|
||||
file.close();
|
||||
|
||||
const AppCore::FileTarget target = core.fileTarget(broken);
|
||||
assert(target.name.isEmpty());
|
||||
assert(!target.installed);
|
||||
// It is still a plugin package by its name, which is what the window asks
|
||||
// next before handing it to the installer.
|
||||
assert(core.isPluginPackage(broken));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
@@ -282,6 +312,7 @@ int main(int argc, char* argv[]) {
|
||||
testLogReadReportsItsFailure();
|
||||
testUpdateStateIsReadableWithoutRunningAnything();
|
||||
testDatabaseLockIsQueryable();
|
||||
testFileTargetAnswersNothingForWhatItCannotRead();
|
||||
|
||||
std::cout << "app-core: all tests passed" << std::endl;
|
||||
return 0;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QLoggingCategory>
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
@@ -271,6 +272,43 @@ void testJournalMovesAndRotates() {
|
||||
assert(journal.currentSizeBytes() > before);
|
||||
}
|
||||
|
||||
// Qt's platform plugins narrate the display server, not the application: the
|
||||
// Wayland text-input warning, for one, repeats for every dialog the user opens,
|
||||
// and a journal full of it is unreadable. Those categories stay on stderr; what
|
||||
// the application logs — its own categories, and the "default" one a bare
|
||||
// qCWarning carries — still lands in the journal.
|
||||
void testPlatformChatterStaysOutOfTheJournal() {
|
||||
// The decision itself first, so the test says which side a category is on
|
||||
// even when nothing is written.
|
||||
assert(LogManager::journalsQtCategory(QStringLiteral("default")));
|
||||
assert(LogManager::journalsQtCategory(QStringLiteral("pacmgr.update")));
|
||||
assert(LogManager::journalsQtCategory(QStringLiteral("qt.sql")));
|
||||
assert(!LogManager::journalsQtCategory(QStringLiteral("qt.qpa.wayland.textinput")));
|
||||
assert(!LogManager::journalsQtCategory(QStringLiteral("qt.qpa.xcb")));
|
||||
|
||||
resetSettings();
|
||||
AppSettings& prefs = AppSettings::instance();
|
||||
const QString dir = QDir::homePath() + QStringLiteral("/journal-c");
|
||||
QFile::remove(dir + QStringLiteral("/operations.log"));
|
||||
prefs.setLogDirectory(dir);
|
||||
prefs.setLogMaxBytes(0);
|
||||
|
||||
LogManager::installQtMessageHandler();
|
||||
LogManager& journal = LogManager::instance();
|
||||
|
||||
// An event the application writes, then the warning Qt's Wayland plugin
|
||||
// repeats: the first must be in the journal, the second must not.
|
||||
journal.logEvent(QStringLiteral("ui"), QStringLiteral("mot de passe fourni"));
|
||||
qCWarning(QLoggingCategory("qt.qpa.wayland.textinput"))
|
||||
<< "Trying to disable 0x1 but 0x2 is focused";
|
||||
qCWarning(QLoggingCategory("pacmgr.update")) << "une alerte de l'application";
|
||||
|
||||
const QString content = journal.readFile();
|
||||
assert(content.contains(QStringLiteral("mot de passe fourni")));
|
||||
assert(content.contains(QStringLiteral("une alerte de l'application")));
|
||||
assert(!content.contains(QStringLiteral("Trying to disable")));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
@@ -299,6 +337,7 @@ int main(int argc, char* argv[]) {
|
||||
testUpdateBlockIsPersistedAndCleared();
|
||||
testAutomaticCheckCanBeTurnedOff();
|
||||
testJournalMovesAndRotates();
|
||||
testPlatformChatterStaysOutOfTheJournal();
|
||||
|
||||
std::cout << "app-settings: all tests passed" << std::endl;
|
||||
return 0;
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
// Unit tests for the command-line grammar (cli/cli-command.*): which arguments
|
||||
// ask for the command line rather than the window, and what each keyword parses
|
||||
// into. Pure parsing — no package manager, no display, nothing spawned.
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "cli-command.h"
|
||||
|
||||
static QStringList args(std::initializer_list<const char*> words) {
|
||||
QStringList list;
|
||||
for (const char* word : words) list << QString::fromUtf8(word);
|
||||
return list;
|
||||
}
|
||||
|
||||
static void testInvocationRouting() {
|
||||
// No arguments, or a file the desktop handed over: the window is wanted.
|
||||
assert(!cli::isCliInvocation({}));
|
||||
assert(!cli::isCliInvocation(args({"/home/user/app.flatpak"})));
|
||||
assert(!cli::isCliInvocation(args({"app.flatpakref"})));
|
||||
assert(!cli::isCliInvocation(args({"./bundle.fwspacm"})));
|
||||
|
||||
// A keyword, or any leading option, is aimed at the command line.
|
||||
assert(cli::isCliInvocation(args({"recherche", "vlc"})));
|
||||
assert(cli::isCliInvocation(args({"install", "vlc"})));
|
||||
assert(cli::isCliInvocation(args({"search", "vlc"})));
|
||||
assert(cli::isCliInvocation(args({"--help"})));
|
||||
assert(cli::isCliInvocation(args({"-y", "install", "vlc"})));
|
||||
|
||||
// A bare word that is not a path is a mistyped command, not a file: the
|
||||
// command line reports it instead of opening a window that cannot use it.
|
||||
assert(cli::isCliInvocation(args({"frobnicate"})));
|
||||
}
|
||||
|
||||
static void testSearchParsing() {
|
||||
const cli::Parsed parsed = cli::parse(args({"recherche", "vlc"}));
|
||||
assert(parsed.command == cli::Command::Search);
|
||||
assert(parsed.operands == args({"vlc"}));
|
||||
|
||||
// The search word may hold spaces: the term is everything that follows.
|
||||
const cli::Parsed multi = cli::parse(args({"search", "gtk", "theme"}));
|
||||
assert(multi.command == cli::Command::Search);
|
||||
assert(multi.operands.join(QLatin1Char(' ')) == QLatin1String("gtk theme"));
|
||||
|
||||
// The keyword is not a search term on its own.
|
||||
const cli::Parsed missing = cli::parse(args({"recherche"}));
|
||||
assert(missing.command == cli::Command::Unknown);
|
||||
assert(!missing.error.isEmpty());
|
||||
}
|
||||
|
||||
static void testInstallAndRemoveParsing() {
|
||||
const cli::Parsed install = cli::parse(args({"install", "vlc"}));
|
||||
assert(install.command == cli::Command::Install);
|
||||
assert(install.operands == args({"vlc"}));
|
||||
|
||||
const cli::Parsed several = cli::parse(args({"installer", "vlc", "vim"}));
|
||||
assert(several.command == cli::Command::Install);
|
||||
assert(several.operands == args({"vlc", "vim"}));
|
||||
|
||||
const cli::Parsed remove = cli::parse(args({"supprimer", "-y", "vlc"}));
|
||||
assert(remove.command == cli::Command::Remove);
|
||||
assert(remove.assumeYes);
|
||||
assert(remove.operands == args({"vlc"}));
|
||||
|
||||
assert(cli::parse(args({"remove"})).command == cli::Command::Unknown);
|
||||
}
|
||||
|
||||
static void testUpdateParsing() {
|
||||
// No operand means everything; one operand means that package.
|
||||
const cli::Parsed all = cli::parse(args({"maj"}));
|
||||
assert(all.command == cli::Command::Update);
|
||||
assert(all.operands.isEmpty());
|
||||
|
||||
const cli::Parsed one = cli::parse(args({"update", "vlc"}));
|
||||
assert(one.command == cli::Command::Update);
|
||||
assert(one.operands == args({"vlc"}));
|
||||
|
||||
assert(cli::parse(args({"maj", "vlc", "vim"})).command == cli::Command::Unknown);
|
||||
}
|
||||
|
||||
static void testReadOnlyCommands() {
|
||||
assert(cli::parse(args({"liste"})).command == cli::Command::List);
|
||||
assert(cli::parse(args({"list"})).command == cli::Command::List);
|
||||
assert(cli::parse(args({"maj-dispo"})).command == cli::Command::Updates);
|
||||
assert(cli::parse(args({"cleanup"})).command == cli::Command::Cleanup);
|
||||
assert(cli::parse(args({"refresh"})).command == cli::Command::Refresh);
|
||||
|
||||
const cli::Parsed info = cli::parse(args({"info", "vlc"}));
|
||||
assert(info.command == cli::Command::Info);
|
||||
assert(info.operands == args({"vlc"}));
|
||||
assert(cli::parse(args({"info"})).command == cli::Command::Unknown);
|
||||
|
||||
// A listing takes no operand.
|
||||
assert(cli::parse(args({"liste", "vlc"})).command == cli::Command::Unknown);
|
||||
}
|
||||
|
||||
static void testHelpAndVersion() {
|
||||
assert(cli::parse(args({"--help"})).command == cli::Command::Help);
|
||||
assert(cli::parse(args({"aide"})).command == cli::Command::Help);
|
||||
// An option wins wherever it stands.
|
||||
assert(cli::parse(args({"install", "--help"})).command == cli::Command::Help);
|
||||
|
||||
assert(cli::parse(args({"--version"})).command == cli::Command::Version);
|
||||
assert(cli::parse(args({"-v"})).command == cli::Command::Version);
|
||||
|
||||
// The help names the keywords the parser accepts.
|
||||
assert(cli::helpText().contains(QLatin1String("recherche")));
|
||||
assert(cli::helpText().contains(QLatin1String("install")));
|
||||
}
|
||||
|
||||
static void testUnknownCommands() {
|
||||
const cli::Parsed word = cli::parse(args({"frobnicate"}));
|
||||
assert(word.command == cli::Command::Unknown);
|
||||
assert(word.error.contains(QLatin1String("frobnicate")));
|
||||
|
||||
const cli::Parsed option = cli::parse(args({"--nope"}));
|
||||
assert(option.command == cli::Command::Unknown);
|
||||
assert(option.error.contains(QLatin1String("--nope")));
|
||||
|
||||
// No argument at all is not an error: it is the window.
|
||||
assert(cli::parse({}).command == cli::Command::None);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
testInvocationRouting();
|
||||
testSearchParsing();
|
||||
testInstallAndRemoveParsing();
|
||||
testUpdateParsing();
|
||||
testReadOnlyCommands();
|
||||
testHelpAndVersion();
|
||||
testUnknownCommands();
|
||||
|
||||
std::cout << "All cli-command tests passed" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -1,6 +1,39 @@
|
||||
#include "flatpak-manager.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
// The parsers below read real files, so the tests write real bytes: a scratch
|
||||
// directory of our own in the system temp tree, never the user's home.
|
||||
static std::filesystem::path scratchDir() {
|
||||
std::error_code ec;
|
||||
const std::filesystem::path dir =
|
||||
std::filesystem::temp_directory_path(ec) / "pacmanager-flatpak-manager-test";
|
||||
std::filesystem::create_directories(dir, ec);
|
||||
return dir;
|
||||
}
|
||||
|
||||
static std::string writeScratch(const std::string& name, const std::string& bytes) {
|
||||
const std::filesystem::path path = scratchDir() / name;
|
||||
std::ofstream out(path, std::ios::binary | std::ios::trunc);
|
||||
out.write(bytes.data(), static_cast<std::streamsize>(bytes.size()));
|
||||
out.close();
|
||||
return path.string();
|
||||
}
|
||||
|
||||
// Bytes encoded the way a hex dump reads, so a fixture can be copied from the
|
||||
// real file it came from.
|
||||
static std::string fromHex(const std::string& hex) {
|
||||
std::string bytes;
|
||||
bytes.reserve(hex.size() / 2);
|
||||
for (std::size_t i = 0; i + 1 < hex.size(); i += 2) {
|
||||
bytes.push_back(static_cast<char>(std::stoi(hex.substr(i, 2), nullptr, 16)));
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
static void testParseSearchOutput_parsesAlignedRows() {
|
||||
std::string output =
|
||||
@@ -240,6 +273,153 @@ static void testUninstallCommand_stillAcceptsAnApplicationId() {
|
||||
assert(plain.find("--user") == std::string::npos);
|
||||
}
|
||||
|
||||
// ---- What a dropped file would install ----
|
||||
//
|
||||
// The window asks this before it runs anything, to refuse a file the machine
|
||||
// already has. Both answers are read out of the file itself: no flatpak call,
|
||||
// no network, and nothing guessed at.
|
||||
|
||||
static void testAppIdFromRefFile_readsTheNameField() {
|
||||
const std::string ref = writeScratch("org.gnome.Dictionary.flatpakref",
|
||||
"[Flatpak Ref]\n"
|
||||
"Title=Dictionary\n"
|
||||
"Name=org.gnome.Dictionary\n"
|
||||
"Branch=stable\n"
|
||||
"Url=https://dl.flathub.org/repo/\n"
|
||||
"SuggestRemoteName=flathub\n"
|
||||
"RuntimeRepo=https://dl.flathub.org/repo/flathub.flatpakrepo\n"
|
||||
"IsRuntime=false\n");
|
||||
assert(FlatpakManager::appIdFromRefFile(ref) == "org.gnome.Dictionary");
|
||||
|
||||
// A hand-written file: comments, blank lines, CRLF endings, spaces around
|
||||
// the separator, a lower-case section, and another section behind it whose
|
||||
// `Name` is not the application.
|
||||
const std::string spoken = writeScratch("spaced.flatpakref",
|
||||
"; written by hand\r\n"
|
||||
"\r\n"
|
||||
"[FLATPAK REF]\r\n"
|
||||
" Name = org.gnome.Calculator \r\n"
|
||||
"[Flatpak Repo]\n"
|
||||
"Name=org.example.NotTheApp\n");
|
||||
assert(FlatpakManager::appIdFromRefFile(spoken) == "org.gnome.Calculator");
|
||||
}
|
||||
|
||||
static void testAppIdFromRefFile_refusesWhatNamesNoApplication() {
|
||||
// The name is not in the ref section: a repository definition lists other
|
||||
// keys there, and reading one of them as the application would refuse an
|
||||
// install that has every right to run.
|
||||
const std::string repo = writeScratch("flathub.flatpakref",
|
||||
"[Flatpak Repo]\n"
|
||||
"Name=org.example.NotTheApp\n"
|
||||
"[Flatpak Ref]\n"
|
||||
"Branch=stable\n");
|
||||
assert(FlatpakManager::appIdFromRefFile(repo).empty());
|
||||
|
||||
// An id that is not one is refused rather than handed to flatpak: this came
|
||||
// straight out of a file the user dropped.
|
||||
const std::string injected = writeScratch("injected.flatpakref",
|
||||
"[Flatpak Ref]\n"
|
||||
"Name=org.example.App; rm -rf ~\n");
|
||||
assert(FlatpakManager::appIdFromRefFile(injected).empty());
|
||||
|
||||
// A file that is not there, an empty one, and one that is not a ref file.
|
||||
assert(FlatpakManager::appIdFromRefFile("/tmp/pacmgr-does-not-exist.flatpakref").empty());
|
||||
assert(FlatpakManager::appIdFromRefFile(writeScratch("empty.flatpakref", "")).empty());
|
||||
assert(FlatpakManager::appIdFromRefFile(writeScratch("junk.flatpakref", "garbage")).empty());
|
||||
}
|
||||
|
||||
static void testAppIdFromRef_stripsKindArchAndBranch() {
|
||||
assert(FlatpakManager::appIdFromRef("app/org.gnome.Calculator/x86_64/stable")
|
||||
== "org.gnome.Calculator");
|
||||
assert(FlatpakManager::appIdFromRef("runtime/org.freedesktop.Platform/x86_64/50")
|
||||
== "org.freedesktop.Platform");
|
||||
// A branch can carry a dash and a version, which is not part of the id.
|
||||
assert(FlatpakManager::appIdFromRef("app/org.winehq.Wine/x86_64/stable-25.08")
|
||||
== "org.winehq.Wine");
|
||||
|
||||
// Not a ref at all: a bare id, a kind alone, an empty string, a URL.
|
||||
assert(FlatpakManager::appIdFromRef("com.example.App").empty());
|
||||
assert(FlatpakManager::appIdFromRef("app/").empty());
|
||||
assert(FlatpakManager::appIdFromRef("").empty());
|
||||
assert(FlatpakManager::appIdFromRef("https://flathub.org/repo/app.flatpakref").empty());
|
||||
// A kind flatpak does not install as an application.
|
||||
assert(FlatpakManager::appIdFromRef("something/org.example.App/x86_64/stable").empty());
|
||||
}
|
||||
|
||||
// The first bytes of a real bundle, hex-encoded exactly as `flatpak
|
||||
// build-bundle` wrote them: the magic, the ref it installs, then the metadata.
|
||||
static std::string bundleHeaderFixture() {
|
||||
return fromHex(
|
||||
"666c617470616b00010089e500750800"
|
||||
"72656600000000006170702f636f6d2e"
|
||||
"757365626f74746c65732e626f74746c"
|
||||
"65732f7838365f36342f737461626c65"
|
||||
"00007304000000006d65746164617461"
|
||||
"00000000000000005b4170706c696361"
|
||||
"74696f6e5d0a6e616d653d636f6d2e75"
|
||||
"7365626f74746c65732e626f74746c65"
|
||||
"730a72756e74696d653d6f72672e676e"
|
||||
"6f6d652e506c6174666f726d2f783836"
|
||||
"5f36342f35300a73");
|
||||
}
|
||||
|
||||
static void testAppIdFromBundle_readsTheRefInTheHeader() {
|
||||
const std::string bundle = writeScratch("bottles.flatpak", bundleHeaderFixture());
|
||||
assert(FlatpakManager::appIdFromBundle(bundle) == "com.usebottles.bottles");
|
||||
|
||||
// A runtime bundle is named the same way, behind "runtime/" instead of
|
||||
// "app/", and with the framing flatpak may put around the ref differing.
|
||||
std::string runtime("flatpak\0", 8);
|
||||
runtime += std::string("\x01\0\0\0\0\0\0\0", 8);
|
||||
runtime += std::string("ref\0\0\0\0", 8);
|
||||
runtime += "runtime/org.freedesktop.Platform/x86_64/50";
|
||||
runtime += '\0';
|
||||
runtime += "metadata";
|
||||
assert(FlatpakManager::appIdFromBundle(writeScratch("platform.flatpak", runtime))
|
||||
== "org.freedesktop.Platform");
|
||||
}
|
||||
|
||||
static void testAppIdFromBundle_refusesWhatItCannotRead() {
|
||||
assert(FlatpakManager::appIdFromBundle("/tmp/pacmgr-does-not-exist.flatpak").empty());
|
||||
assert(FlatpakManager::appIdFromBundle(writeScratch("empty.flatpak", "")).empty());
|
||||
assert(FlatpakManager::appIdFromBundle(writeScratch("plain.flatpak", "not a bundle")).empty());
|
||||
|
||||
// The magic alone, then a header that stops in the middle of the ref.
|
||||
std::string truncated("flatpak\0", 8);
|
||||
truncated += "ref\0";
|
||||
assert(FlatpakManager::appIdFromBundle(writeScratch("truncated.flatpak", truncated)).empty());
|
||||
|
||||
// The right magic with something else behind the ref key.
|
||||
std::string foreign("flatpak\0", 8);
|
||||
foreign += std::string("ref\0\0\0\0\0", 9);
|
||||
foreign += "garbage-not-a-ref";
|
||||
foreign += '\0';
|
||||
assert(FlatpakManager::appIdFromBundle(writeScratch("foreign.flatpak", foreign)).empty());
|
||||
}
|
||||
|
||||
// A repository definition installs no application, so it answers nothing and
|
||||
// is installed the ordinary way; the two other formats name what they install.
|
||||
static void testFileTargetName_onlyNamesApplications() {
|
||||
FlatpakManager manager;
|
||||
|
||||
const std::string repo = writeScratch("flathub.flatpakrepo",
|
||||
"[Flatpak Repo]\n"
|
||||
"Name=flathub\n"
|
||||
"Url=https://dl.flathub.org/repo/\n");
|
||||
assert(manager.fileTargetName(repo).empty());
|
||||
|
||||
const std::string ref = writeScratch("calculator.flatpakref",
|
||||
"[Flatpak Ref]\n"
|
||||
"Name=org.gnome.Calculator\n");
|
||||
assert(manager.fileTargetName(ref) == "org.gnome.Calculator");
|
||||
|
||||
assert(manager.fileTargetName(writeScratch("app.flatpak", bundleHeaderFixture()))
|
||||
== "com.usebottles.bottles");
|
||||
|
||||
// A file no format claims stays unknown rather than guessed at.
|
||||
assert(manager.fileTargetName(writeScratch("documents.txt", "rien à voir")).empty());
|
||||
}
|
||||
|
||||
int main() {
|
||||
testParseSearchOutput_parsesAlignedRows();
|
||||
testParseSearchOutput_keepsMultiWordDescriptions();
|
||||
@@ -261,6 +441,13 @@ int main() {
|
||||
testUninstallAndUpdateCommands_targetOneCopy();
|
||||
testUninstallCommand_stillAcceptsAnApplicationId();
|
||||
|
||||
testAppIdFromRefFile_readsTheNameField();
|
||||
testAppIdFromRefFile_refusesWhatNamesNoApplication();
|
||||
testAppIdFromRef_stripsKindArchAndBranch();
|
||||
testAppIdFromBundle_readsTheRefInTheHeader();
|
||||
testAppIdFromBundle_refusesWhatItCannotRead();
|
||||
testFileTargetName_onlyNamesApplications();
|
||||
|
||||
std::cout << "All flatpak-manager tests passed." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
// Unit tests for StartupCheck: parsing of the two update-check formats, the
|
||||
// critical / reboot-required classification, the notification text, and the
|
||||
// autostart unit — the last one written inside a temporary directory, never the
|
||||
// user's own ~/.config.
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QString>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
#include "startup-check.h"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// parseUpdates
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static void testParseUpdates_checkupdatesFormat() {
|
||||
// What `checkupdates` prints: name, current version, "->", new version.
|
||||
const QString output =
|
||||
"linux 6.9.1.arch1-1 -> 6.9.2.arch1-1\n"
|
||||
"firefox 127.0-1 -> 128.0-1\n";
|
||||
const QStringList packages = StartupCheck::parseUpdates(output);
|
||||
assert(packages.size() == 2);
|
||||
assert(packages.at(0) == "linux");
|
||||
assert(packages.at(1) == "firefox");
|
||||
}
|
||||
|
||||
static void testParseUpdates_pacmanFormat() {
|
||||
// What `pacman -Qu` prints: name then the *new* version, no arrow.
|
||||
const QString output = "glibc 2.39-3\nvlc 3.0.21-1\n";
|
||||
const QStringList packages = StartupCheck::parseUpdates(output);
|
||||
assert(packages.size() == 2);
|
||||
assert(packages.at(0) == "glibc");
|
||||
assert(packages.at(1) == "vlc");
|
||||
}
|
||||
|
||||
static void testParseUpdates_ignoresBlanksAndDuplicates() {
|
||||
const QString output = "\n\nlinux 6.9-1\n\nlinux 6.9-1\n";
|
||||
const QStringList packages = StartupCheck::parseUpdates(output);
|
||||
assert(packages.size() == 1);
|
||||
assert(packages.at(0) == "linux");
|
||||
}
|
||||
|
||||
static void testParseUpdates_emptyOutput() {
|
||||
assert(StartupCheck::parseUpdates(QString()).isEmpty());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Classification
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static void testIsCritical_kernelAndCorePackages() {
|
||||
assert(StartupCheck::isCritical("linux"));
|
||||
assert(StartupCheck::isCritical("linux-lts"));
|
||||
assert(StartupCheck::isCritical("linux-firmware"));
|
||||
assert(StartupCheck::isCritical("glibc"));
|
||||
assert(StartupCheck::isCritical("systemd"));
|
||||
assert(StartupCheck::isCritical("systemd-libs"));
|
||||
assert(StartupCheck::isCritical("mesa"));
|
||||
assert(StartupCheck::isCritical("nvidia-utils"));
|
||||
assert(StartupCheck::isCritical("pacman"));
|
||||
assert(StartupCheck::isCritical("openssl"));
|
||||
}
|
||||
|
||||
static void testIsCritical_ordinaryPackages() {
|
||||
assert(!StartupCheck::isCritical("firefox"));
|
||||
assert(!StartupCheck::isCritical("vlc"));
|
||||
assert(!StartupCheck::isCritical("gimp"));
|
||||
assert(!StartupCheck::isCritical("git"));
|
||||
assert(!StartupCheck::isCritical("python"));
|
||||
}
|
||||
|
||||
static void testIsRebootRequired_onlyKernelAndDrivers() {
|
||||
assert(StartupCheck::isRebootRequired("linux"));
|
||||
assert(StartupCheck::isRebootRequired("linux-firmware"));
|
||||
assert(StartupCheck::isRebootRequired("nvidia-utils"));
|
||||
// Critical because they can break the session, but they take effect on the
|
||||
// spot: no reboot to ask for.
|
||||
assert(!StartupCheck::isRebootRequired("glibc"));
|
||||
assert(!StartupCheck::isRebootRequired("mesa"));
|
||||
assert(!StartupCheck::isRebootRequired("firefox"));
|
||||
}
|
||||
|
||||
static void testCriticalPackages_returnsOnlyTheMatchingOnes() {
|
||||
const QStringList all{"firefox", "linux", "vlc", "glibc"};
|
||||
const QStringList critical = StartupCheck::criticalPackages(all);
|
||||
assert(critical.size() == 2);
|
||||
assert(critical.at(0) == "linux");
|
||||
assert(critical.at(1) == "glibc");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Notification text
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static void testNotification_kernelUpdateIsUrgent() {
|
||||
StartupCheck::Result result;
|
||||
result.packages = {"linux", "glibc", "firefox"};
|
||||
result.updateCount = 3;
|
||||
result.anyCritical = true;
|
||||
result.rebootRequired = true;
|
||||
|
||||
assert(StartupCheck::notificationTitle(result) == "Mise à jour du noyau disponible");
|
||||
const QString body = StartupCheck::notificationBody(result);
|
||||
assert(body.contains("3 mises à jour"));
|
||||
assert(body.contains("linux, glibc"));
|
||||
assert(body.contains("redémarrage"));
|
||||
}
|
||||
|
||||
static void testNotification_ordinaryUpdate() {
|
||||
StartupCheck::Result result;
|
||||
result.packages = {"firefox"};
|
||||
result.updateCount = 1;
|
||||
|
||||
assert(StartupCheck::notificationTitle(result) == "Mises à jour disponibles");
|
||||
const QString body = StartupCheck::notificationBody(result);
|
||||
assert(body.contains("1 mise à jour disponible"));
|
||||
assert(body.contains("Ouvrez PacManager"));
|
||||
assert(!body.contains("redémarrage"));
|
||||
}
|
||||
|
||||
static void testNotification_capsTheCriticalPackageList() {
|
||||
// Eight critical packages must not turn the bubble into a wall of text.
|
||||
StartupCheck::Result result;
|
||||
result.packages = {"linux", "linux-lts", "linux-zen", "linux-hardened",
|
||||
"linux-firmware", "glibc", "systemd", "mesa"};
|
||||
result.updateCount = 8;
|
||||
result.anyCritical = true;
|
||||
result.rebootRequired = true;
|
||||
|
||||
const QString body = StartupCheck::notificationBody(result);
|
||||
assert(body.contains("…"));
|
||||
assert(!body.contains("mesa"));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Autostart files
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static void testAutostart_installEnableAndRemove() {
|
||||
QTemporaryDir dir;
|
||||
assert(dir.isValid());
|
||||
const QString configDir = dir.path();
|
||||
// A space in the path checks the quoting systemd needs.
|
||||
const QString program = "/opt/Pac Manager/PacManager";
|
||||
|
||||
assert(!StartupCheck::autostartEnabled(configDir));
|
||||
|
||||
QString error;
|
||||
assert(StartupCheck::installAutostart(configDir, program, &error));
|
||||
assert(error.isEmpty());
|
||||
assert(StartupCheck::autostartEnabled(configDir));
|
||||
|
||||
QFile unit(StartupCheck::autostartUnitPath(configDir));
|
||||
assert(unit.open(QIODevice::ReadOnly));
|
||||
const QString content = QString::fromUtf8(unit.readAll());
|
||||
unit.close();
|
||||
assert(content.contains("\"/opt/Pac Manager/PacManager\" --check-updates"));
|
||||
assert(content.contains("WantedBy=default.target"));
|
||||
assert(content.contains("Type=oneshot"));
|
||||
|
||||
// The enabling link points back at the unit, which is what makes the login
|
||||
// manager start it.
|
||||
const QFileInfo link(StartupCheck::autostartWantsPath(configDir));
|
||||
assert(link.isSymLink());
|
||||
|
||||
assert(StartupCheck::removeAutostart(configDir, &error));
|
||||
assert(!StartupCheck::autostartEnabled(configDir));
|
||||
assert(!QFile::exists(StartupCheck::autostartUnitPath(configDir)));
|
||||
assert(!QFileInfo::exists(StartupCheck::autostartWantsPath(configDir)));
|
||||
}
|
||||
|
||||
static void testAutostart_refusesEmptyInputs() {
|
||||
assert(StartupCheck::autostartUnitPath(QString()).isEmpty());
|
||||
assert(StartupCheck::autostartWantsPath(QString()).isEmpty());
|
||||
|
||||
QString error;
|
||||
assert(!StartupCheck::installAutostart(QString(), "/usr/bin/PacManager", &error));
|
||||
assert(!error.isEmpty());
|
||||
assert(!StartupCheck::installAutostart("/tmp/does-not-matter", QString(), &error));
|
||||
assert(!StartupCheck::autostartEnabled(QString()));
|
||||
}
|
||||
|
||||
int main() {
|
||||
testParseUpdates_checkupdatesFormat();
|
||||
testParseUpdates_pacmanFormat();
|
||||
testParseUpdates_ignoresBlanksAndDuplicates();
|
||||
testParseUpdates_emptyOutput();
|
||||
|
||||
testIsCritical_kernelAndCorePackages();
|
||||
testIsCritical_ordinaryPackages();
|
||||
testIsRebootRequired_onlyKernelAndDrivers();
|
||||
testCriticalPackages_returnsOnlyTheMatchingOnes();
|
||||
|
||||
testNotification_kernelUpdateIsUrgent();
|
||||
testNotification_ordinaryUpdate();
|
||||
testNotification_capsTheCriticalPackageList();
|
||||
|
||||
testAutostart_installEnableAndRemove();
|
||||
testAutostart_refusesEmptyInputs();
|
||||
|
||||
std::cout << "All startup-check tests passed." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
" PacManager reprendra ensuite l'opération automatiquement.": " PacManager setzt den Vorgang anschließend automatisch fort.",
|
||||
"%1 (jusqu'au %2)": "%1 (bis %2)",
|
||||
"%1 : %2": "%1: %2",
|
||||
"%1 : déjà installé, rien à faire": "%1: bereits installiert, nichts zu tun",
|
||||
"%1 : format non reconnu (PacManager installe les fichiers .flatpakref, .flatpakrepo, .flatpak et les paquets de plugin .fwspacm).": "%1: Format nicht erkannt (PacManager installiert die Dateien .flatpakref, .flatpakrepo, .flatpak sowie .fwspacm-Plugin-Pakete).",
|
||||
"%1 Ko": "%1 KB",
|
||||
"%1 Mo": "%1 MB",
|
||||
@@ -37,10 +38,14 @@
|
||||
"5 Mo": "5 MB",
|
||||
"7 jours": "7 Tage",
|
||||
"<b>%1</b> utilise déjà la base pacman.": "<b>%1</b> verwendet die pacman-Datenbank bereits.",
|
||||
"<b>%1</b> : ce plugin est déjà installé. Supprimez-le depuis l'écran Extensions pour en installer un autre.": "<b>%1</b>: Dieses Plugin ist bereits installiert. Entferne es im Bildschirm Erweiterungen, um ein anderes zu installieren.",
|
||||
"<b>%1</b> est déjà installé : il n'y a rien à installer. Sa mise à jour se fait depuis l'écran des mises à jour.": "<b>%1</b> ist bereits installiert: es gibt nichts zu installieren. Aktualisiert wird es über den Bildschirm der Aktualisierungen.",
|
||||
"<b>%1</b> pris en compte : le plugin est installé et utilisable sans redémarrer.": "<b>%1</b> berücksichtigt: das Plugin ist installiert und ohne Neustart nutzbar.",
|
||||
"<b>%1</b> pris en compte : l'installation démarre, sa progression s'affiche en bas de la fenêtre.": "<b>%1</b> berücksichtigt: die Installation startet, ihr Fortschritt wird unten im Fenster angezeigt.",
|
||||
"<h2>PacManager v%1</h2><p>Gestionnaire de paquets pour Arch Linux (pacman).</p>": "<h2>PacManager v%1</h2><p>Paketverwaltung für Arch Linux (pacman).</p>",
|
||||
"<h3>PacManager a été mis à jour</h3><p>La nouvelle version sera active au prochain démarrage.</p><pre>%1</pre>": "<h3>PacManager wurde aktualisiert</h3><p>Die neue Version ist beim nächsten Start aktiv.</p><pre>%1</pre>",
|
||||
"<h3>PacManager v%1 est disponible</h3><p>Vous utilisez actuellement la version %2.</p>": "<h3>PacManager v%1 ist verfügbar</h3><p>Du verwendest derzeit Version %2.</p>",
|
||||
"<p>La mise à jour a échoué :</p><pre>%1</pre>": "<p>Die Aktualisierung ist fehlgeschlagen:</p><pre>%1</pre>",
|
||||
"<p>La mise à jour a échoué :</p><pre>%1</pre><p>Le journal complet est dans <code>%2</code>.</p>": "<p>Die Aktualisierung ist fehlgeschlagen:</p><pre>%1</pre><p>Das vollständige Protokoll liegt in <code>%2</code>.</p>",
|
||||
"ACTIONS RAPIDES": "SCHNELLAKTIONEN",
|
||||
"ACTIVITÉ RÉCENTE": "LETZTE AKTIVITÄT",
|
||||
"AJOUTER UN PLUGIN": "PLUGIN HINZUFÜGEN",
|
||||
@@ -97,6 +102,7 @@
|
||||
"Dossier du journal": "Journal-Ordner",
|
||||
"Dossier du journal : %1": "Journal-Ordner: %1",
|
||||
"Débloquer": "Entsperren",
|
||||
"Déjà installé": "Bereits installiert",
|
||||
"Dépend de": "Hängt ab von",
|
||||
"Déposez un fichier <code>%1</code> n'importe où sur la fenêtre : son bibliothèque est extraite dans <code>%2</code>, sans mot de passe, et le plugin est chargé immédiatement, sans redémarrer. Le paquet contient un manifeste <code>plugin.json</code> et la bibliothèque ; il se crée avec <code>./make-plugin-package.py</code> (voir doc/plugins.md).": "Lege eine Datei <code>%1</code> irgendwo im Fenster ab: Ihre Bibliothek wird nach <code>%2</code> entpackt, ohne Passwort, und das Plugin wird sofort geladen, ohne Neustart. Das Paket enthält ein Manifest <code>plugin.json</code> und die Bibliothek; es wird mit <code>./make-plugin-package.py</code> erstellt (siehe doc/plugins.md).",
|
||||
"Dépôt": "Repository",
|
||||
@@ -123,6 +129,7 @@
|
||||
"Fermer le gestionnaire": "Die Paketverwaltung schließen",
|
||||
"Fichier": "Datei",
|
||||
"Fichier installé": "Installierte Datei",
|
||||
"Fichiers pris en compte": "Dateien berücksichtigt",
|
||||
"Filtre local, instantané": "Lokaler Filter, sofort",
|
||||
"Filtrer :": "Filtern:",
|
||||
"Filtrer les logs (paquet, action, date)...": "Die Logs filtern (Paket, Aktion, Datum)...",
|
||||
|
||||
+13
-1
@@ -5,6 +5,7 @@
|
||||
" PacManager reprendra ensuite l'opération automatiquement.": " PacManager will then resume the operation automatically.",
|
||||
"%1 (jusqu'au %2)": "%1 (until %2)",
|
||||
"%1 : %2": "%1: %2",
|
||||
"%1 : déjà installé, rien à faire": "%1: already installed, nothing to do",
|
||||
"%1 : format non reconnu (PacManager installe les fichiers .flatpakref, .flatpakrepo, .flatpak et les paquets de plugin .fwspacm).": "%1: unsupported format (PacManager installs the .flatpakref, .flatpakrepo and .flatpak files, and the .fwspacm plugin packages).",
|
||||
"%1 Ko": "%1 KB",
|
||||
"%1 Mo": "%1 MB",
|
||||
@@ -37,10 +38,14 @@
|
||||
"5 Mo": "5 MB",
|
||||
"7 jours": "7 days",
|
||||
"<b>%1</b> utilise déjà la base pacman.": "<b>%1</b> is already using the pacman database.",
|
||||
"<b>%1</b> : ce plugin est déjà installé. Supprimez-le depuis l'écran Extensions pour en installer un autre.": "<b>%1</b>: this plugin is already installed. Remove it from the Extensions screen to install another one.",
|
||||
"<b>%1</b> est déjà installé : il n'y a rien à installer. Sa mise à jour se fait depuis l'écran des mises à jour.": "<b>%1</b> is already installed: there is nothing to install. It is updated from the updates screen.",
|
||||
"<b>%1</b> pris en compte : le plugin est installé et utilisable sans redémarrer.": "<b>%1</b> taken into account: the plugin is installed and usable without restarting.",
|
||||
"<b>%1</b> pris en compte : l'installation démarre, sa progression s'affiche en bas de la fenêtre.": "<b>%1</b> taken into account: the installation starts, its progress is shown at the bottom of the window.",
|
||||
"<h2>PacManager v%1</h2><p>Gestionnaire de paquets pour Arch Linux (pacman).</p>": "<h2>PacManager v%1</h2><p>Package manager for Arch Linux (pacman).</p>",
|
||||
"<h3>PacManager a été mis à jour</h3><p>La nouvelle version sera active au prochain démarrage.</p><pre>%1</pre>": "<h3>PacManager has been updated</h3><p>The new version will be active on the next start.</p><pre>%1</pre>",
|
||||
"<h3>PacManager v%1 est disponible</h3><p>Vous utilisez actuellement la version %2.</p>": "<h3>PacManager v%1 is available</h3><p>You are currently running version %2.</p>",
|
||||
"<p>La mise à jour a échoué :</p><pre>%1</pre>": "<p>The update failed:</p><pre>%1</pre>",
|
||||
"<p>La mise à jour a échoué :</p><pre>%1</pre><p>Le journal complet est dans <code>%2</code>.</p>": "<p>The update failed:</p><pre>%1</pre><p>The full log is in <code>%2</code>.</p>",
|
||||
"ACTIONS RAPIDES": "QUICK ACTIONS",
|
||||
"ACTIVITÉ RÉCENTE": "RECENT ACTIVITY",
|
||||
"AJOUTER UN PLUGIN": "ADD A PLUGIN",
|
||||
@@ -97,6 +102,7 @@
|
||||
"Dossier du journal": "Journal folder",
|
||||
"Dossier du journal : %1": "Journal folder: %1",
|
||||
"Débloquer": "Unblock",
|
||||
"Déjà installé": "Already installed",
|
||||
"Dépend de": "Depends on",
|
||||
"Déposez un fichier <code>%1</code> n'importe où sur la fenêtre : son bibliothèque est extraite dans <code>%2</code>, sans mot de passe, et le plugin est chargé immédiatement, sans redémarrer. Le paquet contient un manifeste <code>plugin.json</code> et la bibliothèque ; il se crée avec <code>./make-plugin-package.py</code> (voir doc/plugins.md).": "Drop a <code>%1</code> file anywhere on the window: its library is extracted into <code>%2</code>, without a password, and the plugin is loaded right away, with no restart. The package holds a <code>plugin.json</code> manifest and the library; it is built with <code>./make-plugin-package.py</code> (see doc/plugins.md).",
|
||||
"Dépôt": "Repository",
|
||||
@@ -123,6 +129,7 @@
|
||||
"Fermer le gestionnaire": "Close the package manager",
|
||||
"Fichier": "File",
|
||||
"Fichier installé": "Installed file",
|
||||
"Fichiers pris en compte": "Files taken into account",
|
||||
"Filtre local, instantané": "Local filter, instant",
|
||||
"Filtrer :": "Filter:",
|
||||
"Filtrer les logs (paquet, action, date)...": "Filter the logs (package, action, date)...",
|
||||
@@ -145,6 +152,7 @@
|
||||
"Identifiants enregistrés pour la session.": "Credentials kept for the session.",
|
||||
"Identifiants sudo": "Sudo credentials",
|
||||
"Illimité": "Unlimited",
|
||||
"Impossible d'installer la vérification au démarrage.": "Cannot install the startup update check.",
|
||||
"Impossible d'ouvrir %1.\nVérifiez que le fichier existe et que vous avez les droits de lecture.": "Cannot open %1.\nCheck that the file exists and that you have read permission.",
|
||||
"Impossible d'écrire dans %1": "Cannot write to %1",
|
||||
"Installation": "Installation",
|
||||
@@ -254,6 +262,7 @@
|
||||
"Plugins rechargés.": "Plugins reloaded.",
|
||||
"Plus tard": "Later",
|
||||
"Préférences de PacManager : journal, glisser-déposer, langue et mises à jour": "PacManager preferences: journal, drag and drop, language and updates",
|
||||
"Prévient par une notification à l'ouverture de session quand des mises à jour sont disponibles — sans mot de passe. Installe le service utilisateur associé.": "Notifies you at login when updates are pending — no password, no sudo. Installs the matching user service.",
|
||||
"Prévisualisation des mises à jour disponibles": "Preview the available updates",
|
||||
"Prévisualiser les mises à jour": "Preview updates",
|
||||
"Prêt": "Ready",
|
||||
@@ -333,9 +342,12 @@
|
||||
"Voir les paquets installés": "See the installed packages",
|
||||
"Vue d'ensemble de votre système": "An overview of your system",
|
||||
"Vue d'ensemble du système": "System overview",
|
||||
"Vérification des mises à jour au démarrage activée (notification à l'ouverture de session).": "Startup update check enabled (a notification at login).",
|
||||
"Vérification des mises à jour au démarrage désactivée.": "Startup update check disabled.",
|
||||
"Vérification des mises à jour réactivée": "Update checking re-enabled",
|
||||
"Vérification des mises à jour...": "Checking for updates...",
|
||||
"Vérifier les mises à jour": "Check for updates",
|
||||
"Vérifier les mises à jour au démarrage": "Check for updates at startup",
|
||||
"Vérifier les nouvelles versions au lancement": "Check for new versions at launch",
|
||||
"\"%1\" via %2": "\"%1\" via %2",
|
||||
"activé": "enabled",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
" PacManager reprendra ensuite l'opération automatiquement.": " PacManager reanudará la operación automáticamente.",
|
||||
"%1 (jusqu'au %2)": "%1 (hasta %2)",
|
||||
"%1 : %2": "%1: %2",
|
||||
"%1 : déjà installé, rien à faire": "%1: ya instalado, nada que hacer",
|
||||
"%1 : format non reconnu (PacManager installe les fichiers .flatpakref, .flatpakrepo, .flatpak et les paquets de plugin .fwspacm).": "%1: formato no reconocido (PacManager instala los archivos .flatpakref, .flatpakrepo, .flatpak y los paquetes de plugin .fwspacm).",
|
||||
"%1 Ko": "%1 KB",
|
||||
"%1 Mo": "%1 MB",
|
||||
@@ -37,10 +38,14 @@
|
||||
"5 Mo": "5 MB",
|
||||
"7 jours": "7 días",
|
||||
"<b>%1</b> utilise déjà la base pacman.": "<b>%1</b> ya está usando la base de datos de pacman.",
|
||||
"<b>%1</b> : ce plugin est déjà installé. Supprimez-le depuis l'écran Extensions pour en installer un autre.": "<b>%1</b>: este plugin ya está instalado. Elimínalo desde la pantalla Extensiones para instalar otro.",
|
||||
"<b>%1</b> est déjà installé : il n'y a rien à installer. Sa mise à jour se fait depuis l'écran des mises à jour.": "<b>%1</b> ya está instalado: no hay nada que instalar. Su actualización se hace desde la pantalla de actualizaciones.",
|
||||
"<b>%1</b> pris en compte : le plugin est installé et utilisable sans redémarrer.": "<b>%1</b> tenido en cuenta: el plugin está instalado y se puede usar sin reiniciar.",
|
||||
"<b>%1</b> pris en compte : l'installation démarre, sa progression s'affiche en bas de la fenêtre.": "<b>%1</b> tenido en cuenta: la instalación comienza y su progreso se muestra en la parte inferior de la ventana.",
|
||||
"<h2>PacManager v%1</h2><p>Gestionnaire de paquets pour Arch Linux (pacman).</p>": "<h2>PacManager v%1</h2><p>Gestor de paquetes para Arch Linux (pacman).</p>",
|
||||
"<h3>PacManager a été mis à jour</h3><p>La nouvelle version sera active au prochain démarrage.</p><pre>%1</pre>": "<h3>PacManager se ha actualizado</h3><p>La nueva versión estará activa en el próximo inicio.</p><pre>%1</pre>",
|
||||
"<h3>PacManager v%1 est disponible</h3><p>Vous utilisez actuellement la version %2.</p>": "<h3>PacManager v%1 está disponible</h3><p>Actualmente usas la versión %2.</p>",
|
||||
"<p>La mise à jour a échoué :</p><pre>%1</pre>": "<p>La actualización ha fallado:</p><pre>%1</pre>",
|
||||
"<p>La mise à jour a échoué :</p><pre>%1</pre><p>Le journal complet est dans <code>%2</code>.</p>": "<p>La actualización ha fallado:</p><pre>%1</pre><p>El registro completo está en <code>%2</code>.</p>",
|
||||
"ACTIONS RAPIDES": "ACCIONES RÁPIDAS",
|
||||
"ACTIVITÉ RÉCENTE": "ACTIVIDAD RECIENTE",
|
||||
"AJOUTER UN PLUGIN": "AÑADIR UN PLUGIN",
|
||||
@@ -97,6 +102,7 @@
|
||||
"Dossier du journal": "Carpeta del diario",
|
||||
"Dossier du journal : %1": "Carpeta del diario: %1",
|
||||
"Débloquer": "Desbloquear",
|
||||
"Déjà installé": "Ya instalado",
|
||||
"Dépend de": "Depende de",
|
||||
"Déposez un fichier <code>%1</code> n'importe où sur la fenêtre : son bibliothèque est extraite dans <code>%2</code>, sans mot de passe, et le plugin est chargé immédiatement, sans redémarrer. Le paquet contient un manifeste <code>plugin.json</code> et la bibliothèque ; il se crée avec <code>./make-plugin-package.py</code> (voir doc/plugins.md).": "Suelta un archivo <code>%1</code> en cualquier parte de la ventana: su biblioteca se extrae en <code>%2</code>, sin contraseña, y el plugin se carga de inmediato, sin reiniciar. El paquete contiene un manifiesto <code>plugin.json</code> y la biblioteca; se crea con <code>./make-plugin-package.py</code> (ver doc/plugins.md).",
|
||||
"Dépôt": "Repositorio",
|
||||
@@ -123,6 +129,7 @@
|
||||
"Fermer le gestionnaire": "Cerrar el gestor",
|
||||
"Fichier": "Archivo",
|
||||
"Fichier installé": "Archivo instalado",
|
||||
"Fichiers pris en compte": "Archivos tenidos en cuenta",
|
||||
"Filtre local, instantané": "Filtro local, instantáneo",
|
||||
"Filtrer :": "Filtrar:",
|
||||
"Filtrer les logs (paquet, action, date)...": "Filtrar los registros (paquete, acción, fecha)...",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
" PacManager reprendra ensuite l'opération automatiquement.": " PacManager riprenderà poi l'operazione automaticamente.",
|
||||
"%1 (jusqu'au %2)": "%1 (fino al %2)",
|
||||
"%1 : %2": "%1: %2",
|
||||
"%1 : déjà installé, rien à faire": "%1: già installato, nulla da fare",
|
||||
"%1 : format non reconnu (PacManager installe les fichiers .flatpakref, .flatpakrepo, .flatpak et les paquets de plugin .fwspacm).": "%1: formato non riconosciuto (PacManager installa i file .flatpakref, .flatpakrepo, .flatpak e i pacchetti di plugin .fwspacm).",
|
||||
"%1 Ko": "%1 KB",
|
||||
"%1 Mo": "%1 MB",
|
||||
@@ -37,10 +38,14 @@
|
||||
"5 Mo": "5 MB",
|
||||
"7 jours": "7 giorni",
|
||||
"<b>%1</b> utilise déjà la base pacman.": "<b>%1</b> sta già usando il database di pacman.",
|
||||
"<b>%1</b> : ce plugin est déjà installé. Supprimez-le depuis l'écran Extensions pour en installer un autre.": "<b>%1</b>: questo plugin è già installato. Rimuovilo dalla schermata Estensioni per installarne un altro.",
|
||||
"<b>%1</b> est déjà installé : il n'y a rien à installer. Sa mise à jour se fait depuis l'écran des mises à jour.": "<b>%1</b> è già installato: non c'è nulla da installare. Il suo aggiornamento si fa dalla schermata degli aggiornamenti.",
|
||||
"<b>%1</b> pris en compte : le plugin est installé et utilisable sans redémarrer.": "<b>%1</b> preso in carico: il plugin è installato e utilizzabile senza riavviare.",
|
||||
"<b>%1</b> pris en compte : l'installation démarre, sa progression s'affiche en bas de la fenêtre.": "<b>%1</b> preso in carico: l'installazione inizia e il suo avanzamento è mostrato in fondo alla finestra.",
|
||||
"<h2>PacManager v%1</h2><p>Gestionnaire de paquets pour Arch Linux (pacman).</p>": "<h2>PacManager v%1</h2><p>Gestore di pacchetti per Arch Linux (pacman).</p>",
|
||||
"<h3>PacManager a été mis à jour</h3><p>La nouvelle version sera active au prochain démarrage.</p><pre>%1</pre>": "<h3>PacManager è stato aggiornato</h3><p>La nuova versione sarà attiva al prossimo avvio.</p><pre>%1</pre>",
|
||||
"<h3>PacManager v%1 est disponible</h3><p>Vous utilisez actuellement la version %2.</p>": "<h3>PacManager v%1 è disponibile</h3><p>Al momento usi la versione %2.</p>",
|
||||
"<p>La mise à jour a échoué :</p><pre>%1</pre>": "<p>L'aggiornamento non è riuscito:</p><pre>%1</pre>",
|
||||
"<p>La mise à jour a échoué :</p><pre>%1</pre><p>Le journal complet est dans <code>%2</code>.</p>": "<p>L'aggiornamento non è riuscito:</p><pre>%1</pre><p>Il registro completo è in <code>%2</code>.</p>",
|
||||
"ACTIONS RAPIDES": "AZIONI RAPIDE",
|
||||
"ACTIVITÉ RÉCENTE": "ATTIVITÀ RECENTE",
|
||||
"AJOUTER UN PLUGIN": "AGGIUNGI UN PLUGIN",
|
||||
@@ -97,6 +102,7 @@
|
||||
"Dossier du journal": "Cartella del diario",
|
||||
"Dossier du journal : %1": "Cartella del diario: %1",
|
||||
"Débloquer": "Sblocca",
|
||||
"Déjà installé": "Già installato",
|
||||
"Dépend de": "Dipende da",
|
||||
"Déposez un fichier <code>%1</code> n'importe où sur la fenêtre : son bibliothèque est extraite dans <code>%2</code>, sans mot de passe, et le plugin est chargé immédiatement, sans redémarrer. Le paquet contient un manifeste <code>plugin.json</code> et la bibliothèque ; il se crée avec <code>./make-plugin-package.py</code> (voir doc/plugins.md).": "Rilascia un file <code>%1</code> in qualsiasi punto della finestra: la sua libreria viene estratta in <code>%2</code>, senza password, e il plugin viene caricato subito, senza riavviare. Il pacchetto contiene un manifesto <code>plugin.json</code> e la libreria; si crea con <code>./make-plugin-package.py</code> (vedi doc/plugins.md).",
|
||||
"Dépôt": "Repository",
|
||||
@@ -123,6 +129,7 @@
|
||||
"Fermer le gestionnaire": "Chiudi il gestore",
|
||||
"Fichier": "File",
|
||||
"Fichier installé": "File installato",
|
||||
"Fichiers pris en compte": "File presi in carico",
|
||||
"Filtre local, instantané": "Filtro locale, istantaneo",
|
||||
"Filtrer :": "Filtra:",
|
||||
"Filtrer les logs (paquet, action, date)...": "Filtra i log (pacchetto, azione, data)...",
|
||||
|
||||
@@ -553,7 +553,7 @@ QString UpdateManager::stagedInstallScript() {
|
||||
" cp \"$1\" \"$TMP\"\n"
|
||||
" mv -f \"$TMP\" \"$2\"\n"
|
||||
"}\n"
|
||||
"mkdir -p \"$BIN_DIR\"\n"
|
||||
"mkdir -p \"$BIN_DIR\" || { echo 'Impossible de créer '$BIN_DIR; exit 1; }\n"
|
||||
"install_file \"$STAGE/bin/PacManager\" \"$BIN_DIR/PacManager\"\n"
|
||||
// The version marker has to follow the installed release: it is what
|
||||
// the app reports and what the next update check compares against, so
|
||||
|
||||
Reference in new issue
Block a user