9 Commits
Author SHA1 Message Date
BlackAngelTV d27792975e Merge branch 'main' of https://gitea.nocode-var.tech/FWS/FWS-PacManage 2026-10-30 18:04:51 +01:00
BlackAngelTV c23308f78e Fix(update): chaine de SU 2026-10-30 18:04:04 +01:00
BlackAngelTV 9343f53bae Merge pull request 'Release 1.6.1' (#25) from release-1.6.1 into main
Reviewed-on: #25
2026-10-30 16:50:02 +00:00
BlackAngelTV 111143cd4c chore(release): 1.6.1
The journal fix and the file feedback of this branch ship together,
with nothing else: 1.6.0 stays the feature release it was.
2026-10-09 19:22:27 +02:00
BlackAngelTV 55718064a6 feat(files): confirm dropped files and refuse the ones already installed
A drop — or "Ouvrir avec PacManager" — answered nothing: a Flatpak
install walked off into the background and a plugin package landed
without a sound, so the gesture read as ignored. Both now open a
dialog saying what was taken and what it starts.

A file the machine already has is refused before anything runs, and
named. The application a file would install is read out of the file
itself (the [Flatpak Ref] section of a .flatpakref, the header of a
.flatpak bundle, the manifest of a .fwspacm) and compared with what
the provider has, so nothing is started to find out: Flatpak would
otherwise skip the install and report a success the user never got,
and a plugin package would silently replace the one in place.
2026-10-09 19:22:24 +02:00
BlackAngelTV f4aa661b54 fix(logging): keep Qt's platform chatter out of the journal
Opening a dialog under Wayland made Qt write a burst of qt.qpa
warnings into the application journal — the text-input focus one,
repeated at every prompt — where the user can do nothing with them:
they describe the display server, not the application. Those
categories stay on stderr from now on, next to everything else, while
what the application logs (its own categories, and a bare qCWarning)
keeps going to the journal.
2026-10-09 19:22:19 +02:00
BlackAngelTV bea3d61045 Merge branch 'release-1.6.0' into main
The release moved every source into its own layer (core/, app/, pages/,
providers/, preferences/, logging/, archive/, update/, translations/) and
replaced the plugin shop with .fwspacm packages. main added the headless update
check run at login. Both sides are kept, the feature moved onto the new layout:

- core/startup-check.{h,cpp} and its test, wired into the CMake targets the
  release renamed (core/startup-check.cpp, startup-check-test);
- app/main.cpp carries the --check-updates branch, ahead of the command line so
  the login unit never opens a window;
- the settings menu keeps the "check at startup" toggle, now through tr(), and
  translations/en.json gains the new strings;
- doc/mise-a-jour.md keeps the release's version and gains the startup-check
  section; the documented test count follows the new target.
2026-10-09 17:56:53 +02:00
BlackAngelTVandCodebuff 3a77cb8f42 docs: documenter la vérification des mises à jour au démarrage
Mode --check-updates headless, service systemd --user auto-installé, réglage
Paramètres, notification urgente, et le mode pacman -Qu de repli.

Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-10-04 20:03:12 +02:00
BlackAngelTVandCodebuff 65b3496b42 feat(pkgcheck): vérification des mises à jour au démarrage sans mdp + notif
Le mode headless --check-updates (QT Core uniquement) synchro checkupdates
sans root, classe les paquets critiques (noyau, glibc, systemd, graphics),
envoie une notif urgente via notify-send quand c'est nécessaire, et installe
soi-même son service systemd --user (paramètre actif par défaut) pour
lancer la vérification à chaque ouverture de session. Ajout de tests
d'unité et de doc.

Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-10-04 20:02:41 +02:00
31 changed files with 1586 additions and 31 deletions

No files matched your search

+16
View File
@@ -38,6 +38,8 @@ set(SOURCES
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
@@ -72,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
@@ -218,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)
@@ -307,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):
+2 -1
View File
@@ -53,7 +53,7 @@ download. Once built:
cd build && ctest --output-on-failure
```
There are **12 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
@@ -73,6 +73,7 @@ replaying a request**, so it can never run pacman as root.
| `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.
+2 -1
View File
@@ -53,7 +53,7 @@ framework, pas de téléchargement. Après avoir compilé :
cd build && ctest --output-on-failure
```
Ce sont **12 tests**. La plupart sont unitaires et ne touchent pas au système ;
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
@@ -73,6 +73,7 @@ rejouer une requête**, donc sans jamais exécuter pacman en root.
| `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.
+52 -1
View File
@@ -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).
+101 -1
View File
@@ -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;
+10 -1
View File
@@ -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;
};
+17
View File
@@ -10,6 +10,7 @@
#include "language-manager.h"
#include "log-manager.h"
#include "main-window.h"
#include "startup-check.h"
#include "update-manager.h"
namespace {
@@ -29,6 +30,22 @@ QStringList commandLineArguments(int argc, char* argv[]) {
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.
+112
View File
@@ -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
// ---------------------------------------------------------------------------
+29
View File
@@ -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
+347
View File
@@ -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;
}
+118
View File
@@ -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);
};
+9
View File
@@ -51,6 +51,15 @@ Depuis un paquet installé, la sortie part dans le journal :
journalctl --user -f | grep pacmgr
```
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
+18
View File
@@ -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.
+53
View File
@@ -292,6 +292,59 @@ 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 |
+1
View File
@@ -96,6 +96,7 @@ Copiez `providers/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.
+8 -5
View File
@@ -16,16 +16,17 @@ 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
@@ -90,8 +91,10 @@ est donc autant une vérification de comportement qu'un garde-fou d'architecture
- 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.
+20
View File
@@ -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
View File
@@ -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
View File
@@ -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();
+109 -1
View File
@@ -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();
+17 -1
View File
@@ -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;
};
+31
View File
@@ -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;
+39
View File
@@ -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;
+187
View File
@@ -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;
}
+206
View File
@@ -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;
}
+7
View File
@@ -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,6 +38,10 @@
"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>",
@@ -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)...",
+12
View File
@@ -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,6 +38,10 @@
"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>",
@@ -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",
+7
View File
@@ -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,6 +38,10 @@
"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>",
@@ -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)...",
+7
View File
@@ -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,6 +38,10 @@
"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>",
@@ -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)...",
+11 -3
View File
@@ -579,18 +579,26 @@ QString UpdateManager::stagedInstallScript() {
// Install command: the action runs in a child `sh` (so it may be a compound
// command and expands the exported paths), through sudo when a password was
// provided or the target directory is not writable.
//
// The paths are handed to the child through `env` because sudo resets the
// environment (env_reset, the default): the exports from the prologue would be
// dropped and the install script would run `mkdir -p ""` on a system-wide
// install (/usr/bin and the like). They are expanded by the unprivileged shell
// that still has them, since the action itself is single-quoted.
QString UpdateManager::installCommand(const QString& quotedPassword,
const QString& action) const {
const QString quotedAction = quoteShell(action);
const QString passThrough = QStringLiteral(
"env BIN_DIR=\"$BIN_DIR\" STAGE=\"$STAGE\" APP_VERSION=\"$APP_VERSION\"");
if (!quotedPassword.isEmpty()) {
// NOTE: single %s — QString::arg() only substitutes %1..%99.
return QStringLiteral("printf '%s\\n' %1 | sudo -S sh -c %2 2>&1\n")
.arg(quotedPassword, quotedAction);
return QStringLiteral("printf '%s\\n' %1 | sudo -S %2 sh -c %3 2>&1\n")
.arg(quotedPassword, passThrough, quotedAction);
}
if (QFileInfo(binDir()).isWritable()) {
return QStringLiteral("sh -c %1 2>&1\n").arg(quotedAction);
}
return QStringLiteral("sudo sh -c %1 2>&1\n").arg(quotedAction);
return QStringLiteral("sudo %1 sh -c %2 2>&1\n").arg(passThrough, quotedAction);
}
QString UpdateManager::quotedBinDir() const {
+1 -1
View File
@@ -1 +1 @@
1.6.0
1.6.1