Просмотр исходного кода

Fix update-alternatives messing with spurious slave link spuriously.

When a slave alternative is inapplicable do not attempt to create the
slave link before removing it again.
Ian Jackson лет назад: 19
Родитель
Сommit
0fafaf6a2f
3 измененных файлов с 25 добавлено и 15 удалено
  1. 6 0
      ChangeLog
  2. 3 0
      debian/changelog
  3. 16 15
      scripts/update-alternatives.pl

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2007-08-08  Ian Jackson  <iwj@ubuntu.com>
+
+	* scripts/update-alternatives.pl: In the case where the slave is
+	inapplicable do not attempt to create the slave link before
+	removing it again.
+
 2007-08-08  Guillem Jover  <guillem@debian.org>
 
 	* src/configure.c (deferred_configure): Do not print a new line

+ 3 - 0
debian/changelog

@@ -28,6 +28,9 @@ dpkg (1.14.6) UNRELEASED; urgency=low
   * Tightening dpkg-dev versioned Depends to dpkg 1.14.6, and dpkg Conflicts
     against << dpkg-dev 1.14.6, where the perl modularization started.
   * Do not print empty lines after 'Setting up ...' output. Closes: #392317
+  * When a slave alternative is inapplicable do not attempt to create the
+    slave link before removing it again. Closes: #411699
+    Thanks to Ian Jackson.
 
   [ Updated scripts translations ]
   * French (Frédéric Bothamy, Christian Perrier).

+ 16 - 15
scripts/update-alternatives.pl

@@ -584,21 +584,6 @@ if ($mode eq 'auto') {
     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", $!));
@@ -610,6 +595,22 @@ if ($mode eq 'auto') {
 	    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;