The following commit has been merged in the master branch:
commit 45a7adc8ac5e8864d3a3865b7c0c9cb4ef3b4388
Author: Raphael Hertzog <[email protected]>
Date:   Mon May 4 20:49:42 2009 +0200

    update-alternatives: don't remove real files conflicting with link
    
    When an alternative is installed and a real file is in conflict, the real
    file is kept. When the same alternative is fully removed, the real file
    should be kept according to the same logic (but currently it was removed).
    This commit modifies update-alternatives to follow this expected
    behaviour.
    
    Also add a non-regression test.

diff --git a/debian/changelog b/debian/changelog
index 624d26c..6053ecb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -63,6 +63,9 @@ dpkg (1.15.1) UNRELEASED; urgency=low
   * Bump Standards-Version to 3.8.1 (no change required).
   * Do not store usernames and group names in tarballs created by dpkg-source,
     they are anyway ignored at unpack time. Closes: #523184
+  * Fix update-alternatives to not remove real files installed in place of
+    an alternative link when the corresponding alternative is fully removed.
+    Closes: #526538
 
   [ Guillem Jover ]
   * Fix typo in dpkg output (‘unexecpted’ → ‘unexpected’). Closes: #519082
diff --git a/scripts/t/900_update_alternatives.t 
b/scripts/t/900_update_alternatives.t
index da4ba84..7b29a21 100644
--- a/scripts/t/900_update_alternatives.t
+++ b/scripts/t/900_update_alternatives.t
@@ -53,7 +53,7 @@ my @choices = (
 );
 my $nb_slaves = 2;
 plan tests => (4 * ($nb_slaves + 1) + 2) * 24 # number of check_choices
-               + 60;                         # rest
+               + 63;                         # rest
 
 sub cleanup {
     system("rm -rf t.tmp/ua && mkdir -p $admindir && mkdir -p $altdir");
@@ -345,6 +345,9 @@ system("touch $main_link $bindir/slave1");
 install_choice(0);
 ok(!-l $main_link, "install preserves files that should be links");
 ok(!-l "$bindir/slave1", "install preserves files that should be slave links");
+remove_choice(0);
+ok(-f $main_link, "removal keeps real file installed as master link");
+ok(-f "$bindir/slave1", "removal keeps real files installed as slave links");
 install_choice(0, params => ["--force"]);
 check_choice(0, "auto", "install --force replaces files with links");
 
diff --git a/scripts/update-alternatives.pl b/scripts/update-alternatives.pl
index 37cbd7b..1771ee2 100755
--- a/scripts/update-alternatives.pl
+++ b/scripts/update-alternatives.pl
@@ -1045,13 +1045,13 @@ sub remove {
     my ($self) = @_;
     my ($link, $name) = ($self->link(), $self->name());
     main::checked_rm("$link.dpkg-tmp");
-    main::checked_rm($link);
+    main::checked_rm($link) if -l $link;
     main::checked_rm("$altdir/$name.dpkg-tmp");
     main::checked_rm("$altdir/$name");
     foreach my $slave ($self->slaves()) {
         my $slink = $self->slave_link($slave);
         main::checked_rm("$slink.dpkg-tmp");
-        main::checked_rm($slink);
+        main::checked_rm($slink) if -l $slink;
         main::checked_rm("$altdir/$slave.dpkg-tmp");
         main::checked_rm("$altdir/$slave");
     }

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to