ArchUpdater: add AUR support
This commit is contained in:
parent
74e65d75cb
commit
a1f87c50bc
3 changed files with 195 additions and 80 deletions
|
|
@ -10,29 +10,54 @@ Singleton {
|
|||
|
||||
// Core properties
|
||||
readonly property bool busy: checkupdatesProcess.running
|
||||
readonly property int updates: updatePackages.length
|
||||
property var updatePackages: []
|
||||
readonly property bool aurBusy: checkAurUpdatesProcess.running
|
||||
readonly property int updates: repoPackages.length
|
||||
readonly property int aurUpdates: aurPackages.length
|
||||
readonly property int totalUpdates: updates + aurUpdates
|
||||
property var repoPackages: []
|
||||
property var aurPackages: []
|
||||
property var selectedPackages: []
|
||||
property int selectedPackagesCount: 0
|
||||
property bool updateInProgress: false
|
||||
|
||||
// Initial check
|
||||
Component.onCompleted: doPoll()
|
||||
Component.onCompleted: {
|
||||
doPoll()
|
||||
doAurPoll()
|
||||
}
|
||||
|
||||
// Process for checking updates
|
||||
// Process for checking repo updates
|
||||
Process {
|
||||
id: checkupdatesProcess
|
||||
command: ["checkupdates"]
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode !== 0 && exitCode !== 2) {
|
||||
Logger.warn("ArchUpdater", "checkupdates failed (code:", exitCode, ")")
|
||||
updatePackages = []
|
||||
repoPackages = []
|
||||
}
|
||||
}
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
parseCheckupdatesOutput(text)
|
||||
Logger.log("ArchUpdater", "found", updatePackages.length, "upgradable package(s)")
|
||||
Logger.log("ArchUpdater", "found", repoPackages.length, "repo package(s) to upgrade")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process for checking AUR updates
|
||||
Process {
|
||||
id: checkAurUpdatesProcess
|
||||
command: ["sh", "-c", "command -v yay >/dev/null 2>&1 && yay -Qua || command -v paru >/dev/null 2>&1 && paru -Qua || echo ''"]
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode !== 0) {
|
||||
Logger.warn("ArchUpdater", "AUR check failed (code:", exitCode, ")")
|
||||
aurPackages = []
|
||||
}
|
||||
}
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
parseAurUpdatesOutput(text)
|
||||
Logger.log("ArchUpdater", "found", aurPackages.length, "AUR package(s) to upgrade")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -49,12 +74,34 @@ Singleton {
|
|||
"name": m[1],
|
||||
"oldVersion": m[2],
|
||||
"newVersion": m[3],
|
||||
"description": `${m[1]} ${m[2]} -> ${m[3]}`
|
||||
"description": `${m[1]} ${m[2]} -> ${m[3]}`,
|
||||
"source": "repo"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
updatePackages = packages
|
||||
repoPackages = packages
|
||||
}
|
||||
|
||||
// Parse AUR updates output
|
||||
function parseAurUpdatesOutput(output) {
|
||||
const lines = output.trim().split('\n').filter(line => line.trim())
|
||||
const packages = []
|
||||
|
||||
for (const line of lines) {
|
||||
const m = line.match(/^(\S+)\s+([^\s]+)\s+->\s+([^\s]+)$/)
|
||||
if (m) {
|
||||
packages.push({
|
||||
"name": m[1],
|
||||
"oldVersion": m[2],
|
||||
"newVersion": m[3],
|
||||
"description": `${m[1]} ${m[2]} -> ${m[3]}`,
|
||||
"source": "aur"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
aurPackages = packages
|
||||
}
|
||||
|
||||
// Check for updates
|
||||
|
|
@ -64,15 +111,26 @@ Singleton {
|
|||
checkupdatesProcess.running = true
|
||||
}
|
||||
|
||||
// Update all packages
|
||||
// Check for AUR updates
|
||||
function doAurPoll() {
|
||||
if (aurBusy)
|
||||
return
|
||||
checkAurUpdatesProcess.running = true
|
||||
}
|
||||
|
||||
// Update all packages (repo + AUR)
|
||||
function runUpdate() {
|
||||
if (updates === 0) {
|
||||
if (totalUpdates === 0) {
|
||||
doPoll()
|
||||
doAurPoll()
|
||||
return
|
||||
}
|
||||
|
||||
updateInProgress = true
|
||||
// Update repos first, then AUR
|
||||
Quickshell.execDetached(["pkexec", "pacman", "-Syu", "--noconfirm"])
|
||||
Quickshell.execDetached(
|
||||
["sh", "-c", "command -v yay >/dev/null 2>&1 && yay -Sua --noconfirm || command -v paru >/dev/null 2>&1 && paru -Sua --noconfirm || true"])
|
||||
|
||||
// Refresh after updates with multiple attempts
|
||||
refreshAfterUpdate()
|
||||
|
|
@ -84,8 +142,29 @@ Singleton {
|
|||
return
|
||||
|
||||
updateInProgress = true
|
||||
const command = ["pkexec", "pacman", "-S", "--noconfirm"].concat(selectedPackages)
|
||||
Quickshell.execDetached(command)
|
||||
// Split selected packages by source
|
||||
const repoPkgs = selectedPackages.filter(pkg => {
|
||||
const repoPkg = repoPackages.find(p => p.name === pkg)
|
||||
return repoPkg && repoPkg.source === "repo"
|
||||
})
|
||||
const aurPkgs = selectedPackages.filter(pkg => {
|
||||
const aurPkg = aurPackages.find(p => p.name === pkg)
|
||||
return aurPkg && aurPkg.source === "aur"
|
||||
})
|
||||
|
||||
// Update repo packages
|
||||
if (repoPkgs.length > 0) {
|
||||
const repoCommand = ["pkexec", "pacman", "-S", "--noconfirm"].concat(repoPkgs)
|
||||
Quickshell.execDetached(repoCommand)
|
||||
}
|
||||
|
||||
// Update AUR packages
|
||||
if (aurPkgs.length > 0) {
|
||||
const aurCommand = ["sh", "-c", `command -v yay >/dev/null 2>&1 && yay -S ${aurPkgs.join(
|
||||
' ')} --noconfirm || command -v paru >/dev/null 2>&1 && paru -S ${aurPkgs.join(
|
||||
' ')} --noconfirm || true`]
|
||||
Quickshell.execDetached(aurCommand)
|
||||
}
|
||||
|
||||
// Clear selection and refresh
|
||||
selectedPackages = []
|
||||
|
|
@ -105,7 +184,7 @@ Singleton {
|
|||
}
|
||||
|
||||
function selectAllPackages() {
|
||||
selectedPackages = updatePackages.map(pkg => pkg.name)
|
||||
selectedPackages = [...repoPackages.map(pkg => pkg.name), ...aurPackages.map(pkg => pkg.name)]
|
||||
selectedPackagesCount = selectedPackages.length
|
||||
}
|
||||
|
||||
|
|
@ -123,22 +202,26 @@ Singleton {
|
|||
// First refresh attempt after 3 seconds
|
||||
Qt.callLater(() => {
|
||||
doPoll()
|
||||
doAurPoll()
|
||||
}, 3000)
|
||||
|
||||
// Second refresh attempt after 8 seconds
|
||||
Qt.callLater(() => {
|
||||
doPoll()
|
||||
doAurPoll()
|
||||
}, 8000)
|
||||
|
||||
// Third refresh attempt after 15 seconds
|
||||
Qt.callLater(() => {
|
||||
doPoll()
|
||||
doAurPoll()
|
||||
updateInProgress = false
|
||||
}, 15000)
|
||||
|
||||
// Final refresh attempt after 30 seconds
|
||||
Qt.callLater(() => {
|
||||
doPoll()
|
||||
doAurPoll()
|
||||
}, 30000)
|
||||
}
|
||||
|
||||
|
|
@ -152,6 +235,9 @@ Singleton {
|
|||
interval: 15 * 60 * 1000 // 15 minutes
|
||||
repeat: true
|
||||
running: true
|
||||
onTriggered: doPoll()
|
||||
onTriggered: {
|
||||
doPoll()
|
||||
doAurPoll()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue