Explorar o código

Handle case in update-alternatives when there's no existing alternative
to configure. Closes: #260987, #353252, #367717, #392431

Guillem Jover %!s(int64=19) %!d(string=hai) anos
pai
achega
75a96e69ea
Modificáronse 3 ficheiros con 19 adicións e 3 borrados
  1. 8 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 9 3
      scripts/update-alternatives.pl

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2007-05-09  Guillem Jover  <guillem@debian.org>
+
+	* scripts/update-alternatives.pl (config_message): Handle the case
+	when @versions is empty. Return a negative value if there's nothing to
+	do, 0 on success.
+	(config_alternatives): Check for config_message exit value to decide
+	to return instead of @versions being empty.
+
 2007-05-09  Guillem Jover  <guillem@debian.org>
 
 	* scripts/dpkg-buildpackage.sh: Remove check for variable being empty,

+ 2 - 0
debian/changelog

@@ -1,6 +1,8 @@
 dpkg (1.14.2) UNRELEASED; urgency=low
 
   * Remove bashisms in dpkg-buildpackage. Closes: #422239
+  * Handle case in update-alternatives when there's no existing alternative
+    to configure. Closes: #260987, #353252, #367717, #392431
 
  -- Guillem Jover <guillem@debian.org>  Tue, 08 May 2007 18:48:22 +0300
 

+ 9 - 3
scripts/update-alternatives.pl

@@ -611,11 +611,17 @@ if ($manual eq 'auto') {
 }
 
 sub config_message {
+    if ($#versions < 0) {
+	print "\n";
+	printf _g("There is no program which provides %s.\n".
+	          "Nothing to configure.\n"), $name;
+	return -1;
+    }
     if ($#versions == 0) {
 	print "\n";
 	printf _g("There is only 1 program which provides %s\n".
 	          "(%s). Nothing to configure.\n"), $name, $versions[0];
-	return;
+	return -1;
     }
     print STDOUT "\n";
     printf(STDOUT _g("There are %s alternatives which provide \`%s'.\n\n".
@@ -629,13 +635,13 @@ sub config_message {
 	    $i+1, $versions[$i]);
     }
     printf(STDOUT "\n"._g("Press enter to keep the default[*], or type selection number: "));
+    return 0;
 }
 
 sub config_alternatives {
     my $preferred;
     do {
-	&config_message;
-	if ($#versions == 0) { return; }
+	return if config_message() < 0;
 	$preferred=<STDIN>;
 	chop($preferred);
     } until $preferred eq '' || $preferred>=1 && $preferred<=$#versions+1 &&