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

update-alternatives switching from manual to auto

[ I sent a similar message to 54933@bugs.debian.org but it got bounced
  and is now wallowing in the BTS junk.  At least that gave me a second
  chance to go into more detail in this message... ]

Hi, on March 6th Wichert wrote about bug #54933...

> Previously Jean-Philippe Gu=E9rard wrote:

> > Then, when the alternative that was last selected (when the system
> > revert to manual) is removed or renamed, the system stays manual,
> > and the program will cease to work.
> This is indeed wrong behaviour. I modified the code to return an
> alternative to automatic mode when a manually selected alternative is
> removed.

and here's the relevant section of update-alternatives from dpkg 1.6.14,
beginning on line 303:

if ($mode eq 'remove') {
    if ($manual eq "manual" and $state = "expected") {
        &pr("Removing manually selected alternative - switching to auto mode");
        $manual= "auto";

Shouldn't you be checking if $state = "nonexistant"? And aren't you
accidentally changing $state, instead of checking it's value? ( "=" vs.
"eq").  I don't know perl though...

I tracked this down because a few packages in woody have been annoyingly
resetting my manual alternatives to auto mode on each upgrade.  It turns
out that they call "update-alternatives --remove ..." in their prerm
scripts even if the package is only being upgraded.  I presume replacing
"=" with "eq" and "expected" with "nonexistant" in the above section of
code would (on the surface) fix that problem.

The thing is, wouldn't it also be proper behavior to return an
alternative to automatic mode when the file that it points to is being
--removed?  In that case, the "nonexistant" check won't help because
update-alternatives is most commonly called from the prerm script, so...

if ($mode eq 'remove') {
    if ($manual eq "manual" && ($state eq "nonexistant" ||
		readlink("$altdir/$name") eq $apath)) {
        &pr("Removing manually selected alternative - switching to auto mode");
        $manual= "auto";

would seem best, but then you're back to the problem of having packages
using --remove in their prerm scripts even when they're only being
upgraded.  IMHO bugs should be filed against all of these packages...
but I can't find any documentation describing when to use --remove, so
at this point I'll admit I'm way out of my league here, and await any
comments you ppl might have. :)



Reply to: