forked from Mirror/pmbootstrap
Make pmb.helpers.run.root support non-timeout output modes (MR 1996)
Before this commit, pmb.helpers.run_core.sanity_checks would raise a runtime error when pmb.helpers.run.root was called with an output mode that did not support timeouts (like background).
This commit is contained in:
parent
de175bfb1f
commit
82d149c85d
3 changed files with 15 additions and 3 deletions
|
@ -98,6 +98,13 @@ defaults = {
|
|||
"extra_space": "0"
|
||||
}
|
||||
|
||||
|
||||
# pmbootstrap will kill programs which do not output anything for several
|
||||
# minutes and have one of the following output types. See
|
||||
# pmb.helpers.run_core.core() for more information.
|
||||
run_outputs_with_timeout = ["log", "stdout"]
|
||||
|
||||
|
||||
#
|
||||
# CHROOT
|
||||
#
|
||||
|
|
|
@ -73,5 +73,9 @@ def root(args, cmd, working_dir=None, output="log", output_return=False,
|
|||
if env:
|
||||
cmd = ["sh", "-c", flat_cmd(cmd, env=env)]
|
||||
cmd = ["sudo"] + cmd
|
||||
|
||||
# pmbootstrap shall use 'sudo kill' to get rid of timed out programs
|
||||
kill_as_root = output in pmb.config.run_outputs_with_timeout or None
|
||||
|
||||
return user(args, cmd, working_dir, output, output_return, check, env,
|
||||
True)
|
||||
kill_as_root)
|
||||
|
|
|
@ -33,7 +33,7 @@ def sanity_checks(output="log", output_return=False, check=None,
|
|||
if output_return and output in ["tui", "background"]:
|
||||
raise RuntimeError("Can't use output_return with output: " + output)
|
||||
|
||||
if kill_as_root and output in ["interactive", "tui", "background"]:
|
||||
if kill_as_root and output not in pmb.config.run_outputs_with_timeout:
|
||||
raise RuntimeError("Can't use kill_as_root with output: " + output)
|
||||
|
||||
|
||||
|
@ -270,7 +270,8 @@ def core(args, log_message, cmd, working_dir=None, output="log",
|
|||
if not args.details_to_stdout and output in ["stdout", "interactive"]:
|
||||
output_to_stdout = True
|
||||
|
||||
output_timeout = output in ["log", "stdout"] and not disable_timeout
|
||||
output_timeout = output in pmb.config.run_outputs_with_timeout \
|
||||
and not disable_timeout
|
||||
(code, output_after_run) = foreground_pipe(args, cmd, working_dir,
|
||||
output_to_stdout,
|
||||
output_return,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue