2

What's the right way to ensure that a package installation with pacman has completed successfully when using pacman in a script?

During the recent repository outage of MSYS2, which uses pacman, I discovered that an installation with

pacman -S --noconfirm somepackage1 somepackage2

will still give an exit code of 0 despite not having installed the requested packages if it didn't attempt to install them because all dependent package download attempts timed out.

I've now added package queries after the supposed installation that definitely exit with 1 when the given package was not installed, which will take care of this exact case:

pacman -Qi somepackage

But I wonder if there are other types of package installation failure I don't know about that pacman also returns 0 for.

What's the right way to use pacman and definitely know whether it considers the package installation successful or not?

rakslice
  • 473
  • 3
  • 11

0 Answers0