How to determine which packages need upgrading in Arch Linux?

I know that pacman -Su upgrades all packages. But how can I get just the list of packages that need upgrading?


Solution 1:

Looking at the man page something like

pacman -Sy

to sync the database up to the latest version followed by

pacman -Qu

to

-u, --upgrades

Restrict or filter output to packages that are out of date on the

local system. (Only package versions are used to find outdated packages, replacements are not checked here.) This option works best if the sync database is refreshed using -Sy.


Please note that syncing the package list like this will leave you in a situation where you should not install or upgrade single packages, until you have performed the next full update.

In general you should not upgrade individual packages, because partial upgrades are not supported in Arch or Manjaro. If you see a package that needs upgrading, you should really run pacman -Syu to upgrade all the packages at once.

While installing or upgrading a single package might work sometimes, there is a danger that it will upgrade a library it depends on, and that library upgrade could cause another package to break.

Solution 2:

checkupdates

The bash script checkupdates, included with the pacman-contrib package, provides a safe way to check for upgrades to installed packages without running a system update at the same time.

System Maintenance

Solution 3:

As @Panagiotis mentioned, checkupdates provides a way to do this without requiring root or messing up your /var/lib/pacman database. Here's a minimal version of checkupdates:

TMPPATH="${TMPDIR:-/tmp}/checkup-db-${USER}"
DBPATH="$(pacman-conf DBPath)"

mkdir -p "$TMPPATH"
ln -s "$DBPATH/local" "$TMPPATH" &>/dev/null
fakeroot -- pacman -Sy --dbpath "$TMPPATH" --logfile /dev/null &>/dev/null
pacman -Qu --dbpath "$TMPPATH" 2>/dev/null

It works by:

  1. Creating a temporary folder for your database.
  2. Symlinking your /var/lib/pacman/local.
  3. Running pacman -Sy on your temporary folder.
  4. Querying via pacman -Qu on your temporary folder.