2

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

3 Answers 3

7

The 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

pacman-contrib source

checkupdates - print a list of pending updates without touching the system sync databases (for safety on rolling release distributions).

1
  • This is the correct answer. In most cases you do not want to update the main package database when simply checking for available updates. Updating the main database with pacman -Sy or similar sets up for unintended—and unsupported—partial upgrades with subsequent pacman -S. Jun 12 at 1:24
3

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

2
  • Using 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
  • thank you! You are correct and I adjusted my answer to create awareness.
    – Bone
    Jun 13 at 8:27
1

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

3
  • 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
  • That's interesting. You see different results when you run sudo pacman -S -u and sudo pacman -S -u --print-format...?
    – hba
    Nov 28 at 13:58
  • sudo pacman -S -u --print-format %n,%v prints list of packages ready to upgrade :) Thanks Nov 28 at 14:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .