0

This question is just an opposite of How do you see what packages are available for update question.

I want to check the answers in this question, is that the given answers really downgrade an installed package.It's so hard to run apt-cache policy package command on each and every installed package and to manually check for the available low versions in the repository.

So, is there any command to list all the installed packages which has a lower version available in the repositories(Packages which can be downgraded)?

Avinash Raj
  • 80,446

2 Answers2

1

You can check if a specific package has an possible candidate for downgrade using:

apt-cache showpkg package_name | sed "0,/Reverse Provides:/d"

Now, according with this Q&A you can use:

dpkg --get-selections | grep -v deinstall

to list all your installed packages which are "available for downgrade" af follow:

for i in $(dpkg --get-selections | grep -v deinstall | cut -f1); do apt-cache showpkg $i | sed "0,/Reverse Provides:/d"; done
Radu Rădeanu
  • 174,089
  • 51
  • 332
  • 407
-1

Not sure about a command, but here is a bit of python:

from __future__ import print_function

import apt

def downgrade_versions(package):
  if package.versions is None or not package.is_installed:
    return []
  result = []
  for version in package.versions:
    if version < package.installed:
      result.append(version.version)
  return result

with apt.Cache() as cache:
  for package in cache:
    versions = downgrade_versions(package)
    if len(versions) > 0:
      print(package.fullname, package.installed.version, versions)

Prints the package name, the installed version, and a list of available versions less than the installed version.

For an individual package you can use apt-cache policy package. It shows the installed version and the available versions.

Jason Conti
  • 2,371