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

update-alternatives: remove the link group together with last alternative

* scripts/update-alternatives.pl: Remove the link group when
the last choice is removed, even if we are in manual mode.
* man/update-alternatives.8: Update the documentation
accordingly to not be as strong about not touching links in manual
mode.
Raphael Hertzog лет назад: 17
Родитель
Сommit
aaf5632144
4 измененных файлов с 27 добавлено и 15 удалено
  1. 8 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 3 2
      man/update-alternatives.8
  4. 14 13
      scripts/update-alternatives.pl

+ 8 - 0
ChangeLog

@@ -3,6 +3,14 @@
 	* lib/dpkg.h (ohshitvb): Remove function prototype.
 	* lib/ehandle.c (ohshitvb): Remove function definition.
 
+2009-02-06  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/update-alternatives.pl: Remove the alternative when
+	the last choice is removed, even if we are in manual mode.
+	* man/update-alternatives.8: Update the documentation
+	accordingly to not be as strong about not touching links in manual
+	mode.
+
 2009-02-06  Raphael Hertzog  <hertzog@debian.org>
 
 	* scripts/update-alternatives.pl (set_links): Remove slavelinks

+ 2 - 0
debian/changelog

@@ -131,6 +131,8 @@ dpkg (1.15.0) UNRELEASED; urgency=low
     Closes: #98822
   * Properly remove inappropriate slave links in update-alternatives even when
     we switch to manual mode with --set or --config. Closes: #388313
+  * Modify update-alternatives to always remove the alternative group when the last
+    alternative is removed (even in manual mode).
 
   [ Pierre Habouzit ]
   * Add a --query option to update-alternatives. Closes: #336091, #441904

+ 3 - 2
man/update-alternatives.8

@@ -95,8 +95,9 @@ in one of two modes: automatic or manual.
 When a group is in automatic mode, the alternatives system will
 automatically decide, as packages are installed and removed,
 whether and how to update the links.
-In manual mode, the alternatives system will not change the links;
-it will leave all the decisions to the system administrator.
+In manual mode, the alternatives system will retain the choice of
+the administrator and avoid changing the links (except when something is
+broken).
 .PP
 Link groups are in automatic mode when they are first introduced to
 the system.

+ 14 - 13
scripts/update-alternatives.pl

@@ -637,20 +637,21 @@ for (my $i = 0; $i <= $#versions; $i++) {
 paf('');
 close(AF) || quit(sprintf(_g("unable to close %s: %s"), "$admindir/$name.dpkg-new", $!));
 
+# Purge alternative when nothing left
+if ($best eq '') {
+    pr(sprintf(_g("Last package providing %s (%s) removed, deleting it."), $name, $link))
+        if $verbosemode > 0;
+    checked_rm("$altdir/$name");
+    checked_rm("$link");
+    checked_rm("$admindir/$name.dpkg-new");
+    checked_rm("$admindir/$name");
+    exit(0);
+}
+
 if ($mode eq 'auto') {
-    if ($best eq '') {
-        pr(sprintf(_g("Last package providing %s (%s) removed, deleting it."), $name, $link))
-          if $verbosemode > 0;
-        checked_rm("$altdir/$name");
-        checked_rm("$link");
-        checked_rm("$admindir/$name.dpkg-new");
-        checked_rm("$admindir/$name");
-        exit(0);
-    } else {
-	checked_alternative($name, $link, $best);
-        checked_rm("$altdir/$name.dpkg-tmp");
-        symlink($best,"$altdir/$name.dpkg-tmp");
-    }
+    checked_alternative($name, $link, $best);
+    checked_rm("$altdir/$name.dpkg-tmp");
+    checked_symlink($best, "$altdir/$name.dpkg-tmp");
 }
 
 checked_mv("$admindir/$name.dpkg-new", "$admindir/$name");