From 0fafaf6a2f43c487167a9bfa3f7abc55dcde582c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 8 Aug 2007 06:05:17 +0300 Subject: [PATCH] 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. --- ChangeLog | 6 ++++++ debian/changelog | 3 +++ scripts/update-alternatives.pl | 31 ++++++++++++++++--------------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88aaa1a5..53fccaeb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-08-08 Ian Jackson + + * 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 * src/configure.c (deferred_configure): Do not print a new line diff --git a/debian/changelog b/debian/changelog index fa186997..0febdea7 100644 --- a/debian/changelog +++ b/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). diff --git a/scripts/update-alternatives.pl b/scripts/update-alternatives.pl index f851ccc5..f0e71458 100755 --- a/scripts/update-alternatives.pl +++ b/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; -- 2.39.5