From 90bd30e351d2d107a3cad648eefda74424089091 Mon Sep 17 00:00:00 2001 From: Lukas Krejci Date: Thu, 9 Oct 2025 04:19:40 +0200 Subject: [PATCH] add support for system updates on fedora (#353) --- Modules/SystemUpdatePopout.qml | 2 +- Services/SystemUpdateService.qml | 65 ++++++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/Modules/SystemUpdatePopout.qml b/Modules/SystemUpdatePopout.qml index efd01a5d..76417456 100644 --- a/Modules/SystemUpdatePopout.qml +++ b/Modules/SystemUpdatePopout.qml @@ -171,7 +171,7 @@ DankPopout { return "Failed to check for updates:\n" + SystemUpdateService.errorMessage; } if (!SystemUpdateService.helperAvailable) { - return "No package manager found. Please install 'paru' or 'yay' to check for updates."; + return "No package manager found. Please install 'paru' or 'yay' on Arch-based systems to check for updates."; } if (SystemUpdateService.isChecking) { return "Checking for updates..."; diff --git a/Services/SystemUpdateService.qml b/Services/SystemUpdateService.qml index d26e8ccb..cd8aa5b0 100644 --- a/Services/SystemUpdateService.qml +++ b/Services/SystemUpdateService.qml @@ -19,7 +19,48 @@ Singleton { property bool distributionSupported: false property string shellVersion: "" - readonly property list supportedDistributions: ["arch", "cachyos", "manjaro", "endeavouros"] + readonly property var archBasedSettings: { + "listUpdatesParams": ["-Qu"], + "upgradeSettings": { + "params": ["-Syu"], + "requiresSudo": false + }, + "parserSettings": { + "lineRegex": /^(\S+)\s+([^\s]+)\s+->\s+([^\s]+)$/, + "entryProducer": function (match) { + return { + "name": match[1], + "currentVersion": match[2], + "newVersion": match[3], + "description": `${match[1]} ${match[2]} → ${match[3]}` + } + } + } + } + + readonly property var packageManagerParams: { + "yay": archBasedSettings, + "paru": archBasedSettings, + "dnf": { + "listUpdatesParams": ["list", "--upgrades", "--quiet", "--color=never"], + "upgradeSettings": { + "params": ["upgrade"], + "requiresSudo": true + }, + "parserSettings": { + "lineRegex": /^([^\s]+)\s+([^\s]+)\s+.*$/, + "entryProducer": function (match) { + return { + "name": match[1], + "currentVersion": "", + "newVersion": match[2], + "description": `${match[1]} → ${match[2]}` + } + } + } + } + } + readonly property list supportedDistributions: ["arch", "cachyos", "manjaro", "endeavouros", "fedora"] readonly property int updateCount: availableUpdates.length readonly property bool helperAvailable: pkgManager !== "" && distributionSupported @@ -63,7 +104,7 @@ Singleton { Process { id: helperDetection - command: ["sh", "-c", "which paru || which yay"] + command: ["sh", "-c", "which paru || which yay || which dnf"] onExited: (exitCode) => { if (exitCode === 0) { @@ -110,7 +151,7 @@ Singleton { isChecking = true hasError = false - updateChecker.command = [pkgManager, "-Qu"] + updateChecker.command = [pkgManager].concat(packageManagerParams[pkgManager].listUpdatesParams) updateChecker.running = true } @@ -118,15 +159,13 @@ Singleton { const lines = output.trim().split('\n').filter(line => line.trim()) const updates = [] + const regex = packageManagerParams[pkgManager].parserSettings.lineRegex + const entryProducer = packageManagerParams[pkgManager].parserSettings.entryProducer + for (const line of lines) { - const match = line.match(/^(\S+)\s+([^\s]+)\s+->\s+([^\s]+)$/) + const match = line.match(regex) if (match) { - updates.push({ - name: match[1], - currentVersion: match[2], - newVersion: match[3], - description: `${match[1]} ${match[2]} → ${match[3]}` - }) + updates.push(entryProducer(match)) } } @@ -137,7 +176,9 @@ Singleton { if (!distributionSupported || !pkgManager || updateCount === 0) return const terminal = Quickshell.env("TERMINAL") || "xterm" - const updateCommand = `${pkgManager} -Syu && echo "Updates complete! Press Enter to close..." && read` + const params = packageManagerParams[pkgManager].upgradeSettings.params.join(" ") + const sudo = packageManagerParams[pkgManager].upgradeSettings.requiresSudo ? "sudo" : "" + const updateCommand = `${sudo} ${pkgManager} ${params} && echo "Updates complete! Press Enter to close..." && read` updater.command = [terminal, "-e", "sh", "-c", updateCommand] updater.running = true @@ -149,4 +190,4 @@ Singleton { running: distributionSupported && pkgManager onTriggered: checkForUpdates() } -} \ No newline at end of file +}