How to use the pkgbuilder.DS.pyc.get_localdb function in pkgbuilder

To help you get started, we’ve selected a few pkgbuilder 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 Kwpolska / pkgbuilder / pkgbuilder / build.py View on Github external
def depcheck(depends, pkgobj=None):
    """Perform a dependency check."""
    if depends == []:
        # THANK YOU, MAINTAINER, FOR HAVING NO DEPS AND DESTROYING ME!
        return {}
    else:
        parseddeps = {}
        localpkgs = DS.pyc.get_localdb().pkgcache
        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)
        for dep in depends:
            if dep == '':
                continue

            if re.search('[<=>]', dep):
                vpat = ('>=<|><=|=><|=<>|<>=|<=>|>=|=>|><|<>|=<|'
                        '<=|>|=|<')
                ver_base = re.split(vpat, dep)
                fdep = dep
                dep = ver_base[0]
                try:
                    ver = ver_base[1]
github Kwpolska / pkgbuilder / pkgbuilder / wrapper.py View on Github external
def show_version():
    """Show PBWrapper, PKGBUILDer, pacman and pyalpm versions."""
    localdb = DS.pyc.get_localdb()
    pacpkg = localdb.get_pkg('pacman')

    print("""PBWrapper   v{0}
PKGBUILDer  v{1}
pacman      v{2}
pyalpm      v{3}""".format(__wrapperversion__, __version__,
                           pacpkg.version.split('-', 1)[0],
                           pyalpm.version()))
github Kwpolska / pkgbuilder / pkgbuilder / upgrade.py View on Github external
def list_upgradable(pkglist, vcsup=False, aurcache=None, ignorelist=None):
    """Compare package versions and returns upgradable ones.

    .. versionchanged:: 4.2.9
    """
    localdb = DS.pyc.get_localdb()
    if ignorelist is None:
        ignorelist = []
    if aurcache:
        aurlist = aurcache
    else:
        aurlist = pkgbuilder.utils.info(pkglist)
        # It’s THAT easy.  Oh, and by the way: it is much, MUCH faster than
        # others.  It makes only a handful of multiinfo requests (1-2 on most
        # systems) rather than len(installed_packages) info requests.

    upgradable = []
    downgradable = []
    ignored = []

    for rpkg in aurlist:
        lpkg = localdb.get_pkg(rpkg.name)
github Kwpolska / pkgbuilder / pkgbuilder / transaction.py View on Github external
def validate(self, quiet):
        """Check if packages were installed.

        :param bool quiet: suppress messages
        :return: number of packages that were not installed
        :rtype: int
        """
        if self.pkgnames:
            if not quiet:
                DS.fancy_msg(_('Validating installation status...'))
            DS.log.info('Validating: ' + '; '.join(self.pkgnames))
            DS.pycreload()
            localdb = DS.pyc.get_localdb()

            aurpkgs = {aurpkg.name: aurpkg.version for aurpkg in
                       pkgbuilder.utils.info(self.pkgnames)}

            wrong = len(self.pkgnames)
        else:
            wrong = 0

        for pkgname in self.pkgnames:
            lpkg = localdb.get_pkg(pkgname)
            try:
                aurversion = aurpkgs[pkgname]
            except KeyError:
                if not lpkg:
                    if not quiet:
                        DS.fancy_error2(_('{0}: not an AUR package').format(
github Kwpolska / pkgbuilder / pkgbuilder / upgrade.py View on Github external
def gather_foreign_pkgs():
    """Gather a list of all foreign packages."""
    localdb = DS.pyc.get_localdb()
    # Based on paconky.py.
    installed = [p for p in localdb.pkgcache]
    repo = []
    aur = []
    syncdbs = DS.pyc.get_syncdbs()
    for sdb in syncdbs:
        for ipkg in installed:
            if sdb.get_pkg(ipkg.name):
                repo.append(ipkg)

    aur = set(set(installed) - set(repo))
    # Return foreign packages.
    return dict([(p.name, p) for p in aur])
github Kwpolska / pkgbuilder / pkgbuilder / utils.py View on Github external
def print_package_search(pkg, cachemode=False, prefix='', prefixp=''):
    """Output/return a package representation.

    Based on `pacman -Ss`.

    .. versionchanged:: 4.0.0

    """
    termwidth = get_termwidth(9001)

    localdb = DS.pyc.get_localdb()
    lpkg = localdb.get_pkg(pkg.name)
    category = ''
    installed = ''
    prefix2 = prefix + '    '
    prefixp2 = prefixp + '    '
    if lpkg is not None:
        if pyalpm.vercmp(pkg.version, lpkg.version) != 0:
            installed = _(' [installed: {0}]').format(lpkg.version)
        else:
            installed = _(' [installed]')
    try:
        if pkg.is_outdated:
            installed = (installed + ' ' + DS.colors['red'] +
                         _('[out of date]') + DS.colors['all_off'])
    except AttributeError:
        pass  # for repository packages