latest version is 0.2.0-rc2
What is it?
Best description you can find is in manual page of Debian's
" 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
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?
- You don't need to give
special generic name for altenatives file. This name is autogenerated
- This version is written in shell, awk and sed , so we reduce a
number of dependencies, therefore, number of the packages in basesystem.
- We use different update model. Original alternatives system
maintains its own database, by creating/removing files in
system. In our alternatives (rpm) packages contains it's configs
and places them into generic directory during package
installation. After package removal its config is automatically
removed. It works like Debian menu subsystem, and it's more stable.
- Now we have not any limitations for master-slave hieracly depth.
- New alternatives system works with no groups, but with each item.
You can turn into manual mode any available item. There are only
one difference between master and slave: weight calculation algorithm.
Slave alternative have same weight as a master alternative.
- alternatives-update script corrects invalid manual
alternatives, by switching them into auto mode. In original
alternatives was situations with broken symlinks. Also new system
doesn't create symlinks if target file does not exist. As a
result, we also reduce number of broken symlinks.
for the packages:
- alternatives-auto -
turn into auto mode some alternatives item
- alternatives-manual -
turn into manual mode some alternatives item
- alternatives-update -
update current state of alternatives symlinks
ALT Linux specific:
- alternatives-install -
register new alternatives config, for use in %post package script
- alternatives-uninstall -
unregister some alternatives config, for use in %preun package script
- alternatives-helper -
helper script to use in package scripts
- alternatives-upgrade -
tool to upgrade from old config format (XML based) to new.
- /usr/bin - all scripts
- all package configs
- /etc/alternatives/auto -
symlinks to registered configs
- list of alternatives in manual mode
- for internal use only, alternatives symlinks lives here
- directory with some helper functions and scripts
Config file format
Format is very simple. There are three tab separated fields.
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
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.
Summary: alternatives test file
alternatives test file #1
echo "variant 1"
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
alternatives system is written by