#!/usr/bin/perl -- BEGIN { # Work-around for bug #479711 in perl $ENV{PERL_DL_NONLAZY} = 1; } use strict; use warnings; use POSIX qw(:errno_h); use Dpkg; use Dpkg::Gettext; textdomain("dpkg"); # Global variables: my $altdir = '/etc/alternatives'; # FIXME: this should not override the previous assignment. $admindir = $admindir . '/alternatives'; my $verbosemode = 0; my $action = ''; # Action to perform (display / install / remove / display / auto / config) my $mode = 'auto'; # Update mode for alternative (manual / auto) my $state; # State of alternative: # expected: alternative with highest priority is the active alternative # expected-inprogress: busy selecting alternative with highest priority # unexpected: alternative another alternative is active / error during readlink # nonexistent: alternative-symlink does not exist my %versionnum; # Map from currently available versions into @versions and @priorities my @versions; # List of available versions for alternative my @priorities; # Map from @version-index to priority my $best; my $bestpri; my $bestnum; my $link; # Link we are working with my $linkname; my $alink; # Alternative we are managing (ie the symlink we're making/removing) (install only) my $name; # Name of the alternative (the symlink) we are processing my $apath; # Path of alternative we are offering my $apriority; # Priority of link (only when we are installing an alternative) my %aslavelink; my %aslavepath; my %aslavelinkcount; my $slink; my $sname; my $spath; my @slavenames; # List with names of slavelinks my %slavenum; # Map from name of slavelink to slave-index (into @slavelinks) my @slavelinks; # List of slavelinks (indexed by slave-index) my %slavepath; # Map from (@version-index,slavename) to slave-path my %slavelinkcount; sub version { printf _g("Debian %s version %s.\n"), $progname, $version; printf _g(" Copyright (C) 1995 Ian Jackson. Copyright (C) 2000-2002 Wichert Akkerman."); printf _g(" This is free software; see the GNU General Public Licence version 2 or later for copying conditions. There is NO warranty. "); } sub usage { printf _g( "Usage: %s [