From: Ben Collins Date: Sun, 17 Oct 1999 04:23:07 +0000 (+0000) Subject: * Added --config option to update-alternatives to allow easy changing X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af8d688ca13b8b2c6967536ed590b8bdac89d040;p=dpkg * Added --config option to update-alternatives to allow easy changing of the registered alternatives for a specific name --- diff --git a/scripts/update-alternatives.8 b/scripts/update-alternatives.8 index 413b69cd..946b5955 100644 --- a/scripts/update-alternatives.8 +++ b/scripts/update-alternatives.8 @@ -31,6 +31,10 @@ update-alternatives \- maintain symbolic links determining default commands .RI [ options ] .B --display .I name +.B update-alternatives +.RI [ options ] +.B --config +.I name .SH DESCRIPTION .B update-alternatives creates, removes, maintains and displays information about the symbolic @@ -130,6 +134,17 @@ associated with it. When a link group is in automatic mode, the alternatives pointed to by members of the group will be those which have the highest priority. +.PP +When using the +.I --config +option, update-alternatives will list all of the choices for the given +alternative. You will then be prompted for which of the choices to use +for the alternative. Once you make a change, the alternative will no +longer be in +.I auto +mode. You will need to use the +.I --auto +option in order to return to the automatic state. .SH TERMINOLOGY Since the activities of .B update-alternatives diff --git a/scripts/update-alternatives.pl b/scripts/update-alternatives.pl index c23ef3fe..d528f779 100755 --- a/scripts/update-alternatives.pl +++ b/scripts/update-alternatives.pl @@ -14,6 +14,7 @@ Usage: update-alternatives --install update-alternatives --remove update-alternatives --auto update-alternatives --display + update-alternatives --config is the name in /etc/alternatives. is the name referred to. is the link pointing to /etc/alternatives/. @@ -64,7 +65,7 @@ while (@ARGV) { @ARGV >= 2 || &badusage("--remove needs "); ($name,$apath,@ARGV) = @ARGV; $mode= 'remove'; - } elsif (m/^--(display|auto)$/) { + } elsif (m/^--(display|auto|config)$/) { &checkmanymodes; @ARGV || &badusage("--$1 needs "); $mode= $1; @@ -164,6 +165,15 @@ if ($mode eq 'display') { exit 0; } +if ($mode eq 'config') { + if (!$dataread) { + &pr("No alternatives for $name."); + } else { + &config_alternatives($name); + exit 0; + } +} + $best= ''; for ($i=0; $i<=$#versions; $i++) { if ($best eq '' || $priorities[$i] > $bestpri) { @@ -435,4 +445,37 @@ sub badfmt { sub rename_mv { return (rename($_[0], $_[1]) || (system(("mv", $_[0], $_[1])) == 0)); } + +sub config_message { + printf(STDOUT "\nYou have %s package(s) which", $#versions+1); + printf(STDOUT " provide the $name command:\n"); + printf(STDOUT " Selection Command-Name Command\n"); + printf(STDOUT "-----------------------------------------------\n"); + for ($i=0; $i<=$#versions; $i++) { + if (readlink("$altdir/$name") eq $versions[$i]) { + printf(STDOUT "* %s %s %s\n", $i+1, + $name, $versions[$i]); + } else { + printf(STDOUT " %s %s %s\n", $i+1, + $name, $versions[$i]); + } + } + printf(STDOUT "\nWhich selection to supply `$name'?\n"); + printf(STDOUT "Or press ENTER to keep the current (*) selection.\n"); +} + +sub config_alternatives { + do { + &config_message; + $preferred=; + chop($preferred); + } until $preferred eq '' || ($preferred>=1 && $preferred<=$#versions+1); + if ($preferred ne '') { + system("ln -sf $versions[$preferred-1] $altdir/$name"); + if ($?) { + &quit("unable to change link for alternative"); + } + } +} + exit(0);