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

Re: show searched packages including versions



On Wed, Jan 03, 2018 at 03:28:45PM -0500, Felix Miata wrote:
I've had no luck finding a way to search in Debian that lists versions along
with names. In openSUSE, this is somewhat simple to discover, as zypper includes
everything in one man page rather than having various names to learn along with
separate (or not) man pages, such as apt-cache, apt-get, apt-mark, apt-file,
apt-key, aptitude and dpkg. Generally my searches are seeking whether newer
version is yet available. ATM, the goal is finding whether mc-4.8.17 or older
can readily be replaced by the current version, mc-4.8.20. Output I would like
in a form similar to what follows (from openSUSE):

# zypper se -sx firefox-esr

S  | Name        | Type       | Version      | Arch   | Repository
---+-------------+------------+--------------+--------+--------------
vl | firefox-esr | package    | 52.5.3-1.1   | i586   | Mozilla131
vl | firefox-esr | package    | 45.8.0-1.3   | i586   | MozillaLegacy
vl | firefox-esr | package    | 38.8.0-1.22  | i586   | MozillaLegacy
vl | firefox-esr | package    | 31.8.0-1.30  | i586   | MozillaLegacy
vl | firefox-esr | package    | 17.0.11-1.49 | i586   | MozillaLegacy
vl | firefox-esr | package    | 52.5.3-1.1   | i586   | Mozilla

Even better would show packages sorted first by version and skipping arch.

Can any similar output be provided in Debian? If yes, is there a config option
to make it default?

Try "apt-cache madison firefox-esr". It's also pretty simple to write a python script to tweak the exact output and parameters, something like:

import apt_pkg
import sys
import re

apt_pkg.init()
cache = apt_pkg.Cache()
for pkg in sorted(cache.packages):
   if re.search(sys.argv[1], pkg.name):
       for version in sorted(pkg.version_list):
           print("%s\t%s\t%s" % (pkg.name, pkg.architecture, version.ver_str))

Which would show something like:

/scratch/pyaptvers.py 'firefox-esr$'
Reading package lists... Done
Building dependency tree Reading state information... Done
firefox-esr     amd64   52.5.0esr-1~deb9u1
firefox-esr     amd64   52.5.2esr-1~deb9u1

Mike Stone


Reply to: