check_xbps.py: run commands with sudo only when necessary
This commit is contained in:
parent
7d476d9109
commit
2ad98cb81d
|
@ -79,9 +79,9 @@ lxc-2.0.4_1 update x86_64 https://repo.voidlinux.eu/current 1837102 468024'''.sp
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
def run_command(cmdline):
|
def run_command(cmdline, needs_sudo=False):
|
||||||
tstart = time.time()
|
tstart = time.time()
|
||||||
if plugin.options.sudo:
|
if needs_sudo and plugin.options.sudo:
|
||||||
new = ['sudo', '-n', '--']
|
new = ['sudo', '-n', '--']
|
||||||
new.extend(cmdline)
|
new.extend(cmdline)
|
||||||
cmdline = new
|
cmdline = new
|
||||||
|
@ -112,7 +112,7 @@ def run_command(cmdline):
|
||||||
if plugin.options.sync_repo_index:
|
if plugin.options.sync_repo_index:
|
||||||
plugin.verbose(1, '-S/--sync_repo_index given')
|
plugin.verbose(1, '-S/--sync_repo_index given')
|
||||||
cmdline = [plugin.options.xbps_install, '-S',]
|
cmdline = [plugin.options.xbps_install, '-S',]
|
||||||
(sout, serr, rc) = run_command(cmdline)
|
(sout, serr, rc) = run_command(cmdline, needs_sudo=True)
|
||||||
sout and plugin.verbose(3, sout, prefix='stdout: ')
|
sout and plugin.verbose(3, sout, prefix='stdout: ')
|
||||||
serr and plugin.verbose(3, serr, prefix='stderr: ')
|
serr and plugin.verbose(3, serr, prefix='stderr: ')
|
||||||
plugin.verbose(2, 'Return code: %d' % rc)
|
plugin.verbose(2, 'Return code: %d' % rc)
|
||||||
|
|
Loading…
Reference in a new issue