feat(update): install missing build dependencies before rebuilding

A minimal Arch system has no cmake, no compiler and no qt6-base, so the
self-update used to fail or fall back to the releases page. The update
now asks pacman what is missing, installs it through sudo with the
password typed in the update dialog, then resumes the build.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
BlackAngelTV committed 2026-09-23 21:58:21 +02:00
1 parent 5b24cea9c8
commit b204d6814a
4 files changed
+212 -13

No files matched your search

+25 -6
View File
@@ -1149,21 +1149,40 @@ void MainWindow::onCoreUpdateCheckFinished(bool hasUpdate, const QString& latest
return;
}
// Prompt for the sudo password only when the update must write into a
// root-owned directory (e.g. /usr/bin). Every method installs into the
// running binary's directory, and only that final copy is privileged:
// everything else builds in a temp directory owned by the user.
// Prompt for the sudo password when the update needs privileges: either the
// final install writes into a root-owned directory (e.g. /usr/bin), or the
// build dependencies (qt6-base, cmake, gcc/base-devel, git) are missing and
// the update script must install them first — on a minimal Arch system both
// are why the update cannot run unprivileged. The password is consumed by
// `sudo -S` inside the update script itself (install of the dependencies,
// then the final copy).
QString sudoPassword;
if (!m_core->binDirWritable()) {
const bool needsDeps = !UpdateManager::missingBuildDependencies().isEmpty();
if (!m_core->binDirWritable() || needsDeps) {
QString reason;
if (needsDeps) {
reason = QStringLiteral(
"Des dépendances de compilation manquent (%1).\n")
.arg(UpdateManager::missingBuildDependencies().join(", "));
} else {
reason = QStringLiteral("L'installation doit écrire dans %1.\n").arg(targetDir);
}
bool ok = false;
sudoPassword = QInputDialog::getText(
this, "Mise à jour",
QString("Mot de passe sudo pour installer dans %1 :").arg(targetDir),
QString("%1Mot de passe sudo pour mettre à jour PacManager :\n")
.arg(reason),
QLineEdit::Password, QString(), &ok);
if (!ok) {
statusBar()->showMessage("Mise à jour annulée.");
return;
}
if (!sudoPassword.isEmpty()) {
// The update pipeline also serves the other privileged flows, and
// it drops the password after each use: priming it here avoids a
// second prompt when the update itself was started from one.
m_core->setSudoPassword(sudoPassword);
}
}
qCInfo(pacmgrUpdate) << "applying update, method" << static_cast<int>(method)