acl_toggle_remove(config, config.output, uid, allow=False)
try:
- run(cmdline, stdout=sys.stdout, env=os.environ)
+ run(cmdline, stdout=sys.stdout, env=os.environ, log=False)
finally:
if config.output_format == OutputFormat.directory:
acl_toggle_remove(config, config.output, uid, allow=True)
cmdline += config.qemu_args
cmdline += config.cmdline
- run(cmdline, stdout=sys.stdout, env=os.environ)
+ run(cmdline, stdout=sys.stdout, env=os.environ, log=False)
def run_ssh(config: MkosiConfig) -> None:
cmd += config.cmdline
- run(cmd, stdout=sys.stdout, env=os.environ)
+ run(cmd, stdout=sys.stdout, env=os.environ, log=False)
def run_serve(config: MkosiConfig) -> None:
return result
-def _run(
+def run(
cmdline: Sequence[PathString],
check: bool = True,
stdout: _FILE = None,
stderr: _FILE = None,
env: Mapping[str, PathString] = {},
+ log: bool = True,
**kwargs: Any,
) -> CompletedProcess:
if "run" in ARG_DEBUG:
preexec_fn=foreground)
except FileNotFoundError as e:
die(f"{cmdline[0]} not found in PATH.", e)
-
-
-def run(
- cmdline: Sequence[PathString],
- check: bool = True,
- stdout: _FILE = None,
- stderr: _FILE = None,
- env: Mapping[str, PathString] = {},
- **kwargs: Any,
-) -> CompletedProcess:
- try:
- return _run(cmdline, check, stdout, stderr, env, **kwargs)
except subprocess.CalledProcessError as e:
- die(f"\"{shlex.join(str(s) for s in cmdline)}\" returned non-zero exit code {e.returncode}.", e)
+ if log:
+ die(f"\"{shlex.join(str(s) for s in cmdline)}\" returned non-zero exit code {e.returncode}.", e)
+ raise e
def spawn(
template = f"chmod 1777 {state.root / 'tmp'} {state.root / 'var/tmp'} {state.root / 'dev/shm'} && exec {{}} || exit $?"
try:
- return _run([*cmdline, template.format(shlex.join(str(s) for s in cmd))],
- text=True, stdout=stdout, env=env)
+ return run([*cmdline, template.format(shlex.join(str(s) for s in cmd))],
+ text=True, stdout=stdout, env=env, log=False)
except subprocess.CalledProcessError as e:
if "run" in ARG_DEBUG:
- _run([*cmdline, template.format("sh")], check=False, env=env)
- raise e
+ run([*cmdline, template.format("sh")], check=False, env=env, log=False)
+ die(f"\"{shlex.join(str(s) for s in cmd)}\" returned non-zero exit code {e.returncode}.")
+
def run_workspace_command(
state: MkosiState,
template = "chmod 1777 /tmp /var/tmp /dev/shm && PATH=$PATH:/usr/bin:/usr/sbin exec {} || exit $?"
try:
- return _run([*cmdline, template.format(shlex.join(str(s) for s in cmd))],
- text=True, stdout=stdout, env=env)
+ return run([*cmdline, template.format(shlex.join(str(s) for s in cmd))],
+ text=True, stdout=stdout, env=env, log=False)
except subprocess.CalledProcessError as e:
if "run" in ARG_DEBUG:
- _run([*cmdline, template.format("sh")], check=False, env=env)
- raise e
+ run([*cmdline, template.format("sh")], check=False, env=env, log=False)
+ die(f"\"{shlex.join(str(s) for s in cmd)}\" returned non-zero exit code {e.returncode}.")
finally:
if state.workspace.joinpath("resolv.conf").is_symlink():
resolve.unlink(missing_ok=True)