# We always log when subprocess.CalledProcessError is raised, so we don't log again here.
sys.exit(e.returncode)
- except Exception as e:
- if ARG_DEBUG.get():
- raise e
- elif not isinstance(e, RuntimeError):
- # RuntimeError is used to wrap generic errors, and the message that was printed should be enough.
- logging.info(f"Hint: mkosi failed because of an internal exception {e.__class__.__name__}, "
- "rerun mkosi with --debug to get more information")
- sys.exit(1)
@propagate_failed_return()
env=env,
**kwargs,
preexec_fn=foreground)
- except FileNotFoundError as e:
- die(f"{cmdline[0]} not found in PATH.", e)
+ except FileNotFoundError:
+ die(f"{cmdline[0]} not found in PATH.")
except subprocess.CalledProcessError as e:
if log:
- die(f'"{shlex.join(str(s) for s in cmdline)}" returned non-zero exit code {e.returncode}.', e)
+ logging.error(f'"{shlex.join(str(s) for s in cmdline)}" returned non-zero exit code {e.returncode}.')
raise e
except FileNotFoundError:
die(f"{cmdline[0]} not found in PATH.")
except subprocess.CalledProcessError as e:
- die(f'"{shlex.join(str(s) for s in cmdline)}" returned non-zero exit code {e.returncode}.', e)
+ logging.error(f'"{shlex.join(str(s) for s in cmdline)}" returned non-zero exit code {e.returncode}.')
+ raise e
def bwrap(
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:
+ logging.error(f'"{shlex.join(str(s) for s in cmd)}" returned non-zero exit code {e.returncode}.')
if ARG_DEBUG_SHELL.get():
run([*cmdline, template.format("sh")], stdin=sys.stdin, check=False, env=env, log=False)
- die(f'"{shlex.join(str(s) for s in cmd)}" returned non-zero exit code {e.returncode}.')
+ raise e
def run_workspace_command(
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:
+ logging.error(f'"{shlex.join(str(s) for s in cmd)}" returned non-zero exit code {e.returncode}.')
if ARG_DEBUG_SHELL.get():
run([*cmdline, template.format("sh")], stdin=sys.stdin, check=False, env=env, log=False)
- die(f'"{shlex.join(str(s) for s in cmd)}" returned non-zero exit code {e.returncode}.')
+ raise e
finally:
if tmp.is_symlink():
resolve.unlink(missing_ok=True)
def test_shell_boot() -> None:
with cd_temp_dir():
- with pytest.raises(RuntimeError, match=".boot.*tar"):
+ with pytest.raises(SystemExit):
parse(["--format", "tar", "boot"])
- with pytest.raises(RuntimeError, match=".boot.*cpio"):
+ with pytest.raises(SystemExit):
parse(["--format", "cpio", "boot"])
- with pytest.raises(RuntimeError, match=".boot.*compressed" ):
+ with pytest.raises(SystemExit):
parse(["--format", "disk", "--compress-output=yes", "boot"])