On 2025-12-29 at 09:39, Jörg-Volker Peetz wrote:

> aptitude might help you in this case.
> 
> To find all packages recommended, for example, by apt call
> 
>    aptitude -F "%M%a %p %v# %V#" search '~i~Rrecommends:^apt$'
> 
> it shows the installed version of the package(s) and the version the package 
> can 
> be upgraded to.
> For upgrading all packages recommended by apt call
> 
>    aptitude install '~U~Rrecommends:^apt$'
> 
> The "^" and "$" characters indicate that just the recommendations for the 
> package beginning with apt and ending with apt are to be considered.

Wouldn't that just result in initiating an explicit 'install' action on
the Recommends:'ed packages, though?

I can already do that; I already know what the packages involved are for
the all-installed-packages case (because 'apt-get dist-upgrade' tells
me, after I've finished with the manually-installed-packages upgrades),
and if I wanted to pull out just the ones from a particular package,
have multiple ways to potentially do that (including the one you
suggest), although doing it recursively down the dependency chain would
be harder.

The trouble is that (as I referenced in the parenthetical final
paragraph of my initial post) carrying out an explicit 'install' action
on an automatically-installed package also causes - or at least used to
cause, and I haven't seen any notice that this has changed - it to be
marked as manually installed. By contrast, having such a package be
upgraded because of a (versioned) dependency from another package does
not affect its install-type state.

Identifying which packages need to be upgraded is not the difficulty
here. Getting apt (etc.) to upgrade them piecemeal (as distinct from
doing it en-masse, via 'dist-upgrade' or the like), without having it
also change that marking state, is what I'm trying to figure out.

Ideally I'd prefer to be able to say

# apt-get upgrade-dependencies <packagename>

or similar, and have all packages down the dependency chain (with
Depends: and Recommends: included or not depending on the setting of the
install-recommended-packages configuration option) be upgraded to the
most eligible available version, with the same eligibility criteria that
would be used when installing <packagename> in the first place, or when
running 'apt-get dist-upgrade'.


I suppose in principle I could script something that would do

  for every package specified:
    get all its dependencies, recursively (respecting that config)
    for every package specified or gotten:
      if it has a newer eligible version showing as available:
        check whether it is marked as manually installed
        upgrade it
        if it was not marked as manually installed:
          explicitly set it as automatically installed

but some parts of that look like they would be a *pain* to implement in
the scripting languages I have available (the eligibility checking in
particular, since I'd basically have to implement some form of handling
for the package-source priorities reported by e.g. 'apt-cache policy'),
and I'd really rather not go to that much trouble if there's already a
way to achieve the end result with less my-end complexity.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to