How to use pkgbuilder - 10 common examples

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 / tests / test_pkgbuilder.py View on Github external
def test_utils_print_package_search(self):
        sample = ('aur/pkgbuilderts 3.2.0-1 (19 votes) '
                  '\x1b[1;1m\x1b[1;31m[out of date]\x1b[1;0m\n'
                  '    A Python AUR helper/library.')

        req = pkgbuilder.utils.print_package_search(self.fpkg, True)
        self.assertEqual(req, sample)
github Kwpolska / pkgbuilder / pkgbuilder / build.py View on Github external
for pkg in abspkgs:
                pm.msg(_('retrieving {0}').format(pkg.name), True)
                rc = asp_export(pkg)
                if rc > 0:
                    raise pkgbuilder.exceptions.NetworkError(
                        _('Failed to retieve {0} (from ASP).').format(
                            pkg.name), source='asp', pkg=pkg, retcode=rc)

        if aurpkgs:
            print(_(':: Retrieving packages from aur...'))
            pm = pkgbuilder.ui.Progress(len(aurpkgs))
            for pkg in aurpkgs:
                pm.msg(_('cloning {0}').format(pkg.packagebase), True)
                clone(pkg.packagebase)

        print(_('Successfully fetched: ') + ' '.join(pkgnames))
    except pkgbuilder.exceptions.PBException as e:
        print(':: ERROR: ' + str(e.msg))
        exit(1)
github Kwpolska / pkgbuilder / pkgbuilder / wrapper.py View on Github external
pacargs.append('--' + k)
                    pacargs.extend(v)
                elif k in commonlongl:
                    for vi in v:
                        pacargs.append('--' + k)
                        pacargs.append(vi)
                        pbargs.append('--' + k)
                        pbargs.append(vi)

        log.debug('Preparing to run pacman and/or PKGBUILDer...')

        if args.search or args.s:
            log.debug('Got -s.')
            if args.pkgnames:
                log.info('Running pacman.')
                DS.run_command([DS.paccommand] + pacargs + pkgnames)
                log.info('Running pkgbuilder (pkgbuilder.__main__.main()).')
                pbmain(pbargs + pkgnames)
            else:
                log.info('Nothing to do — args.pkgnames is empty.')

            exit()
        elif args.l or args.list:
            log.debug('Got -l.')
            log.info('Running pacman.')
            DS.run_command([DS.paccommand] + pacargs + pkgnames)
            exit()
        elif args.u or args.sysupgrade:
            log.debug('Got -u.')
            log.info('Running pacman.')
            DS.sudo([DS.paccommand] + pacargs)
            log.info('Running pkgbuilder (pkgbuilder.__main__.main()).')
