예제 #1
0
def main():
    for_install = []
    my_input = raw_input('Package to install: ')

    if not my_input:
        raise SystemExit, 'You need to supply a package for installation'
    else:
        for_install.append(my_input)

    db = pkg.PkgDb(remotedb=True)

    if db.pkg_is_installed(my_input):
        raise SystemExit, 'Package is already installed'

    try:
        jobs = db.install(pattern=for_install)
    except pkg.PkgAccessError:
        raise SystemExit, 'You do not have privileges to install packages'

    if not len(jobs):
        raise SystemExit, 'No packages matching the pattern'

    print '\nAbout to install the following packages:'

    for p in jobs:
        print '\t%s' % p

    print

    my_input = raw_input('Proceed with installation [y/n]: ')

    if my_input and my_input[0].lower() == 'y':
        jobs.apply()

    db.close()
예제 #2
0
#!/usr/bin/env python

# File        : py-pkg-deps.py
# Author      : Marin Atanasov Nikolov <*****@*****.**>
# Description : Display package dependencies

import pkg

db = pkg.PkgDb()

pkgs = db.query()
pkgs.load_deps()

for pkg in pkgs:
    print pkg.origin()
    print '-' * len(pkg.origin())

    if not len(pkg.deps()):
        print '\t<Does not have dependencies>\n'
        continue

    for dep in pkg.deps():
        print '\t%s' % dep

    print

db.close()