openSUSE:Migrating-to-libalternatives

Jump to: navigation, search

Migrating to libalternatives

This page describes how to perform the migration from update-alternatives to libalternatives. For now, only the simplest scenario is documented here. But updates will be on their way, once more packages have been migrated.

Basically, we need to:

  1. Remove all files related to update-alternatives from the package.

  2. Remove all dependencies related to update-alternatives from the package.

  3. Remove any %post, %pre, %postun or %preun hooks that may be related to update-alternatives.

  4. Ensure there is either a hard dependency on the alts package, or that an equally suitable custom binary is provided instead, by linking to libalternatives.so.1.

    4.1. If you opt for the alts route, then the package’s main executable binary must be a symlink to alts.

    4.2. If you opt to provide a custom binary, then check how the nodejs-common package does it: nodejs-common.

  5. Create the appropriate priority/preferences files, located in /usr/share/libalternatives. These files specify both the package’s actual target binary, as well as its man pages.

To exemplify this process, the next section explains how the transmission package was migrated.

How transmission was migrated

The transmission package falls into the following category: it’s a fairly simple package with binaries and man pages, but no other binary files are managed via any alternatives. Only the binaries and the man pages. So it’s a very trivial migration. A single spec file provides the transmission, transmission-common, transmission-daemon, transmission-gtk and transmission-qt packages.

For a full diff regarding this migration, please check it here.

  1. We removed all mentions of the update-alternatives package from the spec file. This includes any dependency declarations, comments, etc.

  2. We removed all files whose only purpose was to adhere to the filesystem conventions specified by update-alternatives. So, no files in /etc/alternatives, and no symlinks pointing to /etc/alternatives.

  3. We also removed any %post, %pre, %postun or %preun hooks that were related to update-alternatives.

  4. The transmission-common package now requires alts. As all other packages require transmission-common, alts will always be pulled as a dependency. Just in case, we made transmission, transmission-gtk and transmission-qt require alts explicitly.

  5. /usr/bin/transmission is a symlink to /usr/bin/alts. This is why there’s a dependency on alts, it is the binary that will check the appropriate priority files and invoke the correct binary based on them.

  6. Each individual package (transmission-gtk, transmission-qt, transmission) creates its own priority file in /usr/share/libalternatives/transmission.

    6.1. The priority file’s name must be a number which indicates that alternative’s priority. For instance, the priority file for transmission-gtk is named /usr/share/libalternatives/transmission/15.conf. The priority file for transmission-qt is named /usr/share/libalternatives/transmission/10.conf. So, transmission-gtk has priority 15, and transmission-qt has priority 10.

For reference, here is the priority file for transmission-gtk:

binary=/usr/bin/transmission-gtk
man=transmission-gtk.1

And for transmission-qt:

binary=/usr/bin/transmission-qt
man=transmission-qt.1