Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3ad3ca523
|
||
|
|
2c7d99138d
|
||
|
|
b204d6814a
|
No files matched your search
+12
-9
@@ -172,17 +172,20 @@ The method is picked automatically (no configuration):
|
|||||||
| Method | When | What happens |
|
| Method | When | What happens |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| **Checkout** | a source checkout surrounds the binary (dev) | `git pull`, rebuild, install into the binary's directory |
|
| **Checkout** | a source checkout surrounds the binary (dev) | `git pull`, rebuild, install into the binary's directory |
|
||||||
| **Clone** | installed app with no checkout, and `git` + `cmake` + a compiler | the repo is cloned/updated in `~/.local/share/PacManager/src`, rebuilt and installed in place |
|
| **Clone** | installed app with no checkout, with `git` (or pacman to install the rest) | missing build dependencies are installed first, the repo is cloned/updated in `~/.local/share/PacManager/src`, rebuilt and installed in place |
|
||||||
| **Prebuilt** | no build toolchain available, and the release has a prebuilt archive attached | that archive is downloaded and unpacked |
|
| **Prebuilt** | no build toolchain nor pacman, and the release has a prebuilt archive attached | that archive is downloaded and unpacked |
|
||||||
| **Tarball** | no `git`, but `cmake` + a compiler | the release sources are built and installed |
|
| **Tarball** | no `git`, but a toolchain present or installable | missing build dependencies are installed first, the release sources are built and installed |
|
||||||
|
|
||||||
Everything builds in a temporary directory: only the final replacement of the
|
Everything builds in a temporary directory: `sudo` is only used for the final
|
||||||
binary (and plugins) needs `sudo`, and only when the target directory is owned
|
binary replacement (when the target directory is root-owned) and for
|
||||||
by root. PacManager then restarts automatically on the new version.
|
**automatically installing the build dependencies** — when `qt6-base`, `cmake`,
|
||||||
|
`gcc`/`base-devel` or `git` are missing, PacManager installs them itself through
|
||||||
|
`pacman` as soon as the sudo password is entered, then resumes the build.
|
||||||
|
PacManager then restarts automatically on the new version.
|
||||||
|
|
||||||
Nothing produces a prebuilt archive automatically: without one attached to the
|
Nothing produces a prebuilt archive automatically: without one attached to the
|
||||||
release, **Clone** or **Tarball** applies instead (so `git`, `cmake` and a
|
release, **Clone** or **Tarball** applies instead — having `pacman` and the sudo
|
||||||
compiler are needed on the machine).
|
password is enough, the rest is installed by the update itself.
|
||||||
|
|
||||||
All four methods install to the same place — the running binary's directory —
|
All four methods install to the same place — the running binary's directory —
|
||||||
and rewrite the `version` file there. To know which release is really installed,
|
and rewrite the `version` file there. To know which release is really installed,
|
||||||
@@ -198,7 +201,7 @@ The interface uses **Qt6** with a dark theme, a **navigation sidebar** and stack
|
|||||||
- 🏠 **Dashboard**: statistics cards, quick actions and recent activity
|
- 🏠 **Dashboard**: statistics cards, quick actions and recent activity
|
||||||
- 🔍 **Search**: search bar, package table on the left and details on the right
|
- 🔍 **Search**: search bar, package table on the left and details on the right
|
||||||
- 📦 **Installed**: list with **instant name filter** (local, no pacman re-run)
|
- 📦 **Installed**: list with **instant name filter** (local, no pacman re-run)
|
||||||
- ⬆️ **Updates**: outdated packages detected by `pacman -Qu`, "Update all" button
|
- ⬆️ **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`)
|
- 🧹 **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
|
- 📋 **History**: filterable table (installs / removals / updates / cleanups) + CSV export
|
||||||
- 📜 **Logs**: built-in `/var/log/pacman.log` viewer with an instant filter
|
- 📜 **Logs**: built-in `/var/log/pacman.log` viewer with an instant filter
|
||||||
|
|||||||
@@ -174,14 +174,16 @@ La méthode est choisie automatiquement (aucune configuration) :
|
|||||||
| Méthode | Quand | Ce qui se passe |
|
| Méthode | Quand | Ce qui se passe |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| **Checkout** | un dépôt source entoure le binaire (dev) | `git pull`, recompilation puis installation dans le dossier du binaire |
|
| **Checkout** | un dépôt source entoure le binaire (dev) | `git pull`, recompilation puis installation dans le dossier du binaire |
|
||||||
| **Clone** | app installée sans dépôt, avec `git` + `cmake` + compilateur | le dépôt est cloné puis mis à jour dans `~/.local/share/PacManager/src`, recompilé et installé en place |
|
| **Clone** | app installée sans dépôt, avec `git` (ou pacman pour installer le reste) | les dépendances de compilation manquantes sont installées, le dépôt est cloné puis mis à jour dans `~/.local/share/PacManager/src`, recompilé et installé en place |
|
||||||
| **Prebuilt** | pas d'outillage de compilation et une archive précompilée est attachée à la release | l'archive est téléchargée et décompressée |
|
| **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 `cmake` + compilateur présents | les sources de la release sont compilées puis installées |
|
| **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 |
|
||||||
|
|
||||||
Tout se compile dans un dossier temporaire : seul le remplacement final du
|
Tout se compile dans un dossier temporaire : `sudo` n'intervient que pour
|
||||||
binaire (et des plugins) demande `sudo`, et uniquement si le dossier cible
|
l'installation finale du binaire (si le dossier cible appartient à root) et pour
|
||||||
appartient à root. PacManager redémarre ensuite automatiquement sur la nouvelle
|
**l'installation automatique des dépendances de compilation** — quand `qt6-base`,
|
||||||
version.
|
`cmake`, `gcc`/`base-devel` ou `git` manquent, PacManager les installe lui-même
|
||||||
|
via `pacman` dès que le mot de passe sudo est saisi, puis relance la compilation.
|
||||||
|
PacManager redémarre ensuite automatiquement sur la nouvelle version.
|
||||||
|
|
||||||
Rien ne produit d'archive précompilée automatiquement : sans archive attachée à
|
Rien ne produit d'archive précompilée automatiquement : sans archive attachée à
|
||||||
la release, ce sont **Clone** ou **Tarball** qui s'appliquent (donc `git`, `cmake`
|
la release, ce sont **Clone** ou **Tarball** qui s'appliquent (donc `git`, `cmake`
|
||||||
@@ -202,7 +204,7 @@ L'interface utilise **Qt6** avec un thème sombre, une **sidebar de navigation**
|
|||||||
- 🏠 **Tableau de bord** : cartes de statistiques, actions rapides et activité récente
|
- 🏠 **Tableau de bord** : cartes de statistiques, actions rapides et activité récente
|
||||||
- 🔍 **Recherche** : barre de recherche, tableau de paquets à gauche et détails à droite
|
- 🔍 **Recherche** : barre de recherche, tableau de paquets à gauche et détails à droite
|
||||||
- 📦 **Installés** : liste avec **filtre instantané** par nom (local, sans relancer pacman)
|
- 📦 **Installés** : liste avec **filtre instantané** par nom (local, sans relancer pacman)
|
||||||
- ⬆️ **Mises à jour** : paquets obsolètes détectés par `pacman -Qu`, bouton « Tout mettre à jour »
|
- ⬆️ **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`)
|
- 🧹 **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
|
- 📋 **Historique** : tableau filtrable (installations / suppressions / mises à jour / nettoyages) + export CSV
|
||||||
- 📜 **Logs** : journal `/var/log/pacman.log` intégré, avec filtre instantané
|
- 📜 **Logs** : journal `/var/log/pacman.log` intégré, avec filtre instantané
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ les widgets pour l'interface, le réseau pour l'auto-mise à jour et le magasin
|
|||||||
plugins. Rien d'autre n'est requis : les plugins Flatpak et AUR ne dépendent que
|
plugins. Rien d'autre n'est requis : les plugins Flatpak et AUR ne dépendent que
|
||||||
des outils qu'ils pilotent (`flatpak`, `yay`/`paru`), eux-mêmes facultatifs.
|
des outils qu'ils pilotent (`flatpak`, `yay`/`paru`), eux-mêmes facultatifs.
|
||||||
|
|
||||||
|
Ces paquets ne sont pas obligatoirement installés à la main : quand une mise à
|
||||||
|
jour de l'application doit recompiler et qu'il manque un de ces outils, elle les
|
||||||
|
installe elle-même via `pacman` dès que le mot de passe sudo est saisi (voir
|
||||||
|
[mise-a-jour.md](mise-a-jour.md)).
|
||||||
|
|
||||||
## Compiler
|
## Compiler
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
+34
-12
@@ -29,6 +29,25 @@ jour à proposer.
|
|||||||
| `lastCheckDate` | Date du dernier contrôle réussi : un seul appel réseau par jour. |
|
| `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. |
|
| `latestRemoteVersion` | Dernière version vue sur le serveur, affichable même sans réseau. |
|
||||||
|
|
||||||
|
## 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 :
|
||||||
|
|
||||||
|
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
|
||||||
|
écriture ») — l'utilisateur voit **pourquoi** le mot de passe est demandé ;
|
||||||
|
2. Le script de mise à jour commence par `pacman -T` puis
|
||||||
|
`sudo pacman -S --needed --noconfirm` avec les paquets manquants ;
|
||||||
|
3. La recompilation n'est tentée qu'ensuite.
|
||||||
|
|
||||||
|
Sur une machine complète, aucune étape de plus : `pacman -T` ne renvoie rien et
|
||||||
|
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.
|
||||||
|
|
||||||
## Les quatre méthodes d'installation
|
## Les quatre méthodes d'installation
|
||||||
|
|
||||||
Toutes installent **au même endroit : le dossier de l'exécutable en cours
|
Toutes installent **au même endroit : le dossier de l'exécutable en cours
|
||||||
@@ -38,11 +57,11 @@ arborescence de build de la même façon.
|
|||||||
|
|
||||||
| Méthode | Quand elle est choisie | Ce qui se passe |
|
| Méthode | Quand elle est choisie | Ce qui se passe |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| **Checkout** | Un dépôt source entoure le binaire (cas du développeur) | `git pull`, recompilation, installation dans le dossier du binaire. |
|
| **Checkout** | Un dépôt source entoure le binaire (cas du développeur) | Installe les déps manquantes, puis `git pull`, recompilation, installation dans le dossier du binaire. |
|
||||||
| **Clone** | Application installée sans dépôt, avec `git` + `cmake` + compilateur | Clone (puis `git pull`) dans `~/.local/share/PacManager/src`, compilation, installation en place. |
|
| **Clone** | Application installée sans dépôt, avec `git` (ou pacman pour l'installer) | Installe les déps manquantes, clone (puis `git pull`) dans `~/.local/share/PacManager/src`, compilation, installation en place. |
|
||||||
| **Prebuilt** | Pas d'outillage de compilation, mais une archive précompilée attachée à la release | Téléchargement et décompression de `PacManager-<version>-x86_64.tar.gz`. |
|
| **Prebuilt** | Pas d'outillage de compilation **et** pacman absent ou inutile, avec une archive précompilée attachée à la release | Téléchargement et décompression de `PacManager-<version>-x86_64.tar.gz`. |
|
||||||
| **Tarball** | `git` absent mais `cmake` + compilateur présents | Compilation des sources de la release, puis installation en place. |
|
| **Tarball** | `git` absent mais un toolchain présent **ou installable via pacman** | Installe les déps manquantes, compilation des sources de la release, puis installation en place. |
|
||||||
| *Aucune* | Ni outillage, ni archive attachée | Le dialogue propose d'**ouvrir la page des releases** au lieu d'un bouton qui échouerait. |
|
| *Aucune* | Ni outillage (réel ou installable), ni archive attachée | Le dialogue propose d'**ouvrir la page des releases** au lieu d'un bouton qui échouerait. |
|
||||||
|
|
||||||
Le choix est une **fonction pure** (`chooseUpdateMethod()` sur
|
Le choix est une **fonction pure** (`chooseUpdateMethod()` sur
|
||||||
`UpdateCapabilities` : checkout utilisable, `git`, `cmake`, compilateur, archive
|
`UpdateCapabilities` : checkout utilisable, `git`, `cmake`, compilateur, archive
|
||||||
@@ -53,9 +72,10 @@ précompilée, tarball), ce qui permet de le tester sans réseau ni outillage.
|
|||||||
1. Le contrôle de version (API Gitea) renvoie un tag plus récent.
|
1. Le contrôle de version (API Gitea) renvoie un tag plus récent.
|
||||||
2. La fenêtre affiche un dialogue : version disponible, méthode qui sera utilisée
|
2. La fenêtre affiche un dialogue : version disponible, méthode qui sera utilisée
|
||||||
et dossier cible (`methodDescription()`).
|
et dossier cible (`methodDescription()`).
|
||||||
3. `sudo` n'est demandé **que si le dossier cible n'est pas accessible en
|
3. `sudo` est demandé quand le dossier cible n'est pas accessible en écriture
|
||||||
écriture** (`binDirWritable()`), c'est-à-dire typiquement pour `/usr/bin`. Tout
|
(`binDirWritable()`), c'est-à-dire typiquement pour `/usr/bin`, **ou quand des
|
||||||
le reste se compile dans un dossier temporaire appartenant à l'utilisateur.
|
dépendances de compilation manquent** — voir la section ci-dessus. Tout le
|
||||||
|
reste se compile dans un dossier temporaire appartenant à l'utilisateur.
|
||||||
4. La mise à jour tourne en arrière-plan ; le binaire en cours d'exécution n'est
|
4. La mise à jour tourne en arrière-plan ; le binaire en cours d'exécution n'est
|
||||||
pas touché.
|
pas touché.
|
||||||
5. À la fin, l'application **relance** le binaire fraîchement installé
|
5. À la fin, l'application **relance** le binaire fraîchement installé
|
||||||
@@ -72,10 +92,11 @@ renomme** (`stagedInstallScript()`) : c'est ce qui permet d'écraser un binaire
|
|||||||
## Ce qui n'est jamais fait automatiquement
|
## Ce qui n'est jamais fait automatiquement
|
||||||
|
|
||||||
**Aucune archive précompilée n'est produite par le dépôt** : sans asset attaché à
|
**Aucune archive précompilée n'est produite par le dépôt** : sans asset attaché à
|
||||||
la release, ce sont les méthodes *Clone* ou *Tarball* qui s'appliquent, donc
|
la release, ce sont les méthodes *Clone* ou *Tarball* qui s'appliquent. Grâce à
|
||||||
`git`, `cmake` et un compilateur doivent être présents sur la machine. Une
|
l'installation automatique des dépendances, il suffit d'avoir `pacman` (donc
|
||||||
installation minimale (binaire seul) se met donc à jour en recompilant, ou pas du
|
d'être sur Arch) et de fournir le mot de passe sudo — `git`, `cmake`, le
|
||||||
tout — dans ce cas le dialogue ouvre la page des releases.
|
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.
|
||||||
|
|
||||||
## Vérifier à la main
|
## Vérifier à la main
|
||||||
|
|
||||||
@@ -95,6 +116,7 @@ tout — dans ce cas le dialogue ouvre la page des releases.
|
|||||||
| 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`. |
|
| 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. |
|
| 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. |
|
| 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. |
|
||||||
|
|
||||||
Voir aussi [installation.md](installation.md) pour les chemins concernés et
|
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
|
[operations.md](operations.md) pour le rôle de `sudo` dans le reste de
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
// Checks the Gitea repository for new releases and tracks the last check
|
// Checks the Gitea repository for new releases and tracks the last check
|
||||||
@@ -19,6 +20,10 @@
|
|||||||
// into ~/.local/share/PacManager/src, built, and installed in place;
|
// into ~/.local/share/PacManager/src, built, and installed in place;
|
||||||
// - Prebuilt: the release's prebuilt archive is unpacked (no compiler);
|
// - Prebuilt: the release's prebuilt archive is unpacked (no compiler);
|
||||||
// - Tarball: the release sources are built and installed in place.
|
// - Tarball: the release sources are built and installed in place.
|
||||||
|
// The three rebuilding methods (Checkout, Clone, Tarball) first make sure the
|
||||||
|
// build dependencies (base-devel, cmake, git, qt6-base) are installed: the
|
||||||
|
// update script asks pacman what is missing and installs it through sudo, so
|
||||||
|
// a minimal Arch system only needs its sudo password to self-update.
|
||||||
// The running binary stays untouched (it keeps the inode that was replaced on
|
// The running binary stays untouched (it keeps the inode that was replaced on
|
||||||
// disk); the UI hands over to the freshly installed build by relaunching it.
|
// disk); the UI hands over to the freshly installed build by relaunching it.
|
||||||
class UpdateManager : public QObject {
|
class UpdateManager : public QObject {
|
||||||
@@ -95,6 +100,16 @@ public:
|
|||||||
enum class UpdateMethod { None, Checkout, Clone, Prebuilt, Tarball };
|
enum class UpdateMethod { None, Checkout, Clone, Prebuilt, Tarball };
|
||||||
UpdateMethod updateMethod() const;
|
UpdateMethod updateMethod() const;
|
||||||
|
|
||||||
|
// Packages needed to rebuild the app. base-devel pulls gcc, make and the
|
||||||
|
// rest of the toolchain, git feeds the Clone method, and qt6-base provides
|
||||||
|
// the Widgets + Network modules the build links against.
|
||||||
|
static QStringList buildDependencies();
|
||||||
|
|
||||||
|
// Subset of buildDependencies() that pacman reports as missing (`pacman -T`,
|
||||||
|
// exit code 127), cached for the process lifetime. Empty when everything is
|
||||||
|
// installed, when pacman is absent (non-Arch system) or on Windows.
|
||||||
|
static QStringList missingBuildDependencies();
|
||||||
|
|
||||||
// Inputs of the strategy decision, split out so the choice is a pure
|
// Inputs of the strategy decision, split out so the choice is a pure
|
||||||
// function that can be unit-tested without a network, a filesystem or an
|
// function that can be unit-tested without a network, a filesystem or an
|
||||||
// installed toolchain.
|
// installed toolchain.
|
||||||
@@ -105,6 +120,9 @@ public:
|
|||||||
bool hasCompiler = false;
|
bool hasCompiler = false;
|
||||||
bool hasPrebuilt = false; // the release ships a prebuilt binary archive
|
bool hasPrebuilt = false; // the release ships a prebuilt binary archive
|
||||||
bool hasTarball = false; // the release ships a source tarball
|
bool hasTarball = false; // the release ships a source tarball
|
||||||
|
// pacman is available, so whatever build tool is missing can be
|
||||||
|
// installed (with the user's sudo password) before rebuilding.
|
||||||
|
bool canInstallPackages = false;
|
||||||
};
|
};
|
||||||
static UpdateMethod chooseUpdateMethod(const UpdateCapabilities& capabilities);
|
static UpdateMethod chooseUpdateMethod(const UpdateCapabilities& capabilities);
|
||||||
|
|
||||||
@@ -122,6 +140,14 @@ public:
|
|||||||
// binary.
|
// binary.
|
||||||
static QString stagedInstallScript();
|
static QString stagedInstallScript();
|
||||||
|
|
||||||
|
// Shell snippet run at the start of every rebuilding method: installs the
|
||||||
|
// build dependencies pacman reports as missing (`pacman -T`) through sudo,
|
||||||
|
// piping the given (already shell-quoted) password to `sudo -S`. Without a
|
||||||
|
// password, `sudo -n` keeps a passwordless-sudo setup working while a
|
||||||
|
// password-requiring one fails fast instead of hanging the background run.
|
||||||
|
// Exposed so the unit test can assert what the update would install.
|
||||||
|
static QString dependencyInstallScript(const QString& quotedPassword);
|
||||||
|
|
||||||
// Whether a self-update is possible with the current state.
|
// Whether a self-update is possible with the current state.
|
||||||
bool canSelfUpdate() const;
|
bool canSelfUpdate() const;
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,10 @@ BrowsePage::BrowsePage(AppCore* core, QWidget* parent) : Page(core, parent) {
|
|||||||
m_table,
|
m_table,
|
||||||
"Aucun paquet à afficher.\nLancez une recherche ou ouvrez la liste des "
|
"Aucun paquet à afficher.\nLancez une recherche ou ouvrez la liste des "
|
||||||
"paquets installés.");
|
"paquets installés.");
|
||||||
|
// The "Tout mettre à jour" button only makes sense on the updates tab, but
|
||||||
|
// there it must be usable without selecting a row first; the per-package
|
||||||
|
// buttons stay gated on the selection.
|
||||||
|
m_updateAllButton->setToolTip("Mettre à jour tous les paquets listés");
|
||||||
listLayout->addWidget(m_tableStack);
|
listLayout->addWidget(m_tableStack);
|
||||||
splitter->addWidget(listCard);
|
splitter->addWidget(listCard);
|
||||||
|
|
||||||
@@ -222,9 +226,24 @@ BrowsePage::BrowsePage(AppCore* core, QWidget* parent) : Page(core, parent) {
|
|||||||
m_installed = results;
|
m_installed = results;
|
||||||
if (m_mode == Mode::Installed) onFilterChanged(m_filterBar->text());
|
if (m_mode == Mode::Installed) onFilterChanged(m_filterBar->text());
|
||||||
} else if (mode == AppCore::ListMode::Updates) {
|
} else if (mode == AppCore::ListMode::Updates) {
|
||||||
|
// The "searching" hint is replaced by the outcome: an empty
|
||||||
|
// result means the system is up to date, not that the check
|
||||||
|
// is still running.
|
||||||
|
if (results.empty()) {
|
||||||
|
ui::setEmptyStateText(
|
||||||
|
m_tableStack,
|
||||||
|
"Aucune mise à jour disponible.\nVotre système est à "
|
||||||
|
"jour.");
|
||||||
|
}
|
||||||
if (m_mode == Mode::Updates) populateTable(results);
|
if (m_mode == Mode::Updates) populateTable(results);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
connect(core, &AppCore::busyChanged, this, [this](bool busy) {
|
||||||
|
// A listing started from elsewhere (dashboard) while the user was
|
||||||
|
// already on the updates tab would leave it without data: reload now
|
||||||
|
// that the core is free again.
|
||||||
|
if (!busy && m_mode == Mode::Updates && isVisible()) reloadCurrentView();
|
||||||
|
});
|
||||||
connect(core, &AppCore::busyChanged, this, [this](bool busy) {
|
connect(core, &AppCore::busyChanged, this, [this](bool busy) {
|
||||||
m_progressBar->setVisible(busy);
|
m_progressBar->setVisible(busy);
|
||||||
if (!busy) {
|
if (!busy) {
|
||||||
@@ -298,6 +317,19 @@ void BrowsePage::showInstalled(const QString& select) {
|
|||||||
|
|
||||||
void BrowsePage::showUpdates() {
|
void BrowsePage::showUpdates() {
|
||||||
setMode(Mode::Updates);
|
setMode(Mode::Updates);
|
||||||
|
// The update check is what the user came for: run it on every arrival on
|
||||||
|
// the tab (pacman caches its queries for a few seconds, so a click right
|
||||||
|
// after the dashboard loaded reuses that answer instead of respawning it).
|
||||||
|
// The "searching" hint replaces the empty-state text for the duration, so
|
||||||
|
// the tab never looks stuck on an empty table.
|
||||||
|
ui::setEmptyStateText(m_tableStack,
|
||||||
|
"Recherche des mises à jour en cours...\nLes résultats "
|
||||||
|
"s'afficheront automatiquement.");
|
||||||
|
if (core()->busy()) {
|
||||||
|
// Something else is loading (e.g. the dashboard asked for the counts):
|
||||||
|
// the busyChanged handler below reloads when the core frees up.
|
||||||
|
return;
|
||||||
|
}
|
||||||
start(core()->loadUpdates(), tr("Mises à jour"));
|
start(core()->loadUpdates(), tr("Mises à jour"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,6 +339,23 @@ void BrowsePage::setMode(Mode mode) {
|
|||||||
m_filterRow->setVisible(mode == Mode::Installed);
|
m_filterRow->setVisible(mode == Mode::Installed);
|
||||||
m_installButton->setVisible(mode == Mode::Search);
|
m_installButton->setVisible(mode == Mode::Search);
|
||||||
|
|
||||||
|
// "Tout mettre à jour" acts on the whole list, so it is only offered on the
|
||||||
|
// tab that displays pending updates; there it needs no row selection.
|
||||||
|
if (m_updateAllButton) {
|
||||||
|
m_updateAllButton->setVisible(mode == Mode::Updates);
|
||||||
|
m_updateAllButton->setEnabled(mode == Mode::Updates
|
||||||
|
&& core()->hasAvailableProvider());
|
||||||
|
}
|
||||||
|
|
||||||
|
// The updates tab rewrote the empty-state hint for its own states; restore
|
||||||
|
// the generic one so the other tabs never show a stale updates message.
|
||||||
|
if (mode != Mode::Updates) {
|
||||||
|
ui::setEmptyStateText(
|
||||||
|
m_tableStack,
|
||||||
|
"Aucun paquet à afficher.\nLancez une recherche ou ouvrez la liste des "
|
||||||
|
"paquets installés.");
|
||||||
|
}
|
||||||
|
|
||||||
// Clear any stale selection and reset the details panel
|
// Clear any stale selection and reset the details panel
|
||||||
m_table->clearSelection();
|
m_table->clearSelection();
|
||||||
resetDetails();
|
resetDetails();
|
||||||
|
|||||||
@@ -103,6 +103,13 @@ void showEmptyState(QStackedWidget* stack, bool empty) {
|
|||||||
if (stack) stack->setCurrentIndex(empty ? 1 : 0);
|
if (stack) stack->setCurrentIndex(empty ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setEmptyStateText(QStackedWidget* stack, const QString& hint) {
|
||||||
|
if (!stack) return;
|
||||||
|
// withEmptyState() puts the hint label second in the placeholder's layout:
|
||||||
|
// the only label of the stack, so this stays a safe lookup.
|
||||||
|
if (QLabel* label = stack->findChild<QLabel*>()) label->setText(hint);
|
||||||
|
}
|
||||||
|
|
||||||
QLabel* countLabel() {
|
QLabel* countLabel() {
|
||||||
QLabel* label = new QLabel();
|
QLabel* label = new QLabel();
|
||||||
label->setStyleSheet("font-size: 12px; color: #64748b; font-weight: 600;");
|
label->setStyleSheet("font-size: 12px; color: #64748b; font-weight: 600;");
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ QTableWidget* table(const QStringList& headers, bool allStretch = false);
|
|||||||
// so a screen with no result explains itself instead of showing a bare header.
|
// so a screen with no result explains itself instead of showing a bare header.
|
||||||
QStackedWidget* withEmptyState(QTableWidget* table, const QString& hint);
|
QStackedWidget* withEmptyState(QTableWidget* table, const QString& hint);
|
||||||
void showEmptyState(QStackedWidget* stack, bool empty);
|
void showEmptyState(QStackedWidget* stack, bool empty);
|
||||||
|
// Rewrites the hint shown while the listing is empty, so a screen can walk the
|
||||||
|
// user through its states ("searching..." then "nothing found").
|
||||||
|
void setEmptyStateText(QStackedWidget* stack, const QString& hint);
|
||||||
|
|
||||||
// Small grey counter ("12 paquet(s)").
|
// Small grey counter ("12 paquet(s)").
|
||||||
QLabel* countLabel();
|
QLabel* countLabel();
|
||||||
|
|||||||
+25
-6
@@ -1149,21 +1149,40 @@ void MainWindow::onCoreUpdateCheckFinished(bool hasUpdate, const QString& latest
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prompt for the sudo password only when the update must write into a
|
// Prompt for the sudo password when the update needs privileges: either the
|
||||||
// root-owned directory (e.g. /usr/bin). Every method installs into the
|
// final install writes into a root-owned directory (e.g. /usr/bin), or the
|
||||||
// running binary's directory, and only that final copy is privileged:
|
// build dependencies (qt6-base, cmake, gcc/base-devel, git) are missing and
|
||||||
// everything else builds in a temp directory owned by the user.
|
// the update script must install them first — on a minimal Arch system both
|
||||||
|
// are why the update cannot run unprivileged. The password is consumed by
|
||||||
|
// `sudo -S` inside the update script itself (install of the dependencies,
|
||||||
|
// then the final copy).
|
||||||
QString sudoPassword;
|
QString sudoPassword;
|
||||||
if (!m_core->binDirWritable()) {
|
const bool needsDeps = !UpdateManager::missingBuildDependencies().isEmpty();
|
||||||
|
if (!m_core->binDirWritable() || needsDeps) {
|
||||||
|
QString reason;
|
||||||
|
if (needsDeps) {
|
||||||
|
reason = QStringLiteral(
|
||||||
|
"Des dépendances de compilation manquent (%1).\n")
|
||||||
|
.arg(UpdateManager::missingBuildDependencies().join(", "));
|
||||||
|
} else {
|
||||||
|
reason = QStringLiteral("L'installation doit écrire dans %1.\n").arg(targetDir);
|
||||||
|
}
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
sudoPassword = QInputDialog::getText(
|
sudoPassword = QInputDialog::getText(
|
||||||
this, "Mise à jour",
|
this, "Mise à jour",
|
||||||
QString("Mot de passe sudo pour installer dans %1 :").arg(targetDir),
|
QString("%1Mot de passe sudo pour mettre à jour PacManager :\n")
|
||||||
|
.arg(reason),
|
||||||
QLineEdit::Password, QString(), &ok);
|
QLineEdit::Password, QString(), &ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
statusBar()->showMessage("Mise à jour annulée.");
|
statusBar()->showMessage("Mise à jour annulée.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!sudoPassword.isEmpty()) {
|
||||||
|
// The update pipeline also serves the other privileged flows, and
|
||||||
|
// it drops the password after each use: priming it here avoids a
|
||||||
|
// second prompt when the update itself was started from one.
|
||||||
|
m_core->setSudoPassword(sudoPassword);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qCInfo(pacmgrUpdate) << "applying update, method" << static_cast<int>(method)
|
qCInfo(pacmgrUpdate) << "applying update, method" << static_cast<int>(method)
|
||||||
|
|||||||
+83
-7
@@ -119,6 +119,50 @@ QString UpdateManager::releasePageUrl() const {
|
|||||||
return m_releasePageUrl;
|
return m_releasePageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Packages required to rebuild the app. base-devel is the Arch metapackage
|
||||||
|
// pulling the whole toolchain (gcc, make, sudo…), git feeds the Clone method
|
||||||
|
// and qt6-base provides the Widgets + Network modules the build links against.
|
||||||
|
// cmake ships in base-devel on current Arch but is listed explicitly so a
|
||||||
|
// stripped-down system still gets it.
|
||||||
|
QStringList UpdateManager::buildDependencies() {
|
||||||
|
return {QStringLiteral("base-devel"), QStringLiteral("cmake"),
|
||||||
|
QStringLiteral("gcc"), QStringLiteral("git"),
|
||||||
|
QStringLiteral("qt6-base")};
|
||||||
|
}
|
||||||
|
|
||||||
|
// `pacman -T` answers "which of these packages is NOT installed" (exit 127 with
|
||||||
|
// the missing names on stdout), the exact question the update asks. The result
|
||||||
|
// is cached for the process lifetime: a package does not vanish between the
|
||||||
|
// dialog and the update, and the check spawns one pacman per call.
|
||||||
|
QStringList UpdateManager::missingBuildDependencies() {
|
||||||
|
static QStringList cached;
|
||||||
|
static bool fetched = false;
|
||||||
|
if (fetched) return cached;
|
||||||
|
fetched = true;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
return cached;
|
||||||
|
#else
|
||||||
|
if (QProcess::execute("/bin/sh", {"-c", "command -v pacman >/dev/null 2>&1"}) != 0) {
|
||||||
|
return cached; // not an Arch system: nothing to install, and the
|
||||||
|
// rebuild methods will fail on their own if attempted
|
||||||
|
}
|
||||||
|
|
||||||
|
QProcess pacman;
|
||||||
|
QStringList args{QStringLiteral("-T")};
|
||||||
|
args += buildDependencies();
|
||||||
|
pacman.start("pacman", args);
|
||||||
|
if (!pacman.waitForFinished(15000)) return cached;
|
||||||
|
// simplified() collapses newlines and runs of spaces into single spaces:
|
||||||
|
// pacman -T prints the missing targets whitespace-separated, and splitting
|
||||||
|
// the raw output would keep line breaks inside the tokens.
|
||||||
|
cached = QString::fromUtf8(pacman.readAllStandardOutput())
|
||||||
|
.simplified()
|
||||||
|
.split(QLatin1Char(' '), Qt::SkipEmptyParts);
|
||||||
|
return cached;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Cached `command -v` lookup. The update dialog queries several tools on
|
// Cached `command -v` lookup. The update dialog queries several tools on
|
||||||
// every check; caching keeps that from spawning a shell per query.
|
// every check; caching keeps that from spawning a shell per query.
|
||||||
bool UpdateManager::toolAvailable(const char* tool) {
|
bool UpdateManager::toolAvailable(const char* tool) {
|
||||||
@@ -186,25 +230,33 @@ UpdateManager::UpdateMethod UpdateManager::updateMethod() const {
|
|||||||
capabilities.hasCompiler = compilerAvailable();
|
capabilities.hasCompiler = compilerAvailable();
|
||||||
capabilities.hasPrebuilt = !m_prebuiltUrl.isEmpty();
|
capabilities.hasPrebuilt = !m_prebuiltUrl.isEmpty();
|
||||||
capabilities.hasTarball = !m_tarballUrl.isEmpty();
|
capabilities.hasTarball = !m_tarballUrl.isEmpty();
|
||||||
|
// pacman present = every missing build tool can be installed first, which
|
||||||
|
// makes the Clone/Tarball methods reachable on a minimal Arch system.
|
||||||
|
capabilities.canInstallPackages = toolAvailable("pacman");
|
||||||
return chooseUpdateMethod(capabilities);
|
return chooseUpdateMethod(capabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strategy, in order of preference:
|
// Strategy, in order of preference:
|
||||||
// 1. Checkout: a source checkout is the developer's tree, pull + rebuild it;
|
// 1. Checkout: a source checkout is the developer's tree, pull + rebuild it;
|
||||||
// 2. Clone: rebuild from the real sources (git + cmake + compiler present),
|
// 2. Clone: rebuild from the real sources (git + cmake + compiler present, or
|
||||||
// so an installed app follows the repo whatever its location;
|
// installable through pacman first), so an installed app follows the repo
|
||||||
// 3. Prebuilt: no toolchain, unpack the release's binary archive;
|
// whatever its location;
|
||||||
// 4. Tarball: no git but a compiler, build the release sources.
|
// 3. Prebuilt: no toolchain and pacman cannot fill the gap, unpack the
|
||||||
|
// release's binary archive;
|
||||||
|
// 4. Tarball: no git but a buildable toolchain, build the release sources.
|
||||||
// Anything else cannot update locally and falls back to the releases page.
|
// Anything else cannot update locally and falls back to the releases page.
|
||||||
UpdateManager::UpdateMethod UpdateManager::chooseUpdateMethod(
|
UpdateManager::UpdateMethod UpdateManager::chooseUpdateMethod(
|
||||||
const UpdateCapabilities& capabilities) {
|
const UpdateCapabilities& capabilities) {
|
||||||
if (capabilities.checkoutUsable) return UpdateMethod::Checkout;
|
if (capabilities.checkoutUsable) return UpdateMethod::Checkout;
|
||||||
if (capabilities.hasGit && capabilities.hasCmake && capabilities.hasCompiler) {
|
const bool buildable = capabilities.hasCmake && capabilities.hasCompiler;
|
||||||
|
// pacman present = every missing build tool can be installed first, which
|
||||||
|
// makes the rebuilding methods reachable on a minimal Arch system.
|
||||||
|
const bool buildableWithPacman = capabilities.canInstallPackages;
|
||||||
|
if (capabilities.hasGit && (buildable || buildableWithPacman)) {
|
||||||
return UpdateMethod::Clone;
|
return UpdateMethod::Clone;
|
||||||
}
|
}
|
||||||
if (capabilities.hasPrebuilt) return UpdateMethod::Prebuilt;
|
if (capabilities.hasPrebuilt) return UpdateMethod::Prebuilt;
|
||||||
if (capabilities.hasTarball && capabilities.hasCmake
|
if (capabilities.hasTarball && (buildable || buildableWithPacman)) {
|
||||||
&& capabilities.hasCompiler) {
|
|
||||||
return UpdateMethod::Tarball;
|
return UpdateMethod::Tarball;
|
||||||
}
|
}
|
||||||
return UpdateMethod::None;
|
return UpdateMethod::None;
|
||||||
@@ -392,6 +444,27 @@ bool UpdateManager::isNewerVersion(const QString& remote, const QString& local)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shell snippet shared by every rebuilding method: asks pacman which of the
|
||||||
|
// build dependencies are missing (`pacman -T`, exit 127) and installs them
|
||||||
|
// through `pacman -S --needed --noconfirm`. --needed skips what is already
|
||||||
|
// installed, --noconfirm keeps the unattended update from blocking on a
|
||||||
|
// pacman prompt. With a password it is piped to `sudo -S`; without one, `-n`
|
||||||
|
// keeps a passwordless-sudo setup working while a password-requiring sudo
|
||||||
|
// fails fast instead of hanging the background run on an unanswerable prompt.
|
||||||
|
// On a fully equipped machine the whole block is skipped.
|
||||||
|
QString UpdateManager::dependencyInstallScript(const QString& quotedPassword) {
|
||||||
|
const QString sudoPrefix = quotedPassword.isEmpty()
|
||||||
|
? QStringLiteral("sudo -n")
|
||||||
|
: QStringLiteral("printf '%s\\n' %1 | sudo -S").arg(quotedPassword);
|
||||||
|
return QStringLiteral(
|
||||||
|
"MISSING=$(pacman -T %1 2>/dev/null || true)\n"
|
||||||
|
"if [ -n \"$MISSING\" ]; then\n"
|
||||||
|
" echo \"Installation des dependances de compilation : $MISSING\"\n"
|
||||||
|
" %2 pacman -S --needed --noconfirm $MISSING 2>&1\n"
|
||||||
|
"fi\n")
|
||||||
|
.arg(buildDependencies().join(QLatin1Char(' ')), sudoPrefix);
|
||||||
|
}
|
||||||
|
|
||||||
// Rebuilds + reinstalls the app in the background, using the strategy picked
|
// Rebuilds + reinstalls the app in the background, using the strategy picked
|
||||||
// by updateMethod(). The running process is untouched (it keeps the replaced
|
// by updateMethod(). The running process is untouched (it keeps the replaced
|
||||||
// inode); the caller relaunches into the new build. Exits non-zero on failure
|
// inode); the caller relaunches into the new build. Exits non-zero on failure
|
||||||
@@ -427,6 +500,7 @@ void UpdateManager::performSelfUpdate(const QString& sudoPassword) {
|
|||||||
// leave the copy in use (and its version marker) untouched.
|
// leave the copy in use (and its version marker) untouched.
|
||||||
void UpdateManager::performCheckoutUpdate(const QString& sudoPassword) {
|
void UpdateManager::performCheckoutUpdate(const QString& sudoPassword) {
|
||||||
QString script = updateScriptPrologue();
|
QString script = updateScriptPrologue();
|
||||||
|
script += dependencyInstallScript(quotedPassword(sudoPassword));
|
||||||
script += QStringLiteral(
|
script += QStringLiteral(
|
||||||
"git pull --ff-only origin main 2>&1 || git pull --ff-only 2>&1\n"
|
"git pull --ff-only origin main 2>&1 || git pull --ff-only 2>&1\n"
|
||||||
"if [ -d build ]; then\n"
|
"if [ -d build ]; then\n"
|
||||||
@@ -542,6 +616,7 @@ QString UpdateManager::quotedPassword(const QString& sudoPassword) {
|
|||||||
// running binary lives.
|
// running binary lives.
|
||||||
void UpdateManager::performCloneUpdate(const QString& sudoPassword) {
|
void UpdateManager::performCloneUpdate(const QString& sudoPassword) {
|
||||||
QString script = updateScriptPrologue();
|
QString script = updateScriptPrologue();
|
||||||
|
script += dependencyInstallScript(quotedPassword(sudoPassword));
|
||||||
script += QStringLiteral(
|
script += QStringLiteral(
|
||||||
"SRC=%1\n"
|
"SRC=%1\n"
|
||||||
"export SRC\n"
|
"export SRC\n"
|
||||||
@@ -593,6 +668,7 @@ void UpdateManager::performPrebuiltUpdate(const QString& sudoPassword) {
|
|||||||
// result where the running binary lives. Used only when git is unavailable.
|
// result where the running binary lives. Used only when git is unavailable.
|
||||||
void UpdateManager::performTarballUpdate(const QString& sudoPassword) {
|
void UpdateManager::performTarballUpdate(const QString& sudoPassword) {
|
||||||
QString script = updateScriptPrologue();
|
QString script = updateScriptPrologue();
|
||||||
|
script += dependencyInstallScript(quotedPassword(sudoPassword));
|
||||||
script += QStringLiteral(
|
script += QStringLiteral(
|
||||||
"command -v cmake >/dev/null 2>&1 || { echo 'cmake est requis pour la mise a jour'; exit 1; }\n"
|
"command -v cmake >/dev/null 2>&1 || { echo 'cmake est requis pour la mise a jour'; exit 1; }\n"
|
||||||
"URL=%1\n"
|
"URL=%1\n"
|
||||||
|
|||||||
@@ -119,6 +119,79 @@ static void testChooseMethod_noneWhenNothingAvailable() {
|
|||||||
"method_none_without_anything");
|
"method_none_without_anything");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pacman can install whatever build tool is missing, so a minimal Arch system
|
||||||
|
// (no cmake, no compiler, not even git) still reaches the rebuilding methods:
|
||||||
|
// the update script installs the dependencies first, with the sudo password the
|
||||||
|
// user typed in the update dialog.
|
||||||
|
static void testChooseMethod_pacmanUnlocksClone() {
|
||||||
|
Caps caps;
|
||||||
|
caps.canInstallPackages = true; // nothing else installed
|
||||||
|
caps.hasGit = true; // git is the only tool the clone path
|
||||||
|
// strictly needs up front (deps install
|
||||||
|
// brings cmake + the compiler)
|
||||||
|
check(UpdateManager::chooseUpdateMethod(caps) == Method::Clone,
|
||||||
|
"method_clone_with_pacman_only");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void testChooseMethod_pacmanWithoutGit_stillTarball() {
|
||||||
|
Caps caps;
|
||||||
|
caps.canInstallPackages = true;
|
||||||
|
caps.hasTarball = true; // no git: the tarball path also needs no tool now
|
||||||
|
check(UpdateManager::chooseUpdateMethod(caps) == Method::Tarball,
|
||||||
|
"method_tarball_with_pacman_only");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Without pacman there is no way to fill a missing toolchain: the prebuilt
|
||||||
|
// archive (when the release ships one) stays the only option.
|
||||||
|
static void testChooseMethod_noPacman_prebuiltStillFallback() {
|
||||||
|
Caps caps;
|
||||||
|
caps.hasGit = true; // git alone cannot build, and pacman cannot fix it
|
||||||
|
caps.hasPrebuilt = true;
|
||||||
|
check(UpdateManager::chooseUpdateMethod(caps) == Method::Prebuilt,
|
||||||
|
"method_prebuilt_without_pacman");
|
||||||
|
}
|
||||||
|
|
||||||
|
// The dependency list and its `pacman -T` probe are pure data/IO: the list is
|
||||||
|
// asserted literally so a rename cannot silently break the install script, and
|
||||||
|
// the missing-dependency lookup must agree with pacman itself (empty on this
|
||||||
|
// machine means "nothing to install", not "unknown").
|
||||||
|
static void testBuildDependencies() {
|
||||||
|
const QStringList deps = UpdateManager::buildDependencies();
|
||||||
|
check(deps.contains("base-devel"), "deps_base_devel");
|
||||||
|
check(deps.contains("cmake"), "deps_cmake");
|
||||||
|
check(deps.contains("gcc"), "deps_gcc");
|
||||||
|
check(deps.contains("qt6-base"), "deps_qt6_base");
|
||||||
|
check(deps.contains("git"), "deps_git");
|
||||||
|
|
||||||
|
// On a machine without pacman this is empty and the update simply keeps
|
||||||
|
// its current behaviour; with pacman it must never report an installed
|
||||||
|
// package as missing.
|
||||||
|
const QStringList missing = UpdateManager::missingBuildDependencies();
|
||||||
|
for (const QString& pkg : missing) {
|
||||||
|
check(deps.contains(pkg), "missing_dependency_is_from_the_list");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The generated snippet must install exactly what pacman -T reports, through
|
||||||
|
// sudo (with the password piped to -S), and skip everything on a complete
|
||||||
|
// system. Quoted here is the password safety: the quoting is the same as the
|
||||||
|
// one used for the install step.
|
||||||
|
static void testDependencyInstallScript() {
|
||||||
|
const QString script = UpdateManager::dependencyInstallScript("'secret'");
|
||||||
|
check(script.contains("pacman -T"), "script_asks_pacman_what_is_missing");
|
||||||
|
check(script.contains("base-devel"), "script_installs_base_devel");
|
||||||
|
check(script.contains("qt6-base"), "script_installs_qt6_base");
|
||||||
|
check(script.contains("--needed --noconfirm"), "script_pacman_flags");
|
||||||
|
check(script.contains("| sudo -S"), "script_pipes_password_to_sudo");
|
||||||
|
check(script.contains("'secret'"), "script_uses_the_given_password");
|
||||||
|
|
||||||
|
// No password: sudo -n fails fast on a password-requiring setup instead of
|
||||||
|
// hanging the background update on an unanswerable prompt.
|
||||||
|
const QString passwordless = UpdateManager::dependencyInstallScript(QString());
|
||||||
|
check(passwordless.contains("sudo -n"), "script_passwordless_uses_sudo_n");
|
||||||
|
check(!passwordless.contains("sudo -S"), "script_passwordless_has_no_pipe");
|
||||||
|
}
|
||||||
|
|
||||||
// Reconciliation of the two sources of truth: whichever is ahead wins, an empty
|
// Reconciliation of the two sources of truth: whichever is ahead wins, an empty
|
||||||
// side never does. This is what stops a release from being offered again when the
|
// side never does. This is what stops a release from being offered again when the
|
||||||
// binary and the installed marker disagree.
|
// binary and the installed marker disagree.
|
||||||
@@ -327,6 +400,11 @@ int main() {
|
|||||||
testChooseMethod_tarballWithoutGit();
|
testChooseMethod_tarballWithoutGit();
|
||||||
testChooseMethod_tarballRequiresCompiler();
|
testChooseMethod_tarballRequiresCompiler();
|
||||||
testChooseMethod_noneWhenNothingAvailable();
|
testChooseMethod_noneWhenNothingAvailable();
|
||||||
|
testChooseMethod_pacmanUnlocksClone();
|
||||||
|
testChooseMethod_pacmanWithoutGit_stillTarball();
|
||||||
|
testChooseMethod_noPacman_prebuiltStillFallback();
|
||||||
|
testBuildDependencies();
|
||||||
|
testDependencyInstallScript();
|
||||||
|
|
||||||
#if !defined(Q_OS_WIN)
|
#if !defined(Q_OS_WIN)
|
||||||
testStagedInstall_replacesRunningExecutable();
|
testStagedInstall_replacesRunningExecutable();
|
||||||
|
|||||||
Reference in new issue
Block a user