github Kwpolska / pkgbuilder / pkgbuilder / transaction.py View on Github external
:param bool quiet: suppress messages
        :return: pacman return code
        :rtype: int
        """
        if not sudo_tested:
            self._test_sudo()
        if not quiet:
            DS.fancy_msg2(_('Installing with pacman -U...'))

        npkgpaths = self.pacman_pkgpaths
        uopt = self.uopt.strip()

        if self.asdeps:
            uopt = uopt + ' --asdeps'

        if not DS.confirm:
            uopt = uopt + ' --noconfirm'

        uopt = uopt.strip()

        if uopt:
            DS.log.debug('$PACMAN -U {0} {1}'.format(uopt, npkgpaths))
            ret = DS.sudo([DS.paccommand, '-U'] + uopt.split(' ') + npkgpaths)
        else:
            DS.log.debug('$PACMAN -U {0}'.format(npkgpaths))
            ret = DS.sudo([DS.paccommand, '-U'] + npkgpaths)

        self.pacmanreturn = ret
        self._set_status_from_return(ret, TransactionStatus.installed,
                                     TransactionStatus.install_failed)
        return ret
github Kwpolska / pkgbuilder / pkgbuilder / main.py View on Github external
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)

            for pkgname in pkgnames:
                try:
                    DS.log.info('Building {0}'.format(pkgname))
                    out = pkgbuilder.build.auto_build(pkgname, args.depcheck,
                                                      args.pkginst, pkgnames)
                    if out:
                        toinstall += out[1][0]
                        sigs += out[1][1]
                except PBException as e:
                    DS.fancy_error(str(e))
                    if e.exit:
                        exit(1)
github Kwpolska / pkgbuilder / pkgbuilder / __main__.py View on Github external
user_chdir = DS.config.get('extras', 'chdir').strip()

        if user_chdir:
            DS.log.debug('Changing directory to %s (via config)', user_chdir)
            os.makedirs(user_chdir, exist_ok=True)
            os.chdir(user_chdir)
        elif DS.pacman:
            DS.log.debug('-S passed, building in /tmp/.')
            path = '/tmp/pkgbuilder-{0}'.format(str(DS.uid))
            if not os.path.exists(path):
                os.mkdir(path)
            os.chdir(path)

        if args.upgrade:
            DS.root_crash()
            DS.log.info('Starting upgrade...')
            dodowngrade = args.upgrade > 1
            ignorelist = []
            for i in (args.ignorelist or []):
                # `pacman -Syu --ignore a,b --ignore c` → ignores a, b, c
                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 = []
github Kwpolska / pkgbuilder / pkgbuilder / __main__.py View on Github external
except NetworkError as e:
        DS.fancy_error(str(e))
        # TRANSLATORS: do not translate the word 'requests'.
        DS.fancy_error(_('PKGBUILDer (or the requests library) had '
                         'problems with fulfilling an HTTP request.'))
        if e.exit:
            exit(1)
    except PBException as e:
        DS.fancy_error(str(e))
        if e.exit:
            exit(1)
    except KeyboardInterrupt:
        pkgbuilder.DS.fancy_error(pkgbuilder.DS.inttext)
        exit(130)

    DS.log.info('Quitting peacefully.')
github Kwpolska / pkgbuilder / pkgbuilder / main.py View on Github external
if args.finst:
            pkgbuilder.build.install(pkgnames, [], False)
            if quit:
                exit(0)

        if args.pac:
            DS.log.debug('-S passed, building in /tmp/.')
            path = '/tmp/pkgbuilder-{0}'.format(str(DS.uid))
            if not os.path.exists(path):
                os.mkdir(path)
            os.chdir(path)

        if args.upgrade > 0:
            DS.root_crash()
            DS.log.info('Starting upgrade...')
            dodowngrade = args.upgrade > 1
            upnames = pkgbuilder.upgrade.auto_upgrade(dodowngrade, args.vcsup)
            pkgnames = upnames + pkgnames

        if args.fetch:
            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:
github Kwpolska / pkgbuilder / pkgbuilder / main.py View on Github external
else:
            args = parser.parse_args()

        DS.pacman = args.pac
        DS.cleanup = args.cleanup
        pkgnames = args.pkgnames

        if args.aur4:
            pkgbuilder.aur.AUR.base = 'https://aur4.archlinux.org'

        if args.debug:
            DS.debugmode(nochange=True)
            DS.log.info('*** PKGBUILDer v{0}'.format(__version__))
            DS.log.debug('*** debug output on.')

        DS.log.info('Arguments parsed.  {0}'.format(args.__dict__))

        if 'VIRTUAL_ENV' in os.environ:
            DS.log.error("virtualenv detected, exiting.")
            DS.fancy_error(_("PKGBUILDer cannot work in a virtualenv, "
                             "exiting."))
            exit(83)

        if not args.color:
            DS.colorsoff()
            DS.log.debug('Colors turned off.')

        if args.info:
            DS.log.debug('Showing info...')

            pkgs = pkgbuilder.utils.info(pkgnames)
            foundnames = [i.name for i in pkgs]