So, after writing about it I decided to take a look at the actual code of alternatives from Fedora.
The nice thing is that the alternatives code is well tested to work properly. The bad things are that it’s a bit of a silly thing to download a source rpm for a single source file and a man page, and that it’s not exactly userfriendly.
The first problem I can find is that it’s not abstracting much, the basic interface would be asking for this:
# alternatives --set tar /bin/bsdtar
It’s not very nice to have to provide the actual symlink.
Okay, so did I waste time? Nope I don’t think so. Although alternatives
has a nasty interface in my opinion, it has a lot of qualities: it’s well tested, it has been designed quite a long time ago, and thus problems were already identified and (hopefully) resolved.
So as Luca said, we need to smooth the wheel a bit.
I think the nastiest problem I have now is with the way alternatives data is written to the library directory. If there is a program that can be invoked by bash to edit configuration files (INI-style), that would be a huge advantage.
In general, what alternatives doesn’t provide that we need is:
- full support for
$ROOT
; as it is alternatives allows you to update the directory data on $ROOT, but it will still change the symlinks in /; - a way to automatically handle man pages compressed with different algorithms (none, gz, bz2, lzma);
- a nicer user interface, that allows you to just have
eselect alternative tar bsdtar
instead.
At least, now that I know how RedHat does it, I can shape our tool on the basis of this. Hopefully in a few months we’ll have virtual/tar in system rather than app-arch/tar, which would then allow who wanted to, to replace GNU tar and GNU cpio with libarchive’s bsdtar and bsdcpio.
On a different note, I don’t like the way RedHat handles the choice of editor: they create a /usr/bin/editor
symlink to be used. While I admit this solves the issue like the one with fcron about telling the software being built which tool to use, it doesn’t solve it entirely. For instance, I have as EDITOR value emacsclient -c
. I wouldn’t be able to express that with the alternatives approach that RedHat uses.
So yeah not always the code that comes from others is good as it is, but often enough it’s a basis to implement something new.