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

MarkInstall, Auto-Installed, and programs that misuse FromUser



Hello

The MarkInstall argument FromUser has two orthogonal sets of effects,
depending on it's value and the current state of the system.

It is passed to isModeChangeOk (and others) and:
(1) influences whether the request should override a hold on that
    package, etc..

It also controls:
(2) when a previously not installed package is marked auto-installed
    (FromUser=false); and
(3) when a previously auto-installed package is marked
    manually-installed (FromUser=true and some other bits that
    should be removed [1]).

The later behaviour is relatively new, introduced in apt/0.8.11.2:

  * apt-pkg/depcache.cc:
    - mark a package which was requested to be installed on commandline
      always as manual regardless if it is already marked or not as the
      marker could be lost later by the removal of rdepends (Closes: #612557)

It is easy to see that (2) is ok.  Also, (3) is a fine idea when dealing
with a lot of situations.

In some cases, another program decides what should be installed,
upgraded, etc. and does not desire (3).  Some programs use this hack:

  FromUser = not (pkg is auto-installed)
  MarkInstall(pkg, FromUser)

to avoid it, thus preserving a packages existing auto-installed status.
However, this may have the side effect of *not* installing the new
package, due to (1).  Situations where it is desirable to override holds
and not change whether a package is marked auto-installed:

- restoring previously saved selections (dselect, aptitude do this
  on load; synaptic --set-selections);
- applying custom dependency resolution (aptitude);
- upgrading a set of packages that has been reviewed by the user but
  does not mean they should all be marked manual (aptitude,
  update-manager).

FromUser=false is wrong in such situations.  The correct way to preserve
auto-installed status is to explicitly save and restore it around
MarkInstall:

  FromUser = [decided based on context]
  Auto = pkg is auto-installed
  MarkInstall(pkg, FromUser)
  MarkAuto(pkg, Auto)

Patches have been filed against python-apt [2] and python-aptdaemon [3],
but the problem may be present in other programs.  In particular,
python-apt, a library, should be exposing FromUser to the caller, and
not using it internally to control auto-installed.

I do not think it is a problem that synaptic's mark-upgrade causes the
selected package to become manually-installed, for the same reason that
this is ok for "apt-get install".

Moving forward, I see three options:
- move (3) to each frontend which desires that behaviour,
  i.e. apt-get.cc (duplicates work, maybe problems);
- allow to temporarily disable (3) (avoids the hacks for preserving
  auto-installed); or
- at least update any program that misuses FromUser, changing it to
  the save-and-restore hack instead.

It is probably not desirably to introduce an additional parameter on
MarkInstall, since FromUser adequately covers (1) and (2).

Regards

[1] Some extra conditions were added to MarkInstall to prevent aptitude
    from clearing all upgraded packages of auto-installed.  These are
    (mostly) no longer needed since aptitude/0.6.4-1 uses the above
    save-and-restore hack for auto-installed.  These extra conditions
    should be removed with an appropriate Breaks entry on aptitude, to
    at least make the library more predictable.
[2] http://bugs.debian.org/686726
[3] http://bugs.debian.org/685044


Reply to: