Example #1
0
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

    f = open('content/package/'+name+'.md', 'w')
    f.write("+++\n")
    f.write("draft = false\n")
    f.write('title = "'+name+'"\n')
    f.write('version = "'+version+'"\n')
    if builddate:
        date_object = datetime.datetime.strptime(builddate, '%c')
        f.write('date = "'+date_object.isoformat()+'"\n')

    f.write('categories = '+str(groups)+'\n')
    if url:
        f.write('upstreamurl = "'+url+'"\n')
    f.write('arch = "'+arch+'"\n')
    f.write('size = "'+str(size)+'"\n')
    f.write('usize = "'+str(usize)+'"\n')
    f.write('sha1sum = "'+sha1sum+'"\n')
#    f.write('depends = "'+depends+'"\n')
#    if licenses:
#    f.write('license = "'+licenses+'"\n')
#    if files:
#    f.write('files = "'+files+'"\n')
    f.write("+++\n")
    f.write(desc)
    f.close()

print simplejson.dumps(packages_as_dict, sort_keys=True, indent=4 * ' ')

pacman.release()
Example #3
0
    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"
        else:
            reason = "is required by"
        sys.stdout.write(
            ":: %s: %s %s" %
            (pacman.void_to_char(pacman.dep_getinfo(
                miss, pacman.DEP_TARGET)), reason,
             pacman.void_to_char(pacman.dep_getinfo(miss, pacman.DEP_NAME))))
        mod = pacman.void_to_long(pacman.dep_getinfo(miss, pacman.DEP_MOD))
        ver = pacman.void_to_char(pacman.dep_getinfo(miss, pacman.DEP_VERSION))
        if mod == pacman.DEP_MOD_EQ:
            sys.stdout.write("=%s\n" % ver)
        elif mod == pacman.DEP_MOD_GE:
            sys.stdout.write(">=%s\n" % ver)
        elif mod == pacman.DEP_MOD_LE:
            sys.stdout.write("<=%s\n" % ver)
        else:
            print
        i = pacman.list_next(i)
pacman.release()
shutil.rmtree(root)
Example #4
0
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

import pacman
import sys

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)

pacman.initialize("/") == 0
db_local = pacman.db_register("local")
result = []
get_recursive_deps(sys.argv[1], result)
print "\n".join(result)
pacman.release() == 0

# vim:set shiftwidth=4 softtabstop=4 expandtab: