• Bug#990451: apt: the --no-all-versions option not working as documented

    From Manny@21:1/5 to All on Thu May 2 12:50:01 2024
    Package: apt
    Version: 2.6.1
    Followup-For: Bug #990451
    X-Debbugs-Cc: debbug.990451@sideload.33mail.com

    I just ran into this problem.

    Scenario: I am on a limited internet connection. So if I do “aptitude
    install $somepkg” which then pulls in many other packages, I need to
    know which packages will be fetched from the cloud and which are
    sourced from my local storage (which is the full 90gb debian release
    from 4 months ago). If the download is big, it will suck the bandwidth
    quota dry (which costs money).

    So I tried this:

    $ while read -d ' ' pkg; do apt-cache policy --no-all-versions "${pkg%%{*}"; done <\
    <(yes | aptitude install $some_pkg --simulate | sed -ne '/^ /p')

    non-starter:
    ===8<----------------------------------------
    E: Command line option --no-all-versions is not understood in combination with the other options
    E: Command line option --no-all-versions is not understood in combination with the other options
    E: Command line option --no-all-versions is not understood in combination with the other options
    E: Command line option --no-all-versions is not understood in combination with the other options

    ===8<----------------------------------------

    There is a bug here no matter what, because the man page does not
    disclose the narrow scope by which --no-all-versions applies. It took
    trial and error with several apt-cache commands before it became
    evident that it only works on the “apt-cache show” command. The show command does not give the information needed. That is, it does not
    indicate the location where the candidate version will be sourced
    from.

    My workaround hackery is this:

    $ while read -d ' ' pkg; do apt-cache policy -o APT::Cache::AllNames=false "${pkg%%{*}"; done <\
    <(yes | aptitude install $some_pkg --simulate | sed -ne '/^ /p') |
    sed -ne '/^[a-z]/Ip;/Version.table/{N;N;p}'

    Note that “-o APT::Cache::AllNames=false” is used in vain (it has no
    effect but at least it does not interfere either). The work of
    suppressing the non-candidate noise is done by the last sed command.

    It would be nice if I could also get a total size on any files to be
    fetched. My knee-jerk thought would be to filter on all packages that
    are not sourced from file:/local/filesystem, run apt-cache on that
    subset to get full URLs, then do something like:

    apt-cache show "$pkg" | awk '/^Size/{print $2}'

    Anyway, the low-effort fix would be to at least update the man page to
    state the narrow availability of --no-all-versions. Though it would be
    useful if it worked for policy.

    In light of my use case, you could also say it’s already hacking
    territory that apt-cache was needed at all. In principle, aptitude’s installer output of how much data will be fetched should give a
    breakdown of data volume to be fetched from each source location,
    perhaps when run in a verbose mode.

    -- System Information:
    Debian Release: 12.5
    APT prefers stable-updates
    APT policy: (990, 'stable-updates'), (990, 'stable-security'), (990, 'stable'), (500, 'oldstable')
    Architecture: amd64 (x86_64)
    Foreign Architectures: i386

    Kernel: Linux 5.10.0-28-amd64 (SMP w/2 CPU threads)
    Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
    Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
    Shell: /bin/sh linked to /usr/bin/dash
    Init: systemd (via /run/systemd/system)
    LSM: AppArmor: enabled

    Versions of packages apt depends on:
    ii adduser 3.134
    ii debian-archive-keyring 2023.3+deb12u1
    ii gpgv 2.2.40-1.1
    ii libapt-pkg6.0 2.6.1
    ii libc6 2.36-9+deb12u6
    ii libgcc-s1 12.2.0-14
    ii libgnutls30 3.7.9-2+deb12u2
    ii libseccomp2 2.5.4-1+b3
    ii libstdc++6 12.2.0-14
    ii libsystemd0 252.22-1~deb12u1

    Versions of packages apt recommends:
    ii ca-certificates 20230311

    Versions of packages apt suggests:
    pn apt-doc <none>
    ii aptitude 0.8.13-5
    ii dpkg-dev 1.21.22
    ii gnupg 2.2.40-1.1
    ii powermgmt-base 1.37

    -- no debconf information

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Kalnischkies@21:1/5 to Manny on Fri May 3 14:00:01 2024
    On Thu, May 02, 2024 at 12:40:30PM +0200, Manny wrote:
    Note that “-o APT::Cache::AllNames=false” is used in vain (it has no effect but at least it does not interfere either). The work of

    I think you meant All*Versions*, not Names. The later is documented to
    effect `pkgnames` only. In some way, AllVersions is documented to effect `show`, but much less specific by "full records" – a record is what show displays and policy doesn't, but yeah, not really discoverable.


    It would be nice if I could also get a total size on any files to be
    fetched. My knee-jerk thought would be to filter on all packages that
    are not sourced from file:/local/filesystem, run apt-cache on that
    subset to get full URLs, then do something like:

    apt-cache show "$pkg" | awk '/^Size/{print $2}'

    Anyway, the low-effort fix would be to at least update the man page to
    state the narrow availability of --no-all-versions. Though it would be
    useful if it worked for policy.

    In light of my use case, you could also say it’s already hacking
    territory that apt-cache was needed at all. In principle, aptitude’s installer output of how much data will be fetched should give a
    breakdown of data volume to be fetched from each source location,
    perhaps when run in a verbose mode.

    fwiw: I don't know about aptitude and if you think it should get some
    feature I suppose you should report it there, but for apt(-get) I have
    to note that both display "download size" as the size of all *.deb
    files to be downloaded from non-local (that mostly means non-file:/)
    sources…

    They do this mostly to check if the free disk space is large enough to
    hold the debs to download (while file:/ are used from there they are),
    but that is close at least to your knee-jerk thought.

    Not sure about the later "each source location"… that can turn out to be
    a lot of details for not that much gain: a typical Debian stable has
    'normal', 'updates' and 'security'. You could add 'proposed' and e.g. 'backports' and a random set of 3rd parties like the typical Ubuntu user
    with seemingly 42+ PPAs added. That is 3+X counters useless even to you
    as you were just interested in the data coming from your local mirror
    vs. others. And that would assume that all mirrors are complete and
    available, no retries, no fallbacks, no redirects.


    Best regards

    David Kalnischkies

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEE5sn+Q4uCja/tn0GrMRvlz3HQeIMFAmY00MMACgkQMRvlz3HQ eINgJxAAgfpslE3pQV7PQG7id2z2BNehyrNhaKv9gl5sHoXB8eOLgvsRTRPfq78U /vylabfLBVFqxbzQl+lu+f9ZrS5VBvSsE4WsdkeABNyjDojMQMufX7sqC4yrbwAa jmrjZb4PtVma11Cs2JBQJZRnpFUaX40F2NgAS3O3rsCKuOuPYVlx5DAwr2hdd6Mk I14SxjgEs8S7W9Uz54ZwEfRWZJ6waZQhgKEZrSbCxWvJcDdZW2LJ+sGLOh8i8TZ4 +qvcdWIs4sxB5h8wo1GR9pQpdYwOjQyR+5iZBGKEPtATzBZvqcgU6AZD1g1K9wvi mtnoLGlNUmlLocuK4EVuAUtMyDi92W5Mq2XYTbIYX9K4aVWBSkgwvDpduP5stYJf UDVWqJNFVDIkTC0LGy3BOHHgkCwzRQpsAagziEbZrrXTNOOOnrn0xywY7YG1YIEk ZaCfM4hEiVEOHUqkurKyxO+e14QiWJa+Iw2M/2dDanL+kCKgNr3lWX5XQLBPEuF+ Nafj+yNwEmdwe7PXJINNzU0LJDsWso4jVKS1NTZRbUoIML+7D+7s0r6v8K18iRa8 hy8lZaKE0FvsRFdUahLW/iS+b7KZGDNuSnirf/9QAaXp7eSeLTcBywYkb2wy0tDp I1beAekDD0WUN1vbzbxNaMRlb2Jso1AdfsgU1uAs65lKvOFz0Vc=
    =AH8Z
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Manny@21:1/5 to All on Fri May 3 19:10:03 2024
    I think you meant All*Versions*, not Names.

    Oh, right.. must have been a copy-paste error.

    fwiw: I don't know about aptitude and if you think it should get some
    feature I suppose you should report it there, but for apt(-get) I have
    to note that both display "download size" as the size of all *.deb
    files to be downloaded from non-local (that mostly means non-file:/) sources…

    Thanks! That’s useful indeed.

    Not sure about the later "each source location"… that can turn out to be
    a lot of details for not that much gain: a typical Debian stable has 'normal', 'updates' and 'security'. You could add 'proposed' and e.g. 'backports' and a random set of 3rd parties like the typical Ubuntu user
    with seemingly 42+ PPAs added. That is 3+X counters useless even to you
    as you were just interested in the data coming from your local mirror
    vs. others. And that would assume that all mirrors are complete and available, no retries, no fallbacks, no redirects.

    Indeed the cloud vs. local counts are the most useful. I was thinking
    in terms of luxury. Many different sources being fetched in parallel
    would give the expectation of a fast fetch. And if some are fetched
    over tor or a slow host, it would also give an indication of time. And
    if something comes from a Tor source and your in a place that blocks
    Tor, that’s marginally useful information. But indeed the effort
    would not be justfied with apt and apt-get already giving what’s
    needed.

    From there, I suppose my use-case does not justify making
    --no-all-versions function. But the man page should at least reflect
    reality.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)