コード例 #1
0
ファイル: scan_portage.py プロジェクト: iksaif/euscan
    def scan_gentoopm(self, query, category=None):
        import gentoopm

        pm = gentoopm.get_package_manager()

        if category:
            packages = pm.stack.filter(key_category=category)
        elif query:
            packages = pm.stack.filter(query)
        else:
            packages = pm.stack

        package = {}
        package_name = None

        for p in packages:
            pkg = p.key.package

            if pkg != package_name:
                if package_name:
                    yield package
                package_name = pkg
                package['package'] = p.key.package
                package['category'] = p.key.category
                package['homepage'] = ' '.join(p.homepages)
                package['description'] = p.description
                package['versions'] = []
            package['versions'].append(
                (p._cpv, p.slot, p.repository or 'gentoo')
            )

        if package_name:
            yield package
コード例 #2
0
ファイル: sets.py プロジェクト: mgorny/smart-live-rebuild
    def load(self):
        # Clasically, apply twice. First time to get configfile path
        # and profile; second time to override them.

        pm = get_package_manager()
        c = Config(pm.config)
        c.apply_dict(self._options)
        c.parse_configfiles()
        c.apply_dict(self._options)

        # We're caching the resulting package in an environment
        # variable, using the pid as a safety measure to avoid random
        # data catching. This allows us to avoid updating all
        # the packages once again after emerge reloads itself.

        cachevar = "PORTAGE_SLR_PACKAGE_LIST"
        pid = str(os.getpid())

        packages = os.environ.get(cachevar, "").split()
        if not packages or packages.pop(0) != pid:
            packages = None

        try:
            if packages is None:
                packages = SmartLiveRebuild(c.get_options(), pm)
        except SLRFailure:
            pass
        else:
            self._setAtoms(packages)
            os.environ[cachevar] = " ".join([pid] + packages)
コード例 #3
0
def main():
    pm = gentoopm.get_package_manager()
    maints = {}

    for p in pm.repositories['gentoo']:
        # include only explicitly proxied by g-p-m
        for m in p.maintainers:
            if m.email == '*****@*****.**':
                break
        else:
            for m in p.maintainers:
                if m.email.endswith('@gentoo.org'):
                    break
            else:
                if p.maintainers:
                    print('Proxied maintainer without a proxy?! pkg %s, %s' %
                          (p, p.maintainers),
                          file=sys.stderr)
            continue

        for m in p.maintainers:
            # skip gentoo devs & projects
            if m.email.endswith('@gentoo.org'):
                continue
            maints[m.email.lower()] = m.name

    pickle.dump(maints, sys.stdout.buffer)
コード例 #4
0
    def scan_gentoopm(self, query, category=None):
        import gentoopm

        pm = gentoopm.get_package_manager()

        if category:
            packages = pm.stack.filter(key_category=category)
        elif query:
            packages = pm.stack.filter(query)
        else:
            packages = pm.stack

        package = {}
        package_name = None

        for p in packages:
            pkg = p.key.package

            if pkg != package_name:
                if package_name:
                    yield package
                package_name = pkg
                package['package'] = p.key.package
                package['category'] = p.key.category
                package['homepage'] = ' '.join(p.homepages)
                package['description'] = p.description
                package['versions'] = []
            package['versions'].append((p._cpv, p.slot, p.repository
                                        or 'gentoo'))

        if package_name:
            yield package
コード例 #5
0
ファイル: main.py プロジェクト: ercpe/portman
def build_tree(cpv, src_tree, dst_tree):
	pm = gentoopm.get_package_manager()
	
	src = pm.repositories[src_tree]
	dst = pm.repositories[dst_tree]
	
	for src_cpv in src.filter(cpv):
		yield (src_cpv, test_deps(src, dst, src_cpv))
コード例 #6
0
def build_tree(cpv, src_tree, dst_tree):
    pm = gentoopm.get_package_manager()

    src = pm.repositories[src_tree]
    dst = pm.repositories[dst_tree]

    for src_cpv in src.filter(cpv):
        yield (src_cpv, test_deps(src, dst, src_cpv))
コード例 #7
0
def qfiletopackage(dep,addpaths):
    """Converts supplied deps with additional include paths to portage packages

    This uses qfile to quess which package certain files belongs to.
    """

    print(dep)
    (statuscode,outstr) = getstatusoutput('echo "" | `gcc -print-prog-name=cc1` -v -q')
    #"`gcc -print-prog-name=cc1plus` -v" for cpp
    outlst = outstr.split("\n")
    incpaths = []
    for item in outlst:
        if item[:2] == " /":
            incpaths += [item[1:]]
    incpaths += addpaths
    depname = os.path.split(dep)[1]

    (statuscode,packagestr) = getstatusoutput("qfile -C " + depname)
    if not statuscode == 0:
        package = pfltopackage(dep,incpaths)

    else:
        packagelst = packagestr.split()
        package = []
        n = 0
        for depfile in packagelst[1::2]:
            for incpath in incpaths:
                if depfile.strip("()") == (incpath + "/" + dep):
                    package.append(packagelst[n])
            n += 2

        if len(package) > 1:
            print("more than one matching package were found!")

        if not package:
            package = pfltopackage(dep,incpaths)

    print(package)
    #check if package exists
    pm=gentoopm.get_package_manager()
    if package:
        #does the package exist in this computers package manager?
        if pm.stack.filter(package[0]):
            return package[0]
        else:
            print("No package named: " + package[0] + " found localy, ignoring")
            return []
    else:
        return package
