fix(update): enable self-update for installed app via release tarball
release / release (push) Has been cancelled
tests / build-test (push) Has been cancelled

The update dialog offered a disabled button when running from an install prefix without a source checkout, and the version file lagged behind the release tag. Add a tarball download + rebuild + reinstall path to the same prefix (sudo only for system prefixes) and bump the version file to 1.3.1.
This commit is contained in:
BlackAngelTV committed 2026-09-10 20:08:08 +02:00
1 parent 4200f63b4f
commit 40a01b0060
4 files changed
+227 -55

No files matched your search

+51 -12
View File
@@ -5,10 +5,13 @@
#include <QTableWidget>
#include <QHeaderView>
#include <QTextEdit>
#include <QDesktopServices>
#include <QUrl>
#include <QMessageBox>
#include <QSplitter>
#include <QFrame>
#include <QFile>
#include <QFileInfo>
#include <QTextCursor>
#include <QListWidget>
#include <QListWidgetItem>
@@ -2158,9 +2161,10 @@ void MainWindow::onUpdateCheckFinished(bool hasUpdate, const QString& latestVers
return;
}
// Ask the user whether to update now or skip. When the source repo is
// available the update runs in the background (git pull + build); the
// running binary stays untouched until the next launch.
// Ask the user whether to update now or skip. The update runs in the
// background (git pull + rebuild from a checkout, or tarball download +
// rebuild + reinstall when installed); the running binary stays
// untouched until the next launch.
QMessageBox box(this);
box.setWindowTitle("Mise à jour disponible");
box.setIcon(QMessageBox::Information);
@@ -2170,25 +2174,60 @@ void MainWindow::onUpdateCheckFinished(bool hasUpdate, const QString& latestVers
.arg(latestVersion, UpdateManager::currentVersion()));
QPushButton* updateBtn = box.addButton("Mettre à jour", QMessageBox::AcceptRole);
QPushButton* skipBtn = box.addButton("Plus tard", QMessageBox::RejectRole);
box.addButton("Plus tard", QMessageBox::RejectRole);
if (!m_updateManager->canSelfUpdate()) {
// No source checkout: only point to the releases page.
// No source checkout and no tarball URL: fall back to the releases
// page instead of a disabled button.
updateBtn->setText("Ouvrir la page des releases");
box.setInformativeText(
"Le dépôt source n'est pas disponible sur ce système.\n"
"Téléchargez la nouvelle version depuis la page des releases.");
updateBtn->setEnabled(false);
} else if (m_updateManager->repoPath().isEmpty()) {
// Installed mode: tarball download + local build + reinstall to the
// same prefix (sudo only for system prefixes).
box.setInformativeText(
QString("La mise à jour va télécharger les sources, les compiler "
"et réinstaller l'application dans %1.\n"
"Redémarrez PacManager ensuite pour utiliser la nouvelle version.")
.arg(m_updateManager->installPrefix()));
}
box.exec();
if (box.clickedButton() == updateBtn) {
statusBar()->showMessage("Mise à jour en cours en arrière-plan...");
connect(m_updateManager, &UpdateManager::selfUpdateFinished,
this, &MainWindow::onSelfUpdateFinished);
m_updateManager->performSelfUpdate();
if (box.clickedButton() != updateBtn) {
// "Plus tard" (or closing the dialog) simply skips the update.
return;
}
// "Plus tard" (or closing the dialog) simply skips the update.
if (!m_updateManager->canSelfUpdate()) {
QDesktopServices::openUrl(QUrl(m_updateManager->releasePageUrl()));
return;
}
// System prefixes (/usr, /usr/local) need sudo for `cmake --install`.
// Prompt once for the password; user prefixes install without sudo.
QString sudoPassword;
const QString prefix = m_updateManager->installPrefix();
const bool prefixWritable =
QFileInfo(prefix).isWritable() || QFileInfo(prefix + "/bin").isWritable();
if (m_updateManager->repoPath().isEmpty() && !prefixWritable
&& m_pacman && m_pacman->isAvailable()) {
bool ok = false;
sudoPassword = QInputDialog::getText(
this, "Mise à jour",
QString("Mot de passe sudo pour installer dans %1 :").arg(prefix),
QLineEdit::Password, QString(), &ok);
if (!ok) {
statusBar()->showMessage("Mise à jour annulée.");
return;
}
}
statusBar()->showMessage("Mise à jour en cours en arrière-plan...");
connect(m_updateManager, &UpdateManager::selfUpdateFinished,
this, &MainWindow::onSelfUpdateFinished);
m_updateManager->performSelfUpdate(sudoPassword);
}
// Called when the background git pull + build finishes. Reports the result in