Alternatives system.

latest version is 0.2.0-rc2

What is it?

Best description you can find is in manual page of Debian's update-alternatives package:
" It is possible for several programs fulfilling the same or similar functions to be installed on a single system at the same time. For example, many systems have several text editors installed at once. This gives choice to the users of a system, allowing each to use a  different editor, if desired, but makes it difficult for a program to make a good choice of editor to invoke if the user has not specified a particular

The alternatives system aims to solve this problem. A generic name in the filesystem is shared by all files providing interchangeable functionality.
The alternatives system and the system administrator together determine  which actual file is referenced by this generic name.
For example, if the text editors ed(1) and nvi(1) are both installed on the system, the alternatives system will cause the generic name /usr/bin/editor to refer to  /usr/bin/nvi by default. The system administrator can override this  and cause it to refer to /usr/bin/ed instead, and the alternatives system  will not alter this setting until explicitly requested to do so.
It is often useful for a number of alternatives to be synchronised, so that  they are changed as a group; for example, when several versions of the vi(1)
editor are installed, the man page referenced by /usr/share/man/man1/vi.1 should correspond to the executable referenced by /usr/bin/vi. update-alternatives handles this by means of master and slave links; when the master is changed, any associated slaves are changed too. A master link and its associated slaves make up a link group.
Each link group is, at any given time, in one of two modes: automatic or manual. When a group is in automatic mode, the alternatives system will automatically decide, as packages are installed and removed, whether and how to update the links. In manual mode, the alternatives system will not change the links; it will leave all the decisions to the system administrator.

What is the ALT Linux alternatives?

Original Debian alternatives implementation has some limitations and problems, so we (ALT Linux Team) rewrite this subsystem. What changes we have made?

Alternatives architecture

general engine:
special scripts for the packages:
ALT Linux specific:

Config file format

Format is very simple. There are three tab separated fields.
<generic name>    <candidate's name>    <weight or name of the master>
Example config for master alternative /usr/bin/links with slave  alternatives /usr/share/man/man1/links.1.gz

/usr/bin/links    /usr/bin/links1    10
/usr/share/man/man1/links.1.gz    /usr/share/man/man1/links1.1.gz    /usr/bin/links1

Sample rpm package with alternatives support

This is a package variant with alternative /usr/bin/variant.  All rpm macros I use in this spec you can find in alternatives.spec.

Name: variant1
Version: 1.0
Release: alt1

Summary: alternatives test file
License: GPL
Group: System/Base
BuildArch: noarch

PreReq: alternatives

alternatives test file #1

install -d $RPM_BUILD_ROOT/%_bindir

echo "variant 1"
chmod 755 $RPM_BUILD_ROOT/%_bindir/%name

install -d $RPM_BUILD_ROOT/%_altdir

cat >$RPM_BUILD_ROOT/%_altdir/%name<<EOF
%_bindir/variant %_bindir/%name 10

%register_alternatives %name

%unregister_alternatives %name


Building and installing

To build this package you need only extra help2man utility to generate manual pages for utilites. Just run "make install" to install alternatives to your system.

alternatives system is written by Stanislav Ievlev

Hosted by
SourceForge Logo
Member of ALT labs