Pārlūkot izejas kodu

update-alternatives: let --install fix links if necessary

* scripts/update-alternatives.pl: Change set_links() to
also reset the main alternative link. Add a parameter to
make it quiet.
When --install reinstalls the current and manually selected entry,
let it recreate the symlinks in case something has gone wrong.
Raphael Hertzog 17 gadi atpakaļ
vecāks
revīzija
d337a00b50
3 mainītis faili ar 23 papildinājumiem un 5 dzēšanām
  1. 8 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 13 5
      scripts/update-alternatives.pl

+ 8 - 0
ChangeLog

@@ -3,6 +3,14 @@
 	* lib/dpkg.h (ohshitvb): Remove function prototype.
 	* lib/ehandle.c (ohshitvb): Remove function definition.
 
+2009-02-06  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/update-alternatives.pl: Change set_links() to
+	also reset the main alternative link. Add a parameter to
+	make it quiet.
+	When --install reinstalls the current and manually selected entry,
+	let it recreate the symlinks in case something has gone wrong.
+
 2009-02-06  Raphael Hertzog  <hertzog@debian.org>
 
 	* scripts/update-alternatives.pl: Remove the alternative when

+ 2 - 0
debian/changelog

@@ -133,6 +133,8 @@ dpkg (1.15.0) UNRELEASED; urgency=low
     we switch to manual mode with --set or --config. Closes: #388313
   * Modify update-alternatives to always remove the alternative group when the last
     alternative is removed (even in manual mode).
+  * Ensure that update-alternative --install fix the links if the alternative
+    installed is the one currently selected. Closes: #100135
 
   [ Pierre Habouzit ]
   * Add a --query option to update-alternatives. Closes: #336091, #441904

+ 13 - 5
scripts/update-alternatives.pl

@@ -286,12 +286,14 @@ sub checked_alternative($$$)
     }
 }
 
-sub set_links($$)
+sub set_links($$$;$)
 {
-    my ($spath, $preferred) = (@_);
+    my ($spath, $link, $preferred, $quiet) = (@_);
 
     printf STDOUT _g("Using '%s' to provide '%s' in %s.") . "\n", $spath,
-                    $name, ($mode eq "auto" ? _g("auto mode") : _g("manual mode"));
+                    $name, ($mode eq "auto" ? _g("auto mode") : _g("manual mode"))
+        unless $quiet;
+    checked_alternative($name, $link, $spath);
     checked_symlink("$spath","$altdir/$name.dpkg-tmp");
     checked_mv("$altdir/$name.dpkg-tmp", "$altdir/$name");
 
@@ -532,6 +534,11 @@ if ($action eq 'install') {
     }
 
     fill_missing_slavepaths();
+
+    if (($mode eq "manual") and defined($linkname) and ($linkname eq $apath)) {
+        # Recreate links to fix any links gone missing
+        set_alternatives(1); # quiet
+    }
 }
 
 if ($action eq 'remove') {
@@ -728,12 +735,13 @@ sub config_alternatives {
 	    $preferred--;
 	    my $spath = $versions[$preferred];
 
-	    set_links($spath, $preferred);
+	    set_links($spath, $link, $preferred);
 	}
     }
 }
 
 sub set_alternatives {
+    my ($quiet) = @_;
     $mode = "manual";
     # Get preferred number
     my $preferred = -1;
@@ -746,7 +754,7 @@ sub set_alternatives {
     if ($preferred == -1) {
         quit(sprintf(_g("Cannot find alternative `%s'."), $apath)."\n");
     }
-    set_links($apath, $preferred);
+    set_links($apath, $link, $preferred, $quiet);
 }
 
 sub pr