[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#164214: Improved fix for update-alternatives, jumping to auto mode bug


I improved the fix a bit after testing different situations. Now, it
coveres the cases:

 - non-existent link was to remove
 - some other link was choosen by-hand as alternative, not the program
   that is to be removed now

In both cases update-alternative currently changes immediately to the
"auto" mode and drops the user selection, because of insufficient
conditions in the init script. The following will fix it:

--- /usr/sbin/update-alternatives       2003-04-26 22:19:04.000000000 +0200
+++ update-alternatives 2003-08-17 01:38:06.000000000 +0200
@@ -309,7 +309,7 @@
 if ($mode eq 'remove') {
-    if ($manual eq "manual" and $state ne "expected") {
+    if ($manual eq "manual" and $state ne "expected" and (map { $hits += $apath eq $_ } @versions) and $hits and ($linkname eq $apath) ) {
        &pr("Removing manually selected alternative - switching to auto mode");
        $manual= "auto";

and the long list of ancient bugs can be closed:

+  * update-alternatives looks whether the target path exists on removing,
+    closes: #37254, #85502, #158973, #48895, #158973, #164214, #203791

Comments: the map construct is better than the grep construct proposed
by Colin, since its "solution" was not different than my old grep call,
both having the same problem with included regexp chars in the string.

Nicht weil die Dinge schwierig sind wagen wir sie nicht,
sondern weil wir sie nicht wagen sind sie schwierig.
		-- Lucius Annaeus Seneca

Reply to: