Skip to content

Instantly share code, notes, and snippets.

@TBog
Created April 18, 2022 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TBog/f07cd3d9620f4bd1ba3d26665e17ddb6 to your computer and use it in GitHub Desktop.
Save TBog/f07cd3d9620f4bd1ba3d26665e17ddb6 to your computer and use it in GitHub Desktop.
How to determine which packages need upgrading in Arch Linux

How to see what packages need an update without side-effects

The reason for not running pacman -Sy is to avoid installing packages from different package database updates.

Example: It's 5 days later when you've forgotten you ran pacman -Sy and run pacman -S nvidia that you're likely to break something

Solution

source 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.

see: System maintenance

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment