コード例 #1
0
ファイル: portageutils.py プロジェクト: andyspiros/numbench
def availablePackages(pattern):
    """Returns a list of packages matching the given pattern.

    The packages are returned as (category, package, version, revision) tuple.
    No test for keywords or mask is performed. The function just returns
    every matching pattern in the portage tree and installed overlays.
    """
    return [cps(l)
      for l in cmd.getoutput('equery -q list -po ' + pattern).split()]
コード例 #2
0
ファイル: portageutils.py プロジェクト: andyspiros/numbench
def normalize_cpv(cpv):
    if type(cpv) == type(''):
        try:
            cpv_ = cps(cpv)
            cpv_[-1]
            cpv = cpv_
        except:
            cpv = availablePackages(cpv)[-1]
    if cpv[-1] != 'r0':
        return '%s/%s-%s-%s' % cpv
    else:
        return '%s/%s-%s' % cpv[:-1]
コード例 #3
0
ファイル: portageutils.py プロジェクト: andyspiros/numbench
def getDependencies(package, env={}, split=False):
    pkg = normalize_cpv(package)
    cmd = ['emerge', '--ignore-default-opts', '=' + pkg, '-poq']
    proc = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE, env=env)
    output = proc.communicate()[0]
    if proc.returncode != 0:
        return []
    lines = output.strip().split('\n')
    if not lines[0]:
        return []
    if split:
        return [cps(shlex.split(l.strip())[-1]) for l in lines]
    else:
        return [shlex.split(l.strip())[-1] for l in lines]