Quellcode durchsuchen

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.
Raphael Hertzog vor 17 Jahren
Ursprung
Commit
45a7adc8ac
3 geänderte Dateien mit 9 neuen und 3 gelöschten Zeilen
  1. 3 0
      debian/changelog
  2. 4 1
      scripts/t/900_update_alternatives.t
  3. 2 2
      scripts/update-alternatives.pl

+ 3 - 0
debian/changelog

@@ -63,6 +63,9 @@ dpkg (1.15.1) UNRELEASED; urgency=low
   * Bump Standards-Version to 3.8.1 (no change required).
   * Bump Standards-Version to 3.8.1 (no change required).
   * Do not store usernames and group names in tarballs created by dpkg-source,
   * Do not store usernames and group names in tarballs created by dpkg-source,
     they are anyway ignored at unpack time. Closes: #523184
     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 ]
   [ Guillem Jover ]
   * Fix typo in dpkg output (‘unexecpted’ → ‘unexpected’). Closes: #519082
   * Fix typo in dpkg output (‘unexecpted’ → ‘unexpected’). Closes: #519082

+ 4 - 1
scripts/t/900_update_alternatives.t

@@ -53,7 +53,7 @@ my @choices = (
 );
 );
 my $nb_slaves = 2;
 my $nb_slaves = 2;
 plan tests => (4 * ($nb_slaves + 1) + 2) * 24 # number of check_choices
 plan tests => (4 * ($nb_slaves + 1) + 2) * 24 # number of check_choices
-		+ 60;			      # rest
+		+ 63;			      # rest
 
 
 sub cleanup {
 sub cleanup {
     system("rm -rf t.tmp/ua && mkdir -p $admindir && mkdir -p $altdir");
     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);
 install_choice(0);
 ok(!-l $main_link, "install preserves files that should be links");
 ok(!-l $main_link, "install preserves files that should be links");
 ok(!-l "$bindir/slave1", "install preserves files that should be slave 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"]);
 install_choice(0, params => ["--force"]);
 check_choice(0, "auto", "install --force replaces files with links");
 check_choice(0, "auto", "install --force replaces files with links");
 
 

+ 2 - 2
scripts/update-alternatives.pl

@@ -1045,13 +1045,13 @@ sub remove {
     my ($self) = @_;
     my ($self) = @_;
     my ($link, $name) = ($self->link(), $self->name());
     my ($link, $name) = ($self->link(), $self->name());
     main::checked_rm("$link.dpkg-tmp");
     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.dpkg-tmp");
     main::checked_rm("$altdir/$name");
     main::checked_rm("$altdir/$name");
     foreach my $slave ($self->slaves()) {
     foreach my $slave ($self->slaves()) {
         my $slink = $self->slave_link($slave);
         my $slink = $self->slave_link($slave);
         main::checked_rm("$slink.dpkg-tmp");
         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-tmp");
         main::checked_rm("$altdir/$slave");
         main::checked_rm("$altdir/$slave");
     }
     }