FS#62336 - [pacman-contrib] When there are updates available, checkupdates should exit non-zero

Attached to Project: Community Packages
Opened by Jonathan DeMasi (jrdemasi) - Sunday, 14 April 2019, 03:02 GMT
Last edited by Daniel M. Capella (polyzen) - Friday, 26 April 2019, 20:24 GMT
Task Type Feature Request
Category Packages
Status Closed
Assigned To Johannes Löthberg (demize)
Daniel M. Capella (polyzen)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
On other distros, such as RHEL/CentOS/Fedora, there is a function to check for package updates. (e.g. yum check-updates). Yum will exit with a status of 100 if there are updates available, and 0 if there are none. Having similar functionality in pacman-contrib's checkupdates would be useful for scripting and determining if a system is up-to-date.

Steps to reproduce:
Ensure you have pacman-contrib installed -- pacman -S pacman-contrib
Run checkupdates
echo $?

The output to the above will always be 0 assuming the script doesn't encounter any errors - this makes sense, but having a set exit status if there ARE updates would mean you could programmatically run checkupdates and generate reports, send emails, etc.
This task depends upon

Closed by  Daniel M. Capella (polyzen)
Friday, 26 April 2019, 20:24 GMT
Reason for closing:  Fixed
Additional comments about closing:  Resolved in https://git.archlinux.org/pacman-contrib .git/commit/?id=ab696663975c433c451d9927 f907a67a14441263
Comment by Dave Reisner (falconindy) - Sunday, 14 April 2019, 14:05 GMT
Note that pacman itself via '-Qu' will do the opposite -- an exit code of non-zero means no updates are available. It'd be nice to keep this consistent between pacman and checkupdates.
Comment by Jonathan DeMasi (jrdemasi) - Sunday, 14 April 2019, 19:40 GMT
That's probably a good point and makes a lot of sense.
Comment by Daniel M. Capella (polyzen) - Wednesday, 17 April 2019, 02:40 GMT Comment by Dave Reisner (falconindy) - Wednesday, 17 April 2019, 10:22 GMT
But that patch gives you the exit code of grep...
Comment by Daniel M. Capella (polyzen) - Wednesday, 17 April 2019, 15:41 GMT
Should I just fix the commit message or?
Comment by Dave Reisner (falconindy) - Wednesday, 17 April 2019, 17:20 GMT
No, fix the code so that it actually returns the exit code of pacman.

return ${PIPESTATUS[0]}
Comment by Daniel M. Capella (polyzen) - Thursday, 18 April 2019, 00:40 GMT Comment by Daniel M. Capella (polyzen) - Thursday, 18 April 2019, 21:12 GMT
With v2, if you are ignoring packages in your `pacman.conf`, checkupdates will show no updates and also not exit non-zero.

Loading...