0

Related: How do I check package version using apt-get / aptitude?

How do I do this for a given variable debian release, from the command line? Using either apt, dpkg, or aptitude is fine. Ideally, relying on the packages.debian.org website is not ok as the requested release may be out of date. (The ftp archive does contain the older releases).

E.g.:

release="bullseye"
package="wget"
version=$(some_magic_apt_command $release)
echo $version

1.21-1+deb11u1

release="stretch" package="wget" version=$(some_magic_apt_command $release) echo $version

1.18-5+deb9u3

I also need to know which 'repository' it's from. Main, contrib, or nonfree?

release="stretch"
package="wget"
type=$(some_magic_apt_command $release)
echo $type

main

Requirements:

  • It has to work for any release: not just the current installed version.

Purpose:

Extracting old packages to find original configuration files that have changed, not remembering what was changed, to figure out how to update these config files for a newer version (the question: what did the programmers change about the config files, it's undocumented).

aphid
  • 179
  • 8
  • If you don't have an installation, but also can't rely on central debian package archives, where would the information magically come from? – Marcus Müller Mar 10 '23 at 12:21
  • You can use the central archive. Just don't use/scrape the http/html website. The website will only keep the last 2-3 stable versions. The repositories go back much further. – aphid Mar 10 '23 at 12:50

1 Answers1

0

so, then the answer seems to be: simply have a podman container for each release, and ask dpkg inside each of them;

One-time setup on your host (Deb 11) machine:

sudo apt install -y podman
sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 YOURUSERNAMEHERE

from thereon to check PKG on DEBIAN_RELEASE:

DEBIAN_RELEASE=8
PKG=gnuradio
podman run \
       -it \
       --rm \
       "debian:${DEBIAN_RELEASE}" \
       sh -c "apt-get update; apt-cache show \"${PKG}\"" \
| grep 'Version:'

For debians prior to – I think – 7 you might need to adjust the URLS in /etc/apt/sources.list first, but you could either just do that in the command passed via sh -c, or first build an image where that's already done and replace debian:releasenumber with that.