• Re: finding apt dependencies

    From jean-christophe@3:633/10 to All on Tuesday, July 07, 2026 21:20:01


    may be use apt-cache --installed

    regards
    jean-chistophe

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From jean-christophe@3:633/10 to All on Tuesday, July 07, 2026 21:20:01


    On mar., 2026-07-07 at 14:18 -0400, Eben King wrote:
    I have a need to find the upgradable package with the most
    dependencies.
    ÿ So far I've got this, in /bin/sh:

    allpkgs="$(apt list --upgradable 2> /dev/null | grep / | cut -f 1 -d
    / )"
    max=0
    countlist=""
    for package in $allpkgs ; do
    ÿÿ dependencies=$(apt-get --simulate upgrade "$package" | grep
    upgraded,
    cut -f 1 -d ' ') # get #dependencies, maybe; this is the slow bit
    ÿÿ [ "$dependencies" -gt "$max" ] && max="$dependencies"
    ÿÿ countlist="$countlist $dependencies $pkgname"
    done

    It works, but is definitely not fast. Is there a faster way?

    may be try awk

    apt-get is a big cmd and is great

    remember -gt ?

    may be use apt-cache --full

    regards
    jean-chistophe

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Robert Heller@3:633/10 to All on Tuesday, July 07, 2026 21:30:02
    Why do you need to do this? And why does speed matter?

    At Tue, 7 Jul 2026 14:18:25 -0400 Eben King <eben@gmx.us> wrote:


    I have a need to find the upgradable package with the most dependencies.
    So far I've got this, in /bin/sh:

    allpkgs="$(apt list --upgradable 2> /dev/null | grep / | cut -f 1 -d / )" max=0
    countlist=""
    for package in $allpkgs ; do
    dependencies=$(apt-get --simulate upgrade "$package" | grep upgraded,
    | cut -f 1 -d ' ') # get #dependencies, maybe; this is the slow bit
    [ "$dependencies" -gt "$max" ] && max="$dependencies"
    countlist="$countlist $dependencies $pkgname"
    done

    It works, but is definitely not fast. Is there a faster way?




    --
    Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
    Deepwoods Software -- Custom Software Services
    http://www.deepsoft.com/ -- Linux Administration Services
    heller@deepsoft.com -- Webhosting Services


    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From jean-christophe@3:633/10 to All on Tuesday, July 07, 2026 22:00:01


    On mar., 2026-07-07 at 14:18 -0400, Eben King wrote:
    I have a need to find the upgradable package with the most
    dependencies.
    ÿ So far I've got this, in /bin/sh:

    allpkgs="$(apt list --upgradable 2> /dev/null | grep / | cut -f 1 -d
    / )"
    max=0
    countlist=""
    for package in $allpkgs ; do
    ÿÿ dependencies=$(apt-get --simulate upgrade "$package" | grep
    upgraded,
    cut -f 1 -d ' ') # get #dependencies, maybe; this is the slow bit
    ÿÿ [ "$dependencies" -gt "$max" ] && max="$dependencies"
    ÿÿ countlist="$countlist $dependencies $pkgname"
    done

    It works, but is definitely not fast. Is there a faster way?

    https://x0.at/FdVb.txt

    is there some faster way in /bin/sh

    me say not dependecies

    could you test ?

    regards,
    jean-christophe.

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From jean-christophe@3:633/10 to All on Tuesday, July 07, 2026 22:00:02


    On mar., 2026-07-07 at 14:18 -0400, Eben King wrote:
    I have a need to find the upgradable package with the most
    dependencies.
    ÿ So far I've got this, in /bin/sh:

    allpkgs="$(apt list --upgradable 2> /dev/null | grep / | cut -f 1 -d
    / )"
    max=0
    countlist=""
    for package in $allpkgs ; do
    ÿÿ dependencies=$(apt-get --simulate upgrade "$package" | grep
    upgraded,
    cut -f 1 -d ' ') # get #dependencies, maybe; this is the slow bit
    ÿÿ [ "$dependencies" -gt "$max" ] && max="$dependencies"
    ÿÿ countlist="$countlist $dependencies $pkgname"
    done

    It works, but is definitely not fast. Is there a faster way?
    https://x0.at/FdVb.txt

    is there some faster way in /bin/sh

    me say not depencies

    could you test ?

    regards,
    jean-christophe.

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From jean-christophe@3:633/10 to All on Tuesday, July 07, 2026 22:10:01


    On mar., 2026-07-07 at 14:18 -0400, Eben King wrote:
    I have a need to find the upgradable package with the most
    dependencies.
    ÿ So far I've got this, in /bin/sh:

    allpkgs="$(apt list --upgradable 2> /dev/null | grep / | cut -f 1 -d
    / )"
    max=0
    countlist=""
    for package in $allpkgs ; do
    ÿÿ dependencies=$(apt-get --simulate upgrade "$package" | grep
    upgraded,
    cut -f 1 -d ' ') # get #dependencies, maybe; this is the slow bit
    ÿÿ [ "$dependencies" -gt "$max" ] && max="$dependencies"
    ÿÿ countlist="$countlist $dependencies $pkgname"
    done

    It works, but is definitely not fast. Is there a faster way?
    https://x0.at/FdVb.txt

    is there some faster way in /bin/sh

    me say not dependencies

    could you test ?

    regards,
    jean-christophe.

    i sorry my mapping after more 48h no sleep is difficulte dict my finger

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Robert Heller@3:633/10 to All on Tuesday, July 07, 2026 22:20:01
    At Tue, 7 Jul 2026 16:05:22 -0400 Eben King <eben@gmx.us> wrote:


    On 7/7/26 15:21, Robert Heller wrote:
    At Tue, 7 Jul 2026 14:18:25 -0400 Eben King <eben@gmx.us> wrote:


    I have a need to find the upgradable package with the most dependencies.
    Why do you need to do this? And why does speed matter?

    Generally, I dislike it when lots of things change at the same time, so rather than going through my upgradable packages periodically and
    updating the lot of them, I run a cron job that, once a day, upgrades a package chosen at random from the list of upgradable packages. I got to thinking it might be bad to update some parts of a package and not
    others, so I want to upgrade those at the top of their tree of dependencies.

    It needs to be fast because I want to cause as little disturbance as possible. Technically it doesn't, it'll work as it is, it just scratches
    and itch to get it done with.


    Typically, with a LTS release, the updates rarely cause any disruptive changes. On my public-facing VPS system I just run the updates every Sunday. The amount of updates that arrive in a weeks time is generally low.




    --
    Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
    Deepwoods Software -- Custom Software Services
    http://www.deepsoft.com/ -- Linux Administration Services
    heller@deepsoft.com -- Webhosting Services


    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Charles Curley@3:633/10 to All on Tuesday, July 07, 2026 22:20:02
    On Tue, 7 Jul 2026 16:05:22 -0400
    Eben King <eben@gmx.us> wrote:

    Generally, I dislike it when lots of things change at the same time,
    so rather than going through my upgradable packages periodically and updating the lot of them, I run a cron job that, once a day, upgrades
    a package chosen at random from the list of upgradable packages. I
    got to thinking it might be bad to update some parts of a package and
    not others, so I want to upgrade those at the top of their tree of dependencies.

    I agree, upgrading some packages but not other related packages is a
    bad idea.

    May I suggest you look at the unattended-upgrades package? It will do a
    lot of what you want once a day.

    --
    Does anybody read signatures any more?

    https://charlescurley.com
    https://charlescurley.com/blog/

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From jean-christophe@3:633/10 to All on Tuesday, July 07, 2026 23:10:01


    On mar., 2026-07-07 at 16:12 -0400, Eben King wrote:
    On 7/7/26 15:57, jean-christophe wrote:


    On mar., 2026-07-07 at 14:18 -0400, Eben King wrote:
    I have a need to find the upgradable package with the most
    dependencies.

    ...

    It works, but is definitely not fast. Is there a faster way?

    https://x0.at/FdVb.txt

    is there some faster way in /bin/sh

    me say not depencies

    could you test ?

    eben@cerberus:~$ apt-cache policy | grep -E '^\s*Installed:\s*(.+)$'
    1

    "1" is the exit status.ÿ Maybe we have different versions of apt-get?

    eben@cerberus:~$ apt-get ---version
    apt 2.6.1 (amd64)
    Supported modules:
    *Ver: Standard .deb
    *Pkg:ÿ Debian dpkg interface (Priority 30)
    ÿ Pkg:ÿ Debian APT solver interface (Priority -1000)
    ÿ Pkg:ÿ Debian APT planner interface (Priority -1000)
    ÿ S.L: 'deb' Debian binary tree
    ÿ S.L: 'deb-src' Debian source tree
    ÿ Idx: Debian Source Index
    ÿ Idx: Debian Package Index
    ÿ Idx: Debian Translation Index
    ÿ Idx: Debian dpkg status file
    ÿ Idx: Debian deb file
    ÿ Idx: Debian dsc file
    ÿ Idx: Debian control file
    ÿ Idx: EDSP scenario file
    ÿ Idx: EIPP scenario file
    ----------------------------------------------------------------------- jean-christophe@debian:~/Documents/codes/bash$ apt-get --version
    apt 3.0.3 (amd64)
    Supported modules:
    *Ver: Standard .deb
    *Pkg: Debian dpkg interface (Priority 30)
    Pkg: Debian APT solver interface (Priority -1000)
    Pkg: Debian APT planner interface (Priority -1000)
    S.L: 'deb' Debian binary tree
    S.L: 'deb-src' Debian source tree
    Idx: Debian Source Index
    Idx: Debian Package Index
    Idx: Debian Translation Index
    Idx: Debian dpkg status file
    Idx: Debian deb file
    Idx: Debian dsc file
    Idx: Debian control file
    Idx: EDSP scenario file
    Idx: EIPP scenario file
    jean-christophe@debian:~/Documents/codes/bash$

    i am no trixie

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From John Hasler@3:633/10 to All on Tuesday, July 07, 2026 23:50:01
    Eben King writes:
    I got to thinking it might be bad to update some parts of a package
    and not others...

    You can't update part of a package with apt. Do you mean "upgrade some
    of the dependencies of a package and not others"? Apt deals with that.
    It's what it's for.
    --
    John Hasler
    john@sugarbit.com
    Elmwood, WI USA

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Andy Smith@3:633/10 to All on Wednesday, July 08, 2026 00:10:01
    On Tue, Jul 07, 2026 at 04:05:22PM -0400, Eben King wrote:
    On 7/7/26 15:21, Robert Heller wrote:
    At Tue, 7 Jul 2026 14:18:25 -0400 Eben King <eben@gmx.us> wrote:


    I have a need to find the upgradable package with the most dependencies.
    Why do you need to do this? And why does speed matter?

    Generally, I dislike it when lots of things change at the same time

    Unless you are on testing or unstable surely almost all updates are
    security updates and you want them all pretty much as soon as possible?

    I got to thinking it might be bad to update some parts of a package
    and not others, so I want to upgrade those at the top of their tree of dependencies.

    As packages are not divisible entities for upgrade purposes, I assume
    you mean the situation where package foo depends upon package bar and
    both of them are due an upgrade, you are saying that you would prefer to upgrade foo so as to not get a version of bar that is unexpected by the non-upgraded foo.

    The thing is, this is unnecessary and won't work as you would want
    anyway. If foo just lists a dependency on bar then any version of bar will
    be good enough for foo. So there should be no harm in upgrading bar and
    doing so won't force an upgrade of foo unless there is also a dependency the other way that lists a specific version requirement.

    Normally you'd just do "apt full-upgrade" or whatever and let everything
    be upgraded but in this instance there should be no harm in upgrading
    only bar with something like "apt install --only-upgrade bar". Apart
    from that there is a security update pending for foo that you've decided
    not to apply.

    I am not sure what would happen if you told apt to upgrade only foo, and
    the incoming foo package had a versioned dependency on an upgraded bar
    package but you had not allowed the upgrade of any other package.

    Thanks,
    Andy

    --
    https://bitfolk.com/ -- No-nonsense VPS hosting

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Max Nikulin@3:633/10 to All on Wednesday, July 08, 2026 04:50:01
    On 08/07/2026 3:05 am, Eben King wrote:
    On 7/7/26 15:21, Robert Heller wrote:
    At Tue, 7 Jul 2026 14:18:25 -0400 Eben King wrote:

    I have a need to find the upgradable package with the most dependencies.
    Why do you need to do this?ÿ And why does speed matter?

    Generally, I dislike it when lots of things change at the same time, so rather than going through my upgradable packages periodically and
    updating the lot of them, I run a cron job that, once a day, upgrades a package chosen at random from the list of upgradable packages.

    From my point of view, you are seeking for subtle bugs due to partial upgrades. Perhaps apt-listchanges might help you to manage updates
    (notice that changelog entries are not enabled by default). Security
    updates have been mentioned in this thread already.

    I recall a similar request a half of the year ago. For those who want to
    try to shoot their feet, I expect, APT Python API should allow to query upgradable packages and to walk through their dependency graph.

    dependencies=$(apt-get --simulate upgrade "$package" | grep upgraded, | cut -f 1 -d ' ')

    Have you tried to run 'apt-get upgrade "$package"' to verify that it
    acts accordingly to your expectations?

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Robert Heller@3:633/10 to All on Wednesday, July 08, 2026 05:40:01
    At Tue, 7 Jul 2026 22:05:19 +0000 Andy Smith <andy@strugglers.net> wrote:


    On Tue, Jul 07, 2026 at 04:05:22PM -0400, Eben King wrote:
    On 7/7/26 15:21, Robert Heller wrote:
    At Tue, 7 Jul 2026 14:18:25 -0400 Eben King <eben@gmx.us> wrote:


    I have a need to find the upgradable package with the most dependencies.
    Why do you need to do this? And why does speed matter?

    Generally, I dislike it when lots of things change at the same time

    Unless you are on testing or unstable surely almost all updates are
    security updates and you want them all pretty much as soon as possible?

    I got to thinking it might be bad to update some parts of a package
    and not others, so I want to upgrade those at the top of their tree of dependencies.

    As packages are not divisible entities for upgrade purposes, I assume
    you mean the situation where package foo depends upon package bar and
    both of them are due an upgrade, you are saying that you would prefer to upgrade foo so as to not get a version of bar that is unexpected by the non-upgraded foo.

    The thing is, this is unnecessary and won't work as you would want
    anyway. If foo just lists a dependency on bar then any version of bar will
    be good enough for foo. So there should be no harm in upgrading bar and
    doing so won't force an upgrade of foo unless there is also a dependency the other way that lists a specific version requirement.

    Normally you'd just do "apt full-upgrade" or whatever and let everything
    be upgraded but in this instance there should be no harm in upgrading
    only bar with something like "apt install --only-upgrade bar". Apart
    from that there is a security update pending for foo that you've decided
    not to apply.

    I am not sure what would happen if you told apt to upgrade only foo, and
    the incoming foo package had a versioned dependency on an upgraded bar package but you had not allowed the upgrade of any other package.

    "apt install foo"

    where foo is an upgrade candidate will upgrade foo and if any of its depenencies have upgrades, those depenencies will get upgraded too.

    If foo depends on bar and if both are updatable and you upgrade bar, foo will get upgraded. There is little to be gained by pre-checking dependencies as the OP wants to do. "Randomly" upgrading a single package will likely upgrade some set of other packages. apt is very clever and it is pretty much impossible to screw anything up by trying to upgrade single packages in any partitular order. If you do "apt full-upgrade, say once a week, the upgrade most weeks will take less than 30 minutes. The only possible time it will take longer is when a new point release comes out.

    What the OP wants to do is not going to really gain anything useful in terms of time, etc.

    The kind of thing the OP is looking to do only really makes sense in two cases:

    Case 1: A machine that has been "neglacted" (not had "apt update" and "apt full-upgrade" run in a very long time.

    Case 2: A machine that has no "good" connection to the Internet -- eg a
    machine that is "air gapped" or only has a slow and unreliable (dialup?) connection to the Internet, and thus needs to be updated in "stages", possibly using something like limited removable media (media too small to hold a full mirror of the repositories). (Given the sizes of usb flash drives currently available, this probably not a real issue.)


    Thanks,
    Andy


    --
    Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
    Deepwoods Software -- Custom Software Services
    http://www.deepsoft.com/ -- Linux Administration Services
    heller@deepsoft.com -- Webhosting Services


    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From John Hasler@3:633/10 to All on Wednesday, July 08, 2026 06:10:01
    Andy Smith wrote:
    I am not sure what would happen if you told apt to upgrade only foo, and
    the incoming foo package had a versioned dependency on an upgraded bar package but you had not allowed the upgrade of any other package.

    Then nothing will happen, obviously. Apt will refuse to install a
    package if it cannot satisfy the dependencies. Handling dependencies is
    what Apt is *for*.
    --
    John Hasler
    john@sugarbit.com
    Elmwood, WI USA

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From jean-christophe@3:633/10 to All on Wednesday, July 08, 2026 06:40:01
    eben@cerberus:~$ apt-cache policy | grep -E '^\s*Installed:\s*(.+)$'
    1

    "1" is the exit status.ÿ Maybe we have different versions of apt-get?

    try with that : https://x0.at/P0Kv.txt

    eben@cerberus:~$ apt-get ---version
    apt 2.6.1 (amd64)
    Supported modules:
    *Ver: Standard .deb
    *Pkg:ÿ Debian dpkg interface (Priority 30)
    ÿ Pkg:ÿ Debian APT solver interface (Priority -1000)
    ÿ Pkg:ÿ Debian APT planner interface (Priority -1000)
    ÿ S.L: 'deb' Debian binary tree
    ÿ S.L: 'deb-src' Debian source tree
    ÿ Idx: Debian Source Index
    ÿ Idx: Debian Package Index
    ÿ Idx: Debian Translation Index
    ÿ Idx: Debian dpkg status file
    ÿ Idx: Debian deb file
    ÿ Idx: Debian dsc file
    ÿ Idx: Debian control file
    ÿ Idx: EDSP scenario file
    ÿ Idx: EIPP scenario file

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From jean-christophe@3:633/10 to All on Wednesday, July 08, 2026 06:50:01


    On mer., 2026-07-08 at 06:34 +0200, jean-christophe wrote:
    eben@cerberus:~$ apt-cache policy | grep -E
    '^\s*Installed:\s*(.+)$'
    1

    "1" is the exit status.ÿ Maybe we have different versions of apt-
    get?

    try with that : https://x0.at/P0Kv.txt


    jean-christophe@debian:~/Documents/codes/bash$ time sh allpkgs-0.5.sh
    The list of packages and their upgradable dependencies has been saved
    to dependencies_count.txt.

    real 0m0.232s
    user 0m0.210s
    sys 0m0.027s
    jean-christophe@debian:~/Documents/codes/bash$

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Charles Curley@3:633/10 to All on Wednesday, July 08, 2026 17:20:01
    On Wed, 8 Jul 2026 09:43:19 -0400
    Eben King <eben@gmx.us> wrote:

    May I suggest you look at the unattended-upgrades package? It will
    do a lot of what you want once a day.

    Yes, it looks to do basically what I want. I have installed it, so
    now I have to figure out how to use it. Thanks.

    You are welcome.

    The two files I customize are /etc/apt/apt.conf.d/50unattended-upgrades
    and /etc/apt/apt.conf.d/20auto-upgrades. The latter I just copy in from /usr/share/unattended-upgrades/20auto-upgrades.

    In the former, I enable email reporting, set the automatic reboot time
    to 02:00, tell it to run only when on AC power (useful for laptops),
    and to not run on metered connections. I let it auto-reboot only on
    machines that don't have encrypted partitions, which these days means
    no machines auto-reboot.

    --
    Does anybody read signatures any more?

    https://charlescurley.com
    https://charlescurley.com/blog/

    --- PyGate Linux v1.5.18
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)