Fixing corrupted package on arch linux

Posted on Aug 4, 2022

I was trying to update my system witb sudo pacman -Syu when I encountered the following:

error: scrcpy: signature from "Alexander F. Rødseth <xyproto@archlinux.org>" is marginal trust
:: File /var/cache/pacman/pkg/scrcpy-1.24-1-x86_64.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] Y
error: shellharden: signature from "Alexander F. Rødseth <xyproto@archlinux.org>" is marginal trust
:: File /var/cache/pacman/pkg/shellharden-4.3.0-1-x86_64.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] Y
error: failed to commit transaction (invalid or corrupted package)
Errors occurred, no packages were upgraded.

Well, I was not sure what to do. Two google searches away, I found that I needed to update my archlinux-keyring package. I am not sure what does it do exactly, I’ll check and update later. But I installed it with:

$ sudo pacman -S archlinux-keyring

And now sudo pacman -Syu worked! yay!

Update: If fetching archlinux-keyring itself results in keyring issues, we can do the following to do a fresh populate

mv /etc/pacman.d/gnupg /tmp/gnupg
pacman-key --init
pacman-key --populate
pacman -Sy archlinux-keyring
pacman -Syu