openSUSE:Migrating from update-alternatives to conflicts
Migrating from update-alternatives to conflicts
As conflicts are something that are already well-established within the RPM packaging ecosystem, this page wonât go into as much technical detail as the pages related to migrating from update-alternatives to libalternatives.
However, weâll nonetheless outline the strategy to transition packages from update-alternatives to a conflict-based implementation.
The following steps are written as if we were migrating the Golang compiler toolchain.
Prerequisites
Make sure youâve followed all of the steps necessary to purge update-alternatives from the spec file, as per that tutorial.
Make sure every package is self-sufficient
Here, by self-sufficient, we mean that each package (go1.21, go1.22, go1.23, etc) should provide the following by itself.
/usr/bin/go, the main executable for the whole toolchain. It shouldnât be a symlink to/etc/alternatives/go, but rather, either the actual executable, or a symlink to it (/usr/lib64/go/1.21/bin/goin the case ofgo1.21). As there will be no alternatives system in place, this migration is essentially going back to a simpler mindset where there are no tricks at all./usr/bin/gofmt, follows the exact same logic as applied above.
In a nutshell, everything that is currently an alternative should now be provided by each package directly. There will be no alternatives system in place, no state change (symlink manipulation) after a package has been installed.
Make each package provide the same capacity, and conflict with it as well
Ok, so the idea is that when you install any package that belongs in this same conceptual set of packages, then that must be the only package that is installed.
For example, if a user has go1.22 currently installed, but tries to install go1.21, then Zypper would prompt the user for go1.22 to be uninstalled. Essentially, all packages in this conceptual set are mutually exclusive. A user can only ever have one âalternativeâ installed, at any given time.
The way to achieve this is as follows, for each package, add the same Provides and Conflicts:
Provides: go Conflicts: go
This will ensure that only one package can be installed. Upgrades will still work just fine.