gentoopm

From Gentoo Wiki
Jump to:navigation Jump to:search

gentoopm is a common interface to Gentoo package managers written in Python. It currently supports Portage and pkgcore.

The project provides a gentoopmq tool providing basic lookups into the package manager data. Most importantly, it provides an IPython-friendly gentoopmq shell command that can be used to play with the API.

Installation

USE flags

USE flags for app-portage/gentoopm A common interface to Gentoo package managers

test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)

Emerge

Install gentoopm:

root #emerge --ask app-portage/gentoopm

Example use

Check if www-client/firefox is installed

CODE
import gentoopm

pm = gentoopm.get_package_manager()
if "www-client/firefox" in pm.installed:
    print("Firefox is installed!")

Get names of all installed packages

CODE
inst = frozenset(str(pkg.key) for pkg in pm.installed)
print(*sorted(inst), sep="\n")

Compare two versions of a package

CODE
pkg1 = pm.Atom("=www-client/firefox-90")
pkg2 = pm.Atom("=www-client/firefox-100")
assert pkg1.version < pkg2.version