Exemple #1
0
def get_recursive_deps(name, result):
	i = pacman.db_getpkgcache(db_local)
	while i:
		pkg = pacman.void_to_PM_PKG(pacman.list_getdata(i))
		pkgname = pacman.void_to_char(pacman.pkg_getinfo(pkg, pacman.PKG_NAME))
		if pkgname == name:
			j = pacman.void_to_PM_LIST(pacman.pkg_getinfo(pkg, pacman.PKG_DEPENDS))
			while j:
				depname = pacman.void_to_char(pacman.list_getdata(j)).split("<")[0].split(">")[0].split("=")[0]
				if depname not in result:
					result.append(depname)
					get_recursive_deps(depname, result)
				j = pacman.list_next(j)
		i = pacman.list_next(i)
def find_pkg(packagename):
	if pacman.initialize("/") == -1:
		fprint("initialize() failed")
		return False
	local = pacman.db_register("local")
	i = pacman.db_getpkgcache(local)
	found = False
	while i:
		pkg = pacman.void_to_PM_PKG(pacman.list_getdata(i))
		pkgname = pacman.void_to_char(pacman.pkg_getinfo(pkg, pacman.PKG_NAME))
		if pkgname == packagename:
		        found = True
		i = pacman.list_next(i)
	pacman.release()
	return found
Exemple #3
0
basecats = ['base']

root = tempfile.mkdtemp()
pacman.initialize(root)
if os.getcwd().split('/')[-2] == "frugalware-current":
	treename = "frugalware-current"
else:
	treename = "frugalware"
db = pacman.db_register(treename)
pacman.db_setserver(db, "file://" + os.getcwd() + "/../frugalware-%s" % sys.argv[1])
pacman.db_update(1, db)

i = pacman.db_getpkgcache(db)
while i:
	pkg = pacman.void_to_PM_PKG(pacman.list_getdata(i))
	pkgname = pacman.void_to_char(pacman.pkg_getinfo(pkg, pacman.PKG_NAME))
	group = pacman.void_to_char(pacman.list_getdata(pacman.void_to_PM_LIST(pacman.pkg_getinfo(pkg, pacman.PKG_GROUPS))))
	if group not in basecats:
		i = pacman.list_next(i)
		continue
	j = pacman.void_to_PM_LIST(pacman.pkg_getinfo(pkg, pacman.PKG_DEPENDS))
	while j:
		found = False
		dep = pacman.void_to_char(pacman.list_getdata(j)).split("<")[0].split(">")[0].split("=")[0]
		k = pacman.db_getpkgcache(db)
		while not found and k:
			p = pacman.void_to_PM_PKG(pacman.list_getdata(k))
			if pacman.void_to_char(pacman.pkg_getinfo(p, pacman.PKG_NAME)) == dep:
				l = pacman.void_to_PM_LIST(pacman.pkg_getinfo(p, pacman.PKG_GROUPS))
				g = pacman.void_to_char(pacman.list_getdata(l))
import simplejson
import datetime

packages_as_dict = {}
root = "/"
packages_path = root + "var/cache/pacman-g2/pkg/"

if pacman.initialize(root) == -1:
    print "initializing DB failed"
    exit

db = pacman.db_register("frugalware-current")

i = pacman.db_getpkgcache(db)
while i :
    pkg = pacman.void_to_PM_PKG(pacman.list_getdata(i))
    name = pacman.void_to_char(pacman.pkg_getinfo(pkg, pacman.PKG_NAME))
    version = pacman.void_to_char(pacman.pkg_getinfo(pkg, pacman.PKG_VERSION))
    arch = pacman.void_to_char(pacman.pkg_getinfo(pkg, pacman.PKG_ARCH))
    files = None
    url = None
    builddate = None
    licenses = None

    groups = []
    j = pacman.void_to_PM_LIST(pacman.pkg_getinfo(pkg, pacman.PKG_GROUPS))
    while j:
        group = pacman.void_to_char(pacman.list_getdata(j))
        groups.append(group)
        j = pacman.list_next(j)
Exemple #5
0
    treename = "frugalware"
local = pacman.db_register("local")
db = pacman.db_register(treename)
if not db:
    print "db_register() failed"
if pacman.db_setserver(
        db, "file://" + os.getcwd() + "/../frugalware-%s" % sys.argv[1]) == -1:
    print "db_setserver() failed"
if pacman.db_update(1, db) == -1:
    print "db_update() failed"
if pacman.trans_init(pacman.TRANS_TYPE_SYNC, pacman.TRANS_FLAG_NOCONFLICTS,
                     None, None, None) == -1:
    print "trans_init() failed"
i = pacman.db_getpkgcache(db)
while i:
    pkg = pacman.void_to_PM_PKG(pacman.list_getdata(i))
    pkgname = pacman.void_to_char(pacman.pkg_getinfo(pkg, pacman.PKG_NAME))
    if pacman.trans_addtarget(pkgname):
        print "failed to add target '%s' (%s)" % (
            pkgname, pacman.strerror(pacman.cvar.pm_errno))
        break
    i = pacman.list_next(i)
junk = pacman.LISTp_new()
if pacman.trans_prepare(junk) == -1:
    print "%s:" % pacman.strerror(pacman.cvar.pm_errno)
    i = pacman.list_first(pacman.LISTp_to_LIST(junk))
    while i:
        miss = pacman.void_to_PM_DEPMISS(pacman.list_getdata(i))
        if pacman.void_to_long(pacman.dep_getinfo(
                miss, pacman.DEP_TYPE)) == pacman.DEP_TYPE_DEPEND:
            reason = "requires"