This patch is safe and has been tested in Ubuntu and should be applied
to sid's dpkg immediately IMO.  (There may be some errors in my
attempts to split the diff out.)

diff -bB --exclude='*~' --exclude='*.orig' --exclude='*.rej' -ruN 
in/debian/dpkg-1.14.4/scripts/update-alternatives.pl 
construct/dpkg-1.14.4/scripts/update-alternatives.pl
--- in/debian/dpkg-1.14.4/scripts/update-alternatives.pl        2007-05-15 
00:42:54.000000000 +0100
+++ construct/dpkg-1.14.4/scripts/update-alternatives.pl        2007-05-30 
17:09:24.000000000 +0100
@@ -588,21 +588,6 @@
     for (my $j = 0; $j <= $#slavenames; $j++) {
         $sname= $slavenames[$j];
         $slink= $slavelinks[$j];
-
-       $linkname = readlink($slink);
-       if (!defined($linkname) && $! != ENOENT) {
-            &pr(sprintf(_g("warning: %s is supposed to be a slave symlink 
to\n".
-                " %s, or nonexistent; however, readlink failed: %s"), $slink, 
"$altdir/$sname", $!))
-               if $verbosemode > 0;
-       } elsif (!defined($linkname) ||
-                (defined($linkname) && $linkname ne "$altdir/$sname")) {
-            unlink("$slink.dpkg-tmp") || $! == &ENOENT ||
-                &quit(sprintf(_g("unable to ensure %s nonexistent: %s"), 
"$slink.dpkg-tmp", $!));
-            symlink("$altdir/$sname","$slink.dpkg-tmp") ||
-                &quit(sprintf(_g("unable to make %s a symlink to %s: %s"), 
"$slink.dpkg-tmp", "$altdir/$sname", $!));
-            rename_mv("$slink.dpkg-tmp",$slink) ||
-                &quit(sprintf(_g("unable to install %s as %s: %s"), 
"$slink.dpkg-tmp", $slink, $!));
-        }
         $spath= $slavepath{$bestnum,$j};
         unlink("$altdir/$sname.dpkg-tmp") || $! == &ENOENT ||
             &quit(sprintf(_g("unable to ensure %s nonexistent: %s"), 
"$altdir/$sname.dpkg-tmp", $!));
@@ -614,6 +599,18 @@
            unlink("$slink") || $! == &ENOENT ||
                &quit(sprintf(_g("unable to remove %s: %s"), $slink, $!));
         } else {
+           if (!defined($linkname= readlink($slink)) && $! != &ENOENT) {
+               &pr(sprintf(_g("warning: %s is supposed to be a slave symlink 
to\n".
+                              " %s, or nonexistent; however, readlink failed: 
%s"), $slink, "$altdir/$sname", $!))
+                   if $verbosemode > 0;
+           } elsif ($linkname ne "$altdir/$sname") {
+               unlink("$slink.dpkg-tmp") || $! == &ENOENT ||
+                   &quit(sprintf(_g("unable to ensure %s nonexistent: %s"), 
"$slink.dpkg-tmp", $!));
+               symlink("$altdir/$sname","$slink.dpkg-tmp") ||
+                   &quit(sprintf(_g("unable to make %s a symlink to %s: %s"), 
"$slink.dpkg-tmp", "$altdir/$sname", $!));
+               rename_mv("$slink.dpkg-tmp",$slink) ||
+                   &quit(sprintf(_g("unable to install %s as %s: %s"), 
"$slink.dpkg-tmp", $slink, $!));
+           }
             if (defined($linkname= readlink("$altdir/$sname")) && $linkname eq 
$spath) {
                 &pr(sprintf(_g("Leaving %s (%s) pointing to %s."), $sname, 
$slink, $spath))
                   if $verbosemode > 0;

Reply via email to