env: Optional[Mapping[str, str]] = None,
nspawn_params: Optional[List[str]] = None,
capture_stdout: bool = False,
-) -> Optional[str]:
+ check: bool = True,
+) -> CompletedProcess:
nspawn = [
nspawn_executable(),
"--quiet",
if args.nspawn_keep_unit:
nspawn += ["--keep-unit"]
- result = run([*nspawn, "--", *cmd], check=False, stdout=stdout, text=capture_stdout)
- if result.returncode != 0:
+ try:
+ return run([*nspawn, "--", *cmd], check=check, stdout=stdout, text=capture_stdout)
+ except subprocess.CalledProcessError as e:
if "workspace-command" in ARG_DEBUG:
run(nspawn, check=False)
- die(f"Workspace command {shell_join(cmd)} returned non-zero exit code {result.returncode}.")
-
- return result.stdout.strip() if capture_stdout else None
+ die(f"Workspace command {shell_join(cmd)} returned non-zero exit code {e.returncode}.")
@contextlib.contextmanager
# We have to run from the root, because if we use the RootDir option to make
# apt from the host look at the repositories in the image, it will also pick
# the 'methods' executables from there, but the ABI might not be compatible.
- changelog = run_workspace_command(self.args, root, cmd, network=not self.args.with_docs, capture_stdout=True)
- source_package = SourcePackageManifest(source, changelog)
+ result = run_workspace_command(self.args, root, cmd, network=not self.args.with_docs, capture_stdout=True)
+ source_package = SourcePackageManifest(source, result.stdout.strip())
self.source_packages[source] = source_package
source_package.add(package)