How to use the pkgbuilder.utils 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 / tests / test_pkgbuilder.py View on Github external
'Depends On     : python  pyalpm>=0.5.1-1  python-requests  asp\n'
                  'Make Deps      : None\n'
                  'Check Deps     : None\n'
                  'Optional Deps  : None\n'
                  'Conflicts With : None\n'
                  'Replaces       : None\n'
                  'Votes          : 19\n'
                  'Popularity     : 7\n'
                  'Out of Date    : \x1b[1;1m\x1b[1;31myes\x1b[1;0m\n'
                  'Maintainer     : Kwpolska\nFirst Submitted: '
                  '2011-09-20T14:46:33Z\nLast Updated   : '
                  '2014-03-25T14:24:32Z\nDescription    : '
                  'A Python AUR helper/library.\n'
                  'Keywords       : foo  bar\n')

        req = pkgbuilder.utils.print_package_info([self.fpkg], True)
        self.assertEqual(req, sample)
github Kwpolska / pkgbuilder / pkgbuilder / __main__.py View on Github external
ignorelist.extend(i.split(','))
            upnames = pkgbuilder.upgrade.auto_upgrade(
                dodowngrade, DS.vcsupgrade, DS.fetch, ignorelist)
            pkgnames = upnames + pkgnames

        if DS.fetch and pkgnames:
            pkgbuilder.build.fetch_runner(pkgnames)
            if quit:
                exit(0)

        if args.userfetch:
            tofetch = []
            print(':: ' + _('Fetching package information...'))
            for u in args.userfetch:
                try:
                    tofetch += pkgbuilder.utils.msearch(u)
                except pkgbuilder.exceptions.AURError as e:
                    print(_('Error while processing {0}: {1}').format(u, e))

            pkgbuilder.build.fetch_runner(tofetch, preprocessed=True)
            if quit:
                exit(0)

        # If we didn't quit, we should build the packages.
        if pkgnames:
            DS.root_crash()

            DS.log.info('Starting build...')
            toinstall = []
            sigs = []
            tovalidate = set(pkgnames)
github Kwpolska / pkgbuilder / pkgbuilder / main.py View on Github external
search = pkgbuilder.utils.info([searchstring])
                    if search == []:
                        DS.fancy_error2(_('not found'))
                        if quit:
                            exit(0)
                    else:
                        pkgbuilder.utils.print_package_search(
                            search[0], prefix=(DS.colors['blue'] + '  ->' +
                                               DS.colors['all_off'] +
                                               DS.colors['bold'] + ' '),
                            prefixp='  -> ')
                        sys.stdout.write(DS.colors['all_off'])
                        if quit:
                            exit(0)
                else:
                    search = pkgbuilder.utils.search(searchstring)

            output = ''
            for pkg in search:
                if args.pac:
                    output = output + pkgbuilder.utils.print_package_search(
                        pkg, False, True) + '\n'
                else:
                    output = output + pkgbuilder.utils.print_package_search(
                        pkg, True, True) + '\n'
            if output != '':
                print(output.rstrip())
            if quit:
                exit(0)

        if args.finst:
            pkgbuilder.build.install(pkgnames, [], False)
github Kwpolska / pkgbuilder / pkgbuilder / build.py View on Github external
else:
                    depmatch = False
                    lsat = pyalpm.find_satisfier(localpkgs, dep)
                    if lsat:
                        depmatch = _test_dependency(lsat.version, diff, ver)
                        parseddeps[dep] = 0

                    if not depmatch:
                        ssat = pyalpm.find_satisfier(syncpkgs, dep)
                        if ssat:
                            depmatch = _test_dependency(ssat.version, diff,
                                                        ver)
                            parseddeps[dep] = 1

                        if not depmatch:
                            asat = pkgbuilder.utils.info([dep])
                            if asat:
                                depmatch = _test_dependency(asat[0].version,
                                                            diff, ver)
                                parseddeps[dep] = 2

                            if not depmatch:
                                raise pkgbuilder.exceptions.PackageError(
                                    _('Failed to fulfill package dependency '
                                      'requirement: {0}').format(fdep),
                                    req=fdep, source=pkgobj)

            if dep not in parseddeps:
                if pyalpm.find_satisfier(localpkgs, dep):
                    parseddeps[dep] = 0
                elif pyalpm.find_satisfier(syncpkgs, dep):
                    parseddeps[dep] = 1
github Kwpolska / pkgbuilder / sample-scripts / aur-ood-orphans.py View on Github external
parser = argparse.ArgumentParser(description=__doc__, epilog='Use both '
                                     'arguments to show data about orphanage '
                                     'status and outdated packages.')
    action = parser.add_argument_group('actions')
    action.add_argument('-m', '--orphans', action='store_true', default=False,
                        dest='orphans', help='show orphans')
    action.add_argument('-o', '--outdated', action='store_true',
                        default=False, dest='ood', help='show outdated '
                        'packages')
    args = parser.parse_args()

    foreign = pkgbuilder.upgrade.gather_foreign_pkgs().keys()
    ood = []
    orphans = []
    toprint = []
    for i in pkgbuilder.utils.info(foreign):
        if not i.human:
            orphans.append(i.name)

        if i.is_outdated:
            ood.append(i.name)

    if args.orphans and args.ood:
        both = list(set(ood + orphans))
        both.sort()
        for i in both:
            entry = ['(']
            if i in orphans:
                entry.append('M')
            else:
                entry.append(' ')
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)
        if lpkg is not None:
            vc = pyalpm.vercmp(rpkg.version, lpkg.version)
            if vc > 0 and rpkg.name not in ignorelist:
                upgradable.append([rpkg.name, lpkg.version, rpkg.version])
            elif vc > 0 and rpkg.name in ignorelist:
                DS.log.warning("{0} ignored for upgrade.".format(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(
                                        pkgname))
                else:
                    wrong -= 1