Explorar o código

update-alternatives: avoid switching to manual mode broken alternatives

* scripts/update-alternatives.pl: Ensure that a broken link
in automatic mode doesn't lead to the alternative being set
on manual mode. Also displays by default (and not only
when --verbose is given) the message that indicates that
an alternative is switched to manual mode.
Raphael Hertzog %!s(int64=17) %!d(string=hai) anos
pai
achega
7b1f88470b
Modificáronse 3 ficheiros con 18 adicións e 2 borrados
  1. 8 0
      ChangeLog
  2. 4 0
      debian/changelog
  3. 6 2
      scripts/update-alternatives.pl

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2009-02-05  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/update-alternatives.pl: Ensure that a broken link
+	in automatic mode doesn't lead to the alternative being set
+	on manual mode. Also displays by default (and not only
+	when --verbose is given) the message that indicates that
+	an alternative is switched to manual mode.
+
 2009-02-05  Raphael Hertzog  <hertzog@debian.org>
 	    Osamu Aoki <osamu@debian.org>
 

+ 4 - 0
debian/changelog

@@ -114,6 +114,10 @@ dpkg (1.15.0) UNRELEASED; urgency=low
     (launched during source build). Closes: #426752, #499924
   * Improve behaviour of update-alternatives --config. Thanks to
     Osamu Aoki <osamu@debian.org> for the initial patch.
+  * Fix update-alternatives to not switch to manual mode an alternative
+    with a broken symlink (instead let the current action fix it).
+    Also ensure that a message is displayed by default when such a switch is
+    made. Closes: #141325, #87677
 
   [ Pierre Habouzit ]
   * Add a --query option to update-alternatives. Closes: #336091, #441904

+ 6 - 2
scripts/update-alternatives.pl

@@ -444,7 +444,11 @@ if (defined($linkname= readlink("$altdir/$name"))) {
     } elsif (defined(readlink("$altdir/$name.dpkg-tmp"))) {
         $state= 'expected-inprogress';
     } else {
-        $state= 'unexpected';
+        if (-e $linkname) {
+            $state = 'unexpected';
+        } else {
+            $state = 'nonexistent';
+        }
     }
 } elsif ($! == ENOENT) {
     $state= 'nonexistent';
@@ -475,7 +479,7 @@ if ($action eq 'auto') {
 if ($state eq 'unexpected' && $mode eq 'auto') {
     pr(sprintf(_g("%s has been changed (manually or by a script).\n" .
                   "Switching to manual updates only."), "$altdir/$name"))
-      if $verbosemode > 0;
+        if $verbosemode >= 0;
     $mode = 'manual';
 }