Pacman Recovery

I updated my laptop, which runs the simple, lightweight Arch Linux distro. I did not note the low battery reading.

Very unfortunately, my laptop up and quit partway through the software update. I’m not sure if it qualified as “powering off” or “shutting down” or what, but it left a mess.

Arch Linux is mainly distinguished by being a rolling release with software updates done via the pacman package manager. I run pacman -Syu about every week to keep up with software updates and security fixes. Part of my reasons for using Arch Linux is using bleeding-edge software, updating often keeps everything on the latest versions.

As the laptop lost power, pacman -Syu was running. Naturally, after I charged the laptop’s battery somewhat, I turned it back on, waited for it to reboot, and tried to finish the update.

Database locked

First problem, pacman refused to run, indicating that its database was locked.

Solved this by deleting a zero length file named /var/lib/pacman/db.lck

Web browser mysteriously didn’t run

Of course the first course of action is to read the Arch Linux Wiki. I could not do this because Firefox mysteriously did not start, did not even give a failure message.

I started Chromium instead. I sometimes install my preferred software (Firefox) and an alternative (Chromium), for the situations where my preferred software doesn’t work. I remember Windows 98 and the dominance of IE 6. Web browsers are one of the categories of software where you want an alternative installed.

Invalid crypto engine

Second problem: some part(s) of the GNU project’s implementation of PGP had gone missing. pacman gave tons of error messages like error: GPGME error: Invalid crypto engine Arch Linux uses cryptographic “signatures” for its package files to prevent some evil genius from substituting malicious code. The cryptographic signatures get checked by using gpg.

Solved this one by changing a line in the file /etc/pacman.conf from:

SigLevel    = Required DatabaseOptional

to

SigLevel    = None

I was able to install the Arch Linux signing keys but that’s basically just a text file or files, no executables and no fancy shared library installs.

Empty, not checked files

Things did not get better. Third level of problem, lots of chatter from pacman about

usr/bin/ldconfig: File /usr/lib/libgrpc.so.39.0.0 is empty, not checked.

About 150 such empty files, not checked, got noted.

I tried forcing a package re-install:

pacman -S --overwrite=* gpgme

One package updated. I still had almost 145 “empty, not checked” files to deal with. At this point I was wondering how the laptop continued to run, much less booted.

The Arch Linux wiki actually has an article about when power fails in the middle of a pacman update. That looked like a lot of work, and it required doing things that make me nervous.

Ultimate solution: reinstall all packages

After reading more of the “pacman crashes during an upgrade” article, I found out how to reinstall all packages. I had to add the loathed “–overwrite” flag to get packages to install on top of files that already exist (the “empty, not checked” files from above);

pacman -Qqn | pacman -S - '--overwrite=*'

Re-enable cryptographic package signing verification, and a reboot, and all’s well.

Edit 2024-03-01: had to reinstall libreoffice. It was somehow still jacked up despite nominally re-installing everything.