An upgrade via pacman could be broken down into three phases:
Updates the sync databases with, if any, new packages. These are downloaded
from the mirrors usually as gzip files located in /var/lib/pacman/sync
such as core.db
and extra.db
.
Deals with dependency resolution and downloads any new package tarballs to
/var/cache/pacman/pkg
by default.
Pacman now essentually untars the downloaded package tarballs over the /
directory by default.
It also updates the database in /var/lib/pacman/local
after each package
is untarred to reflect the changed state of the filesystem.
If the first two phases fail it is usually enough to just start again using the same command-line used to invoke pacman.
If the installation phase fails due to interruptions, errors or power failure then recovery becomes a bit more complicated.
Essentially what has occured is a mismatch between what is contained in the
real filesystem and what the /var/lib/pacman/local
database knows.
Attempting to install packages again will often result in file conflicts as pacman wishes to extract files that already exist in the filesystem but without it knowing about their ownership.
First, try to avoid running -Syu
(or -Sy
) after the installation
failure. This will only complicate matters as the /var/lib/pacman/sync
databases will potentially now also be out of sync with
/var/lib/pacman/local
along with it being out of sync with the filesystem
contents.
Gather a list of all packages which are conflicting (or just issue the same
command innvocation without -y
), then pass them to pacman
-S --dbonly <packages>
to bring the database back into alignment with the
filesystem. Then install the packages using pacman -S <packages>
to bring
the filesystem back into alignment with the database.
Again collect the conflicting packages but this time we'll use -U --dbonly
to install them from the cache which is located at /var/cache/pacman/pkg
by
default. Once this is complete run the same command again without --dbonly
to bring the filesystem back inline with the /var/lib/pacman/local
database. E.g.:
pacman -U --dbonly /var/cache/pacman/pkg/{package-1.tar.xz,package-2.tar.xz,package-3.tar.xz}
pacman -U /var/cache/pacman/pkg/{package-1.tar.xz,package-2.tar.xz,package-3.tar.xz}
After this it would likely be a good idea to run pacman -Syu
again to make
sure everything is in sync once more.