Created
July 28, 2012 21:04
-
-
Save vitorbrandao/3194783 to your computer and use it in GitHub Desktop.
Portage API - Return all packages available in given Overlay [Gentoo Linux]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import portage | |
from gentoolkit.package import Package | |
def get_all_packages(overlay_path): | |
"""Returns all packages from a given overlay path. | |
""" | |
packages = {} | |
porttree = portage.db[portage.root]['porttree'] | |
vartree = portage.db[portage.root]['vartree'] | |
if overlay_path not in porttree.dbapi.porttrees: | |
print('Overlay "%s" is not set in PORTDIR_OVERLAY.\n' % overlay_path + | |
'Please add it in /etc/make.conf and try again.') | |
return False | |
for cp in porttree.dbapi.cp_all(trees=[overlay_path]): | |
for cpv in porttree.dbapi.cp_list(cp, mytree=[overlay_path]): | |
packages[cpv] = Package(cpv) | |
for cpv in vartree.dbapi.cp_list(cp): | |
# Insert only a new entry if not overriding an existing one. | |
packages.setdefault(cpv, Package(cpv)) | |
return packages | |
packages = get_all_packages('/var/lib/layman/noiselabs') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment