Fallback to Arch Linux Archive if the local package database is outdated

· 356 words · 2 minute read

TLDR: Append the following line to your /etc/pacman.d/mirrorlist:

Server = https://archive.archlinux.org/.all

Long version:

I am running a dosen of Arch Linux machines: from desktop devices to servers. They are all running Arch Linux, but I rarely upgrade them. That is because upgrading them requires a lot of time to deal with pacnew’s, service restarts, testing, etc. Although automated tools like Ansible may save me some time, I am not using these tools now, and I still need to manually merge pacnew’s.

This caused a problem: it is pretty hard to install anything without upgrading the whole system. That is, most Arch Linux mirrors will delete old packages, and my local package database is still requesting the old packages instead of the new ones. Thus, installing lots of packages will return 404.

This is especially annoying when you have to install some kinds of debugging tools to fix your servers, and you are forced to waste ten or more minutes doing a full system upgrade. Sucks.

Partial upgrade is also not working because it breaks things. That is, running pacman -Sy <package> to update the local database to download the new version of the desired package. The new package will likely depend on some new version of libraries, making it not working. Even worse, it may break the system.

Fortunately, Arch Linux offers a website called Arch Linux Archive, and it contains lots of old version packages for recovery purposes. What about, let’s fallback to the Archive whenever the mirror returns 404? This not only saves the time of upgrading the whole system, but also avoids partial upgrade issues.

Fortunately enough, the archive service offers a directory contains all versions of all packages in all official repositories, through https://archive.archlinux.org/.all/. Thus, we can just add this line to the bottom of the mirror list, so pacman(1) will visit that URL to download the outdated package if all above mirrors failed.

That’s good, but please keep in mind that upgrading systems frequently is still the best possible solution.

Foot note: In the archive url, /.all/ and /packages/.all/ (the one on Arch Wiki) both work, which I found by accidence.