Bug#823534: apt-get remove is unhelpful for virtual packages

2016-05-06 Thread David Kalnischkies
Hi,

(adding submitter to CC as there was an explicit Reply-To header)

On Fri, May 06, 2016 at 07:31:18AM +0200, Carsten Hey wrote:
> * Richard Stallman [2016-05-05 14:48 -0400]:
> > Package: apt
> > Version: 1.0.1ubuntu2.13+7.0trisquel3
> >
> > I tried to remove a package which is virtual, specifically nethack.
> > apt-get told me it could not do this, but said nothing about
> > what to do.
> 
> "apt-cache showpkg mail-transport-agent" lists "Reverse Provides:",
> but it does not show which m-t-a is installed.  Maybe this is worth
> an additional bug report?

showpkg is not really a user interface… it can be handy for debugging,
but if we implement a better show, it should be in 'show'. Currently its
a bit unhelpful (with just saying its a virtual package).

The biggest hindrance so far was always that 'apt-cache show' is used by
various tools expecting a certain behaviour (like no output & zero-exit
code with virtual packages – I naively changed the later once and the
world exploded…), but 'apt' should really be able to do something more
sensible here given that its usage is discouraged in scripts.


> > It would surely be easy to make it handle a virtual package by
> > seeing which real package provides it, and offering to delete that
> > one.
> 
> I see three possible ways to address this issue:
> 
>  1. Offering to delete the real package, as rms wrote.  apt-get
> would then, for instance, ask "... Would you like to remove
> postfix instead? [yN]".
> 
> This might or might not be useful for /usr/bin/apt, but I hope
> apt-get will stay as non-interactive as it has always been.

Additional questions in a mostly non-interactive command feel indeed
a bit strange. After all, apt is asking anyhow for confirmation on all
the choices it made, singling out a few seems wrong, especially as we
have a few "Did you mean?" messages which follow the "press-N-and-adapt-
commandline"-style already.

The worst is through: If someone came along with -y on this command,
which behaviour is the default and/or should I fail the execution and
why are there no --assume-did-you-mean-yes and -no flags? No, thanks…


>  2. Provide a more useful output.  A good example is the output of
> apt-get _install_ virtual-package on jessie:
> 
> # apt-get install mail-transport-agent
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> Package mail-transport-agent is a virtual package provided by:
>   opensmtpd 5.7.3p2-1
>   ...
>   exim4-daemon-heavy 4.84.2-1
> You should explicitly select one to install.
> 
> E: Package 'mail-transport-agent' has no installation candidate

The "problem" here is that you obviously need to make a choice here as
you probably don't want apt to pick one at random or want them all (or
just a few) in case they aren't mutually exclusive, hence the error.

For remove, the story is a bit more complex: The user likely means:
Remove the mail-transport-agent installed on the system, but as you
mention further in your mail the user might also mean "don't install any
mail-transport-agent" (there is a good chance if you remove exim4 that
apt will 'helpfully' install another instead of removing everything
depending on a mail-transport-agent). In neither case should there be an
error if no agent is installed. And then, there are the cases in which
the providers aren't mutually exclusive (like nethack) were you might
have installed all three, what did the user mean here?

Perhaps the most reasonable choice for virtual packages in remove is to
let apt remove all providers with appropriate "Note, selecting 'foo-x11'
instead of 'foo'" and "Package 'foo-x11' is not installed, so not
removed" messages as that this will implicitly generate a list, the user
knows what is going on, it is likely what was intended and we don't need
new string(s).


>  3. "Do What I Mean" (DWIM) - on IRC, it has been suggested to remove
> the real package if there is only one provider.
> 
> Assume that the packages foo and bar are installed, that foo is not
> available via an apt repository anymore, and that bar provides foo.
> 
> "apt-get remove foo" would then remove foo the first time
> it is run and it would remove bar the second time it is run.
> I wouldn't consider this to be an intuitive behaviour.

This actually happens already¹, BUT your assumption is wrong. The key is
"only one provider" but in your example with foo and bar installed, you
have two providers. The state of providers doesn't even matter, all what
matters is that apt knows about only one provider from all its data
sources (which dpkg/status is, too, just that you never configure it in
sources.list explicitly). The behaviour is 'stolen' from install btw
which will not show the list mentioned above if there is only one
provider and instead just pick the one for install (with a note about
doing this).

¹ at least 

Bug#823534: apt-get remove is unhelpful for virtual packages

2016-05-05 Thread Carsten Hey
Hi,

* Richard Stallman [2016-05-05 14:48 -0400]:
> Package: apt
> Version: 1.0.1ubuntu2.13+7.0trisquel3
>
> I tried to remove a package which is virtual, specifically nethack.
> apt-get told me it could not do this, but said nothing about
> what to do.

"apt-cache showpkg mail-transport-agent" lists "Reverse Provides:",
but it does not show which m-t-a is installed.  Maybe this is worth
an additional bug report?


> It would surely be easy to make it handle a virtual package by
> seeing which real package provides it, and offering to delete
> that one.

I see three possible ways to address this issue:

 1. Offering to delete the real package, as rms wrote.  apt-get
would then, for instance, ask "... Would you like to remove
postfix instead? [yN]".

This might or might not be useful for /usr/bin/apt, but I hope
apt-get will stay as non-interactive as it has always been.

 2. Provide a more useful output.  A good example is the output of
apt-get _install_ virtual-package on jessie:

# apt-get install mail-transport-agent
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package mail-transport-agent is a virtual package provided by:
  opensmtpd 5.7.3p2-1
  ...
  exim4-daemon-heavy 4.84.2-1
You should explicitly select one to install.

E: Package 'mail-transport-agent' has no installation candidate

 3. "Do What I Mean" (DWIM) - on IRC, it has been suggested to remove
the real package if there is only one provider.

Assume that the packages foo and bar are installed, that foo is not
available via an apt repository anymore, and that bar provides foo.

"apt-get remove foo" would then remove foo the first time
it is run and it would remove bar the second time it is run.
I wouldn't consider this to be an intuitive behaviour.

At least I try to remove packages I removed previously from time
to time (although I know that I already removed them).  And I don't
think I'm the only one who occasionally runs "apt-get install pkg1
pkg2- pkg3-", and then presses the up key and appends additional
package names in order to save some key presses.


> Alas. I can't reproduce this now, or show you the output,
> because I no longer have those packages installed.

On stable, the according output is:

  # apt-get remove mail-transport-agent
  Reading package lists... Done
  Building dependency tree
  Reading state information... Done
  Virtual packages like 'mail-transport-agent' can't be removed
  The following packages were automatically installed ...

I noticed that the 'Virtual packages ...' line vanishes if stdout is
piped through, e.g., cat and wonder if this is done deliberately.


Regards
Carsten



Bug#823534: apt-get remove is unhelpful for virtual packages

2016-05-05 Thread Richard Stallman
Package: apt
Version: 1.0.1ubuntu2.13+7.0trisquel3

I tried to remove a package which is virtual, specifically nethack.
apt-get told me it could not do this, but said nothing about
what to do.

It would surely be easy to make it handle a virtual package by
seeing which real package provides it, and offering to delete
that one.

Alas. I can't reproduce this now, or show you the output,
because I no longer have those packages installed.

I am using Trisquel, not Debian, and reportbug does not seem to
work for me.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.