You are not logged in.

#1 2024-06-14 23:43:03

Nikolai5
Member
From: North West, England, UK
Registered: 2024-01-27
Posts: 178

Custom Pacman hook failing to "execute correctly" [Resolved]

Hi,

I don't use an AUR helper, however I have installed auracle so that I can search the AUR from the terminal and also check for outdated packages using it's "outdated" command.
I thought it might be useful to include as a hook similar to "checkrebuild".

However when running it seems to fail with the following:

(2/3) Check for outdated foreign / AUR packages.
error: command failed to execute correctly

I can't find any logs that elaborate further on what exactly it doesn't like about the command or the hook.

This is the hook file (/etc/pacman.d/hooks/auracle-outdated.hook):

[Trigger]
Operation = Upgrade
Type = Package
Target = *

[Action]
Description = Check for outdated foreign / AUR packages.
Exec = /usr/bin/auracle outdated
When = PostTransaction
NeedsTargets

I've tried wrapping the command in quotes, but same result and I checked the hooks in /usr/share/libalpm/hooks and they contain execs with a command written like that without quotes, so I don't think its that.

Is it that pacman or alpm doesn't like the output of the program? Or am I configuring something wrong here. As far as I've understood from the wiki and the alpm manual, this should work OK.

Edit: Resolved in post 4 & 5.

Last edited by Nikolai5 (2024-06-16 12:10:22)


Desktop: Ryzen 7 1800X | AMD 7800XT | KDE Plasma
MacbookPro-2012 | MATE

Offline

#2 2024-06-15 01:09:04

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,464
Website

Re: Custom Pacman hook failing to "execute correctly" [Resolved]

My guess is you do not need "NeedsTargets".

Offline

#3 2024-06-15 01:25:06

Nikolai5
Member
From: North West, England, UK
Registered: 2024-01-27
Posts: 178

Re: Custom Pacman hook failing to "execute correctly" [Resolved]

I had that thought as well and removed it, but same result.


Desktop: Ryzen 7 1800X | AMD 7800XT | KDE Plasma
MacbookPro-2012 | MATE

Offline

#4 2024-06-15 06:54:19

seth
Member
Registered: 2012-09-03
Posts: 57,455

Re: Custom Pacman hook failing to "execute correctly" [Resolved]

Leaving aside that auracle tries to query the package list (not sure whether alpm is fine with that at this point) it'll return EIO on network erros and ENOENT when there're no outdated packages.
=> wrap the call into a script and handle the return code, "nothing to do" isn't an error in this context.

Offline

#5 2024-06-16 12:09:50

Nikolai5
Member
From: North West, England, UK
Registered: 2024-01-27
Posts: 178

Re: Custom Pacman hook failing to "execute correctly" [Resolved]

Good idea Seth, on testing you are right, it doesn't like the output when there are no outdated packages.

I've managed to get it working:

:: Running post-transaction hooks...
(1/3) Arming ConditionNeedsUpdate...
(2/3) Checking for outdated foreign packages
rate-mirrors 0.16.3-1 -> 0.17.1-1
(3/3) Checking which packages need to be rebuilt

:: Running post-transaction hooks...
(1/3) Arming ConditionNeedsUpdate...
(2/3) Checking for outdated foreign packages
Nothing to update
(3/3) Checking which packages need to be rebuilt

As suggested I just did a simple with an if statement and exec that rather than the program directly.

#!/usr/bin/bash

output=`auracle outdated`

if [[ $output == "" ]]
then
        echo "Nothing to update"
else
        echo $output
fi

Probably not the best way of doing it, but its working as expected now.


Desktop: Ryzen 7 1800X | AMD 7800XT | KDE Plasma
MacbookPro-2012 | MATE

Offline

#6 2024-06-16 12:43:52

seth
Member
Registered: 2012-09-03
Posts: 57,455

Re: Custom Pacman hook failing to "execute correctly" [Resolved]

Probably not the best way of doing it, but its working as expected now.

It's probably the only sane way of doing it - you could file an upstream request to (optionally) return 0 even if there's nothing to do but that hardly achieves much else then depriving you of an easy way to discriminate that situation.

However tather than storing and testing the output you can just sanitize the return:

auracle outdated
result=$?
[ $result = 0 -o $result = 2 ] && exit 0
exit 1 # fail

This should™ still fail hard if something goes wrong w/ auracle.

Offline

#7 2024-06-16 12:51:57

Nikolai5
Member
From: North West, England, UK
Registered: 2024-01-27
Posts: 178

Re: Custom Pacman hook failing to "execute correctly" [Resolved]

I'll take a look at that, thanks.

I don't have a huge amount of AUR packages that I'm using, but my previous method of manually going into each package folder I have inside ~/Programs/AUR/*bunch of aur cloned directories* and git pulling, etc just didn't seem scalable, and I don't like the idea of a set-up that doesn't still work when it increases in scale.
And I didn't want to start using an AUR helper, I've so far (fingers crossed) not had a single packaging issue while using Arch and I put it down to me sticking to the rules.


Desktop: Ryzen 7 1800X | AMD 7800XT | KDE Plasma
MacbookPro-2012 | MATE

Offline

Board footer

Powered by FluxBB