How to use the pyalpm.find_satisfier function in pyalpm

To help you get started, we’ve selected a few pyalpm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github archlinux / pyalpm / test / test_alpm.py View on Github external
def test_find_satisfier_error():
    with pytest.raises(TypeError) as excinfo:
        pyalpm.find_satisfier()
    assert 'takes a Package list and a string' in str(excinfo.value)

    with pytest.raises(TypeError) as excinfo:
        pyalpm.find_satisfier(["foo"], PKG)
    assert 'list must contain only Package objects' in str(excinfo.value)
github Kwpolska / pkgbuilder / pkgbuilder.py View on Github external
parseddeps = {}
            H = pycman.config.init_with_config('/etc/pacman.conf')
            localpkgs = H.get_localdb().pkgcache
            syncpkgs = []
            for j in [i.pkgcache for i in H.get_syncdbs()]:
                syncpkgs.append(j)
            syncpkgs = functools.reduce(lambda x, y: x + y, syncpkgs)
            for dep in depends:
                if re.search('[<=>]', dep):
                    vpat = '>=<|><=|=><|=<>|<>=|<=>|>=|=>|><|<>|=<|\
<=|>|=|<'
                    ver_base = re.split(vpat, dep)
                    dep = ver_base[0]
                if pyalpm.find_satisfier(localpkgs, dep):
                    parseddeps[dep] = 0
                elif pyalpm.find_satisfier(syncpkgs, dep):
                    parseddeps[dep] = 1
                elif self.utils.info(dep) != None:
                    parseddeps[dep] = 2
                else:
                    parseddeps[dep] = -1
                    raise PBError(_('[ERR3201] depcheck: cannot find {0} \
anywhere').format(dep))
            return parseddeps
github Antergos / Cnchi / src / download / metalink.py View on Github external
def resolve_deps(alpm_handle, other, alldeps):
    """ Resolve dependencies """
    missing_deps = []
    queue = deque(other)
    local_cache = alpm_handle.get_localdb().pkgcache
    syncdbs = alpm_handle.get_syncdbs()
    seen = set(queue)
    while queue:
        pkg = queue.popleft()
        for dep in pkg.depends:
            if pyalpm.find_satisfier(local_cache, dep) is None or alldeps:
                for database in syncdbs:
                    prov = pyalpm.find_satisfier(database.pkgcache, dep)
                    if prov:
                        other.add(prov)
                        if prov.name not in seen:
                            seen.add(prov.name)
                            queue.append(prov)
                        break
                else:
                    missing_deps.append(dep)
    return other, missing_deps
github Antergos / Cnchi / src / download / metalink.py View on Github external
def resolve_deps(alpm_handle, other, alldeps):
    """ Resolve dependencies """
    missing_deps = []
    queue = deque(other)
    local_cache = alpm_handle.get_localdb().pkgcache
    syncdbs = alpm_handle.get_syncdbs()
    seen = set(queue)
    while queue:
        pkg = queue.popleft()
        for dep in pkg.depends:
            if pyalpm.find_satisfier(local_cache, dep) is None or alldeps:
                for database in syncdbs:
                    prov = pyalpm.find_satisfier(database.pkgcache, dep)
                    if prov:
                        other.add(prov)
                        if prov.name not in seen:
                            seen.add(prov.name)
                            queue.append(prov)
                        break
                else:
                    missing_deps.append(dep)
    return other, missing_deps
github archlinuxcn / repo / check.py View on Github external
def _dep_satisfied_in_syncdb(self, dep, packages: List[pyalpm.Package]):
        pkgobj = pyalpm.find_satisfier(packages, dep)
        if pkgobj is None:
            return False
        return True
github Antergos / Cnchi / cnchi.tmp / cnchi / download / metalink.py View on Github external
other_grp |= PkgSet(syncgrp[1])
        else:
            other |= other_grp

    # foreign_names = requested - set(x.name for x in other)

    # Resolve dependencies.
    if other and not pargs.nodeps:
        queue = deque(other)
        local_cache = handle.get_localdb().pkgcache
        syncdbs = handle.get_syncdbs()
        seen = set(queue)
        while queue:
            pkg = queue.popleft()
            for dep in pkg.depends:
                if pyalpm.find_satisfier(local_cache, dep) is None or pargs.alldeps:
                    for db in syncdbs:
                        prov = pyalpm.find_satisfier(db.pkgcache, dep)
                        if prov is not None:
                            other.add(prov)
                            if prov.name not in seen:
                                seen.add(prov.name)
                                queue.append(prov)
                            break
                    else:
                        missing_deps.append(dep)

    found |= set(other.pkgs)
    not_found = requested - found
    if pargs.needed:
        other = PkgSet(list(check_cache(conf, other)))
github Kwpolska / pkgbuilder / pkgbuilder / build.py View on Github external
"""A build function, which actually links to others.

    DO NOT use it unless you re-implement auto_build!

    """
    pkg = None
    try:
        pkg = pkgbuilder.utils.info([pkgname])[0]
    except IndexError:
        DS.log.info('{0} not found in the AUR, checking in repositories'.format(
            pkgname))
        syncpkgs = []
        for j in [i.pkgcache for i in DS.pyc.get_syncdbs()]:
            syncpkgs.append(j)
        syncpkgs = functools.reduce(lambda x, y: x + y, syncpkgs)
        abspkg = pyalpm.find_satisfier(syncpkgs, pkgname)
        if abspkg:  # abspkg can be None or a pyalpm.Package object.
            pkg = pkgbuilder.package.ABSPackage.from_pyalpm(abspkg)
            subpackages = [pkg.name]  # no way to get it
    if not pkg:
        raise pkgbuilder.exceptions.PackageNotFoundError(pkgname, 'build')

    DS.fancy_msg(_('Building {0}...').format(pkg.name))
    pkgbuilder.utils.print_package_search(pkg,
                                          prefix=DS.colors['blue'] +
                                          '  ->' + DS.colors['all_off'] +
                                          DS.colors['bold'] + ' ',
                                          prefixp='  -> ')
    sys.stdout.write(DS.colors['all_off'])
    if pkg.is_abs:
        DS.fancy_msg(_('Retrieving from ASP...'))
        rc = asp_export(pkg)
github Kwpolska / pkgbuilder / pkgbuilder / build.py View on Github external
else:
            print(':: ' + _('Fetching package information...'))
            for pkgname in pkgnames:
                pkg = None
                try:
                    pkg = pkgbuilder.utils.info([pkgname])[0]
                except IndexError:
                    try:
                        DS.log.info('{0} not found in the AUR, checking in '
                                    'repositories'.format(pkgname))
                        syncpkgs = []
                        for j in [i.pkgcache for i in DS.pyc.get_syncdbs()]:
                            syncpkgs.append(j)
                        syncpkgs = functools.reduce(lambda x, y: x + y,
                                                    syncpkgs)
                        abspkg = pyalpm.find_satisfier(syncpkgs, pkgname)
                        pkg = pkgbuilder.package.ABSPackage.from_pyalpm(abspkg)

                    except AttributeError:
                        pass
                allpkgs.append(pkg)
                if not pkg:
                    raise pkgbuilder.exceptions.PackageNotFoundError(
                        pkgname, 'fetch')

        for pkg in allpkgs:
            if pkg.is_abs:
                abspkgs.append(pkg)
            else:
                aurpkgs.append(pkg)

        if abspkgs: