Title: Backport OpenBSD 7.3 pkg_add enhancement | |
Author: Solène | |
Date: 30 May 2023 | |
Tags: openbsd | |
Description: In this blog post, you will learn how to backport a huge | |
speedup to pkg_add for OpenBSD 7.3 | |
# Introduction | |
Recently, OpenBSD package manager received a huge speed boost when | |
updating packages, but it's currently only working in -current due to | |
an issue. | |
Fortunately, espie@ fixed it for the next release, I tried it and it's | |
safe to fix yourself. It will be available in the 7.4 release, but for | |
7.3 users, here is how to apply the change. | |
Link to the commit (GitHub) | |
# Fix | |
There is a single file modified, just download the patch and apply it | |
on `/usr/libdata/perl5/OpenBSD/PackageRepository/Installed.pm` with the | |
command `patch`. | |
```shell | |
cd /usr/libdata/perl5/OpenBSD/PackageRepository/ | |
ftp -o /tmp/pkg_add.patch https://github.com/openbsd/src/commit/fa222ab7fc13c11… | |
patch -C < /tmp/pkg_add.patch && patch < /tmp/pkg_add.patch && rm /tmp/pkg_add.… | |
``` | |
After that, running `pkg_add -u` should be at least 5 or 10 times | |
faster, and will use a lot less bandwidth. | |
# Some explanations | |
On -current, there is a single directory to look for packages, but on | |
release for architectures amd64, aarch64, sparc64 and i386, there are | |
two directories: the packages generated for the release, and the | |
packages-stable directory receiving updates during the release | |
lifetime. | |
The code wasn't working with the two paths case, preventing `pkg_add` | |
to build a local packages signature to compare the remote signature | |
database in the "quirks" package in order to look for updates. The old | |
behavior was still used, making pkg_add fetching the first dozen | |
kilobytes of each installed packages to compare their signature package | |
by package, while now everything is stored in quirks. | |
# Disclaimer | |
If you have any issue, just revert the patch by adding `-R` to the | |
patch command, and report the problem TO ME only. | |
This change is not officially supported for 7.3, so you are on your own | |
if there is an issue, but it's not harmful to do. If you were to have | |
an issue, reporting it to me would help solving it for 7.4 for | |
everyone, but really, it just work without being harmful in the worse | |
case scenario. | |
# Conclusion | |
I hope you will enjoy this change so you don't have to wait for 7.4. | |
This makes OpenBSD pkg_add feeling a bit more modern, compared to some | |
packages manager that are now almost instant to install/update | |
packages. |