How to use the pkgbuilder.DS.sudo 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 / transaction.py View on Github external
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 / transaction.py View on Github external
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 / wrapper.py View on Github external
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()).')
            pbmain(pbargs, quit=False)
        elif args.y or args.refresh:
            log.debug('Got -y.')
            log.info('Running pacman.')
            DS.sudo([DS.paccommand] + pacargs)
        elif args.help:
            show_help()
            exit()
        elif args.version:
            show_version()
            exit()

        log.debug('Generating AUR packages list...')
        pbpkgnames = []
        info = pkgbuilder.utils.info(pkgnames)

        names = [i.name for i in info]
        pbpkgnames = [n for n in pkgnames if n in names]
        pacmanpkgnames = [i for i in pkgnames if i not in pbpkgnames]

        droppable = ['-u', '-y', '--sysupgrade', '--refresh']
github Kwpolska / pkgbuilder / pkgbuilder / wrapper.py View on Github external
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()).')
            pbmain(pbargs, quit=False)
        elif args.y or args.refresh:
            log.debug('Got -y.')
            log.info('Running pacman.')
            DS.sudo([DS.paccommand] + pacargs)
        elif args.help:
            show_help()
            exit()
        elif args.version:
            show_version()
            exit()

        log.debug('Generating AUR packages list...')
        pbpkgnames = []
        info = pkgbuilder.utils.info(pkgnames)
github Kwpolska / pkgbuilder / pkgbuilder / transaction.py View on Github external
def _test_sudo(self):
        """Test if sudo works."""
        trueexit = 256
        while trueexit != 0:
            trueexit = DS.sudo(['true'])
github Kwpolska / pkgbuilder / pkgbuilder / transaction.py View on Github external
elif os.path.exists(pacs):
                DS.log.warning("Not moving signature file {0} -- "
                               "found in pacman cache".format(s))
            else:
                DS.log.error("Not moving signature file {0} -- "
                             "not found".format(s))
                if not quiet:
                    DS.fancy_warning2(_("Signature file {0} not found").format(
                        s))
                failed_files += 1

        DS.log.debug('mv {0} {1} /var/cache/pacman/pkg/'.format(
            pkgpaths, sigpaths))
        ret = -failed_files
        if pkgpaths or sigpaths:
            ret = DS.sudo(['mv'] + pkgpaths + sigpaths +
                          ['/var/cache/pacman/pkg/'])
        self._set_status_from_return(ret, TransactionStatus.moved,
                                     TransactionStatus.move_failed)
        return ret