Преглед на файлове

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 години
родител
ревизия
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/dpkg.h (ohshitvb): Remove function prototype.
 	* lib/ehandle.c (ohshitvb): Remove function definition.
 	* 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>
 2009-02-06  Raphael Hertzog  <hertzog@debian.org>
 
 
 	* scripts/update-alternatives.pl (set_links): Remove slavelinks
 	* 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
     Closes: #98822
   * Properly remove inappropriate slave links in update-alternatives even when
   * Properly remove inappropriate slave links in update-alternatives even when
     we switch to manual mode with --set or --config. Closes: #388313
     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 ]
   [ Pierre Habouzit ]
   * Add a --query option to update-alternatives. Closes: #336091, #441904
   * 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
 When a group is in automatic mode, the alternatives system will
 automatically decide, as packages are installed and removed,
 automatically decide, as packages are installed and removed,
 whether and how to update the links.
 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
 .PP
 Link groups are in automatic mode when they are first introduced to
 Link groups are in automatic mode when they are first introduced to
 the system.
 the system.

+ 14 - 13
scripts/update-alternatives.pl

@@ -637,20 +637,21 @@ for (my $i = 0; $i <= $#versions; $i++) {
 paf('');
 paf('');
 close(AF) || quit(sprintf(_g("unable to close %s: %s"), "$admindir/$name.dpkg-new", $!));
 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 ($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");
 checked_mv("$admindir/$name.dpkg-new", "$admindir/$name");