is there a way to just print list of packages available for upgrade ?
I am using pacman (yay) of arch linux.
Thank you for help
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityThe package pacman-contrib
includes a script that can list all the pending updates without applying them, called checkupdates
. pacman-contrib is in the community repository
checkupdates - print a list of pending updates without touching the system sync databases (for safety on rolling release distributions).
pacman -Sy
or similar sets up for unintended—and unsupported—partial upgrades with subsequent pacman -S
.
Jun 12 at 1:24
First you need to update your local package repository databases:
sudo pacman -Sy
or pacman -Sy
as root.
Pacman then fetches the most recent database from your configured mirrors. (This is not an upgrade, this is just updating the list of available package versions)
Then use this command to list upgradable packages:
pacman -Qu
This command compares the installed versions of packages to the available ones in your local package repository databases. If you skip step one (above), this will likely produce an empty list.
Same applies to yay: yay -Sy; yay -Qu
.
Important Note: Arch does not support partial upgrades and running pacman -Sy
sets up for exactly that. See Arch Wiki for reference.
If you use this way to check for upgradable packages make sure you always install using pacman -Su $package
.
Since it can happen that the package version in your local database does not exist on the mirror anymore I recommend to always upgrade the system when installing a new package anyways.
So at the end its a tradeoff and choice of workflow in my opinion. The alternative of course is the solution mentioned by Alex which includes an extra package to achieve what you asked for, but without updating the systems package database.
Pacman is one of the best package managers out there (in my opinion) and as most of the time the Arch Linux Wiki is a great source of information: Arch Wiki
pacman -Sy
is not recommended as it sets up for an unintended—and unsupported—partial upgrade. See Alex's answer instead or the Arch Wiki.
Jun 12 at 1:29
I have never used yay, but for pacman, you can try something like this:
sudo pacman -S -u -p --print-format %n,%v
to get the number you can do the same thing just pipe it to wc -l
Prints a comma separated list of pkgnames,version
In the pacman man-page look for --print
& --printf
sudo pacman -S -u -p --print-format %n,%v
prints nothing even If I ave 5 upgradable packeges. But it looks like a lead to some elegant solution.
Nov 27 at 10:20
sudo pacman -S -u
and sudo pacman -S -u --print-format...
?
sudo pacman -S -u --print-format %n,%v
prints list of packages ready to upgrade :) Thanks
Nov 28 at 14:12