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

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



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


Reply to: