How to use the pkgbuilder.DS 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 / 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 / build.py View on Github external
pkgnames=build_result[1],
                    pkgpaths=toinstall2,
                    sigpaths=sigs2,
                    asdeps=True,
                    filename=pkgbuilder.transaction.generate_filename(),
                    delete=True)
                tx.run(standalone=False, validate=DS.validation)

            return auto_build(pkgname, performdepcheck, pkginstall,
                              completelist)

        return build_result
    # Non-critical exceptions that shouldn’t crash PKGBUILDer as a whole are
    # handled here.  Some are duplicated for various reasons.
    except pkgbuilder.exceptions.MakepkgError as e:
        DS.fancy_error(_('makepkg (or someone else) failed and '
                         'returned {0}.').format(e.retcode))
        return []
    except pkgbuilder.exceptions.AURError as e:
        DS.fancy_error(str(e))
        return []
    except pkgbuilder.exceptions.PackageError as e:
        DS.fancy_error(str(e))
        return []
github Kwpolska / pkgbuilder / pkgbuilder / transaction.py View on Github external
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
                    if not quiet:
                        DS.fancy_msg2(_('{0}: installed {1}').format(
                                      pkgname, lpkg.version))
            else:
                if not lpkg:
                    if not quiet:
                        DS.fancy_error2(_('{0}: NOT installed').format(
                            pkgname))
                else:
                    if pyalpm.vercmp(aurversion, lpkg.version) > 0:
                        if not quiet:
                            DS.fancy_error2(_('{0}: outdated {1}').format(
                                pkgname, lpkg.version))
github Kwpolska / pkgbuilder / pkgbuilder / exceptions.py View on Github external
def __init__(self, pkgbase, exit=False, *args, **kwargs):
        DS.log.error('({0:<20}) directory {1} exists, but is not a git '
                     'repository'.format(self.qualname, pkgbase))
        self.pkgbase = pkgbase
        self.msg = _('Directory {0} exists, but is not a git '
                     'repository.').format(self.pkgbase)
        self.exit = exit
        self.args = args
        self.kwargs = kwargs
github Kwpolska / pkgbuilder / pkgbuilder / build.py View on Github external
'The package download failed.\n    This package might '
                'be generated from a split PKGBUILD.  Please find out the '
                'name of the “main” package (eg. python- instead of python2-) '
                'and try again.', pkg.name, exit=False)

        if not os.path.exists('.SRCINFO'):
            # Create a .SRCINFO file for ASP/repo packages.
            # Slightly hacky, but saves us work on parsing bash.
            DS.log.debug("Creating .SRCINFO for repository package")
            srcinfo = subprocess.check_output(["makepkg", "--printsrcinfo"])
            with open(".SRCINFO", "wb") as fh:
                fh.write(srcinfo)
    else:
        existing = find_packagefile(pkg.packagebase)
        if any(pkg.name in i for i in existing[0]):
            DS.fancy_msg(_('Found an existing package for '
                           '{0}').format(pkgname))
            if not pkginstall:
                existing = ([], [])
            return [RES_EXISTING, existing]
        DS.fancy_msg(_('Cloning the git repository...'))
        clone(pkg.packagebase)
        os.chdir('./{0}/'.format(pkg.packagebase))
        if not os.path.exists('.SRCINFO'):
            raise pkgbuilder.exceptions.EmptyRepoError(pkg.packagebase)
    subpackages = find_subpackages(os.path.abspath('./.SRCINFO'))

    if performdepcheck:
        DS.fancy_msg(_('Checking dependencies...'))
        depends = prepare_deps(os.path.abspath('./.SRCINFO'))
        deps = depcheck(depends, pkg)
        pkgtypes = [_('found in system'), _('found in repos'),
github Kwpolska / pkgbuilder / pkgbuilder / build.py View on Github external
If you can, use it.


    .. note::

        This function returns a list of packages to install with pacman -U.
        Please take care of it.  Running PKGBUILDer/PBWrapper standalone or
        .__main__.main() will do that.

    """
    if completelist is None:
        completelist = []
    build_result = build_runner(pkgname, performdepcheck, pkginstall, pkgbuild_edit)
    try:
        if build_result[0] == 0:
            DS.fancy_msg(_('The build succeeded.'))
        elif build_result[0] >= 0 and build_result[0] < 256:
            raise pkgbuilder.exceptions.MakepkgError(build_result[0])
        elif build_result[0] == RES_ABORT:
            DS.fancy_warning(_('Installation aborted by user.'))
        elif build_result[0] == RES_EXISTING:
            # existing package, do nothing
            pass
        elif build_result[0] == RES_AURDEPS:
            DS.fancy_warning(_('Building more AUR packages is required.'))
            if not pkginstall:
                raise pkgbuilder.exceptions.PBException(
                    _('Cannot install dependencies and continue building '
                      'because -w, --buildonly was specified.  Please run '
                      'without -w, --buildonly or install dependencies '
                      'manually and try again.'),
                    'auto_build deps')
github Kwpolska / pkgbuilder / pkgbuilder / __main__.py View on Github external
def main(source='AUTO', quit=True):
    """Main routine of PKGBUILDer."""
    try:
        verstring = 'PKGBUILDer v' + __version__
        # TRANSLATORS: translate the whole sentence.
        # Alternatively, use translation instead of locale.
        locale = _('LANG locale by AUTHOR ')
        if locale != 'LANG locale by AUTHOR ':
            verstring = ' — '.join([verstring, locale])
        DS.log.info('Initialized, parsing arguments.')
        parser = argparse.ArgumentParser(
            prog='pkgbuilder',
            description=_('An AUR helper (and library) in Python 3.'),
            epilog=_('Also accepts repository packages to build from source.'))
        parser.add_argument(
            '-V', '--version', action='version', version=verstring,
            help=_('show version number and quit'))
        parser.add_argument(
            'pkgnames', metavar=_('PACKAGE'), action='store', nargs='*',
            help=_('AUR/repository packages to build'))

        argopr = parser.add_argument_group(_('operations'))
        argopr.add_argument(
            '-S', '--sync', action='store_true', dest='pac',
            help=_('build in /tmp'))
        argopr.add_argument(