metis
metis

Reputation: 1044

Finding the attributes of a package in Ubuntu

i want to find and print all attributes of a package using python. I'm using ubuntu and developing in python. I can search and find all packages. FOr example one these packages is "eclipse-cdt". I want to develop a code giving the attributes of this package, such as, isInstalled, isUpdateable, versionNumber, dependentPackages etc. How can i do this?

Thanks in advance

Upvotes: 1

Views: 205

Answers (1)

wfr
wfr

Reputation: 701

apt-cache yields a lot of information about a package, e.g.:

apt-cache show bash

Package: bash
Version: 4.3-12
Essential: yes
Installed-Size: 5367
Maintainer: Matthias Klose <[email protected]>
Architecture: amd64
Replaces: bash-completion (<< 20060301-0), bash-doc (<= 2.05-1)
Depends: base-files (>= 2.1.12), debianutils (>= 2.15)
Pre-Depends: dash (>= 0.5.5.1-2.2), libc6 (>= 2.15), libncurses5 (>= 5.5-5~), libtinfo5
Recommends: bash-completion (>= 20060301-0)
Suggests: bash-doc
Conflicts: bash-completion (<< 20060301-0)
Description-en: GNU Bourne Again SHell
...

You can get a list of packages that will be upgraded with:

apt-get --just-print upgrade

However, don't reinvent the wheel. There's a quite complete Python library to access APT:

http://apt.alioth.debian.org/python-apt-doc/library/apt.cache.html

http://packages.ubuntu.com/trusty/python3-apt

Upvotes: 2

Related Questions