コード例 #8
0
def main():
    pm = gentoopm.get_package_manager()
    maints = {}

    for p in pm.repositories['gentoo']:
        # include only explicitly proxied by g-p-m
        for m in p.maintainers:
            if m.email == '*****@*****.**':
                break
        else:
            for m in p.maintainers:
                if not m.email.endswith('@gentoo.org'):
                    extra_maints[m.email].append(p)
            for m in p.maintainers:
                if m.email.endswith('@gentoo.org'):
                    break
            else:
                if p.maintainers:
                    print('Proxied maintainer without a proxy?! pkg %s, %s'
                          % (p, p.maintainers),
                          file=sys.stderr)
            continue

        for m in p.maintainers:
            # skip gentoo devs & projects
            if m.email.endswith('@gentoo.org'):
                continue
            maints[m.email.lower()] = m.name

    pickle.dump(maints, sys.stdout.buffer)
    for maint, data in sorted(extra_maints.items()):
        other_maints = defaultdict(set)
        for p in data:
            other_maints[tuple(sorted(x.email for x in p.maintainers if x.email.endswith('@gentoo.org')))].add(p.key)

        print('%s' % maint)
        for om, pkgs in sorted(other_maints.items()):
            print('\t%s' % (' '.join(om) or '(none)'))
            for p in sorted(pkgs):
                print('\t\t%s' % p)
        print()
コード例 #9
0
#!/usr/bin/env python

import codecs, re, sys

from gentoopm import get_package_manager
import gentoopm.matchers as pm_matchers
import gentoopm.exceptions

pm = get_package_manager()
repo = pm.repositories['gentoo']
#repo = pm.stack

dep_matching_re = re.compile(r'[^\s"\']+\[\S*(?:\${MULTILIB_USEDEP}|abi_)',
                             re.UNICODE | re.MULTILINE)

# usually packages that have newer versions masked and not expecting
# to get the EAPI<5 versions unmasked anytime ;).
exceptions = {
    'dev-libs/glib': '2.34.3',  # seems to be the first EAPI=5 version
    'dev-libs/glib:2': '2.34.3',  # seems to be the first EAPI=5 version
    'dev-lang/lua': '5.1.5-r3',
    'dev-libs/openssl': '1.0.1h-r2',
    'dev-libs/openssl:0': '1.0.1h-r2',
    'sys-libs/db': '4.8.30-r1',
}


def replace_dep(m):
    dep = m.group(0)
    print('** Regexp match: %s' % dep)
コード例 #10
0
ファイル: cli.py プロジェクト: pkulev/smart-live-rebuild
def main(argv):
    pm = get_package_manager()
    pm_conf = pm.config

    # initialize config with defaults
    c = CLIConfig(pm_conf)

    # parse opts to get the config file
    (opts, args) = parse_options(argv)
    c.apply_optparse(opts)

    # do the config file parsing
    c.parse_configfiles()

    # and now reapply the options to override config file defaults
    c.apply_optparse(opts)
    opts = c.get_options()

    if not opts.pretend:
        try:
            import psutil

            def getproc(pid):
                for ps in psutil.get_process_list():
                    if pid == ps.pid:
                        return ps
                raise Exception()

            def getscriptname(ps):
                if os.path.basename(ps.cmdline[0]) != ps.name:
                    return ps.cmdline[0]
                cmdline = ps.cmdline[1:]
                while cmdline[0].startswith('-'):  # omit options
                    cmdline.pop(0)
                return os.path.basename(cmdline[0])

            ps = getproc(os.getppid())
            # traverse upstream to find the emerge process
            while ps.pid > 1:
                if getscriptname(ps) == 'emerge':
                    out.s1(
                        'Running under the emerge process, assuming --pretend.'
                    )
                    opts.pretend = True
                    break
                ps = ps.parent
        except Exception:
            pass

    if os.geteuid() != 0 and opts.unprivileged_user:
        if not opts.pretend:
            out.s1('Running as an unprivileged user, assuming --pretend.')
            opts.pretend = True
        if opts.quickpkg:
            out.err(
                "Running as an unprivileged user, --quickpkg probably won't work"
            )

    try:
        packages = SmartLiveRebuild(opts, pm, cliargs=args)
    except SLRFailure:
        return 1

    if not packages and not any(filter(lambda a: not a.startswith('-'), args)):
        return 0

    if opts.pretend:
        for p in packages:
            print(p)
        return 0
    else:
        cmd = [
            'emerge', '--oneshot', '--getbinpkg=n', '--usepkg-exclude',
            ' '.join(packages)
        ]
        cmd.extend(args)
        cmd.extend(packages)
        out.s2(' '.join(cmd))
        os.execv('/usr/bin/emerge', cmd)
        return 126