diff options
author | Helmut Grohne <helmut@subdivi.de> | 2021-05-09 07:50:18 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2021-05-09 07:50:18 +0200 |
commit | 15fa5e5b555fdc1aad10f51822de877cde71294d (patch) | |
tree | 6c072ade8fda146e32503fc4afc0414c8263e822 | |
parent | bf30d5dd03503f776127c42d3f1d8b2ea529b150 (diff) | |
download | mdbp-15fa5e5b555fdc1aad10f51822de877cde71294d.tar.gz |
the stdout fd contains the build log
Using a pipe enables streaming of logs, which would not be possible with
a regular file output.
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | TODO.md | 1 | ||||
-rw-r--r-- | mdbp/build_schema.json | 5 | ||||
-rw-r--r-- | mdbp/mmdebstrap.py | 11 | ||||
-rw-r--r-- | mdbp/pbuilder.py | 9 | ||||
-rw-r--r-- | mdbp/sbuild.py | 7 |
6 files changed, 29 insertions, 7 deletions
@@ -23,7 +23,8 @@ The output directory `out` is supposed to be an empty directory. Then run one of the backends `mdbp-BACKEND [BACKENDOPTIONS] REQUEST.json`. The process blocks until the build has finished and its return code signifies success or failure of the operation. Usage of unsupported parameters of the particular -backend result in a failure of the operation as a whole. +backend result in a failure of the operation as a whole. The content of the +stdout file descriptor is to be considered the build log. When to use mdbp? ----------------- @@ -1,4 +1,3 @@ -* A build log should be supplied in a machine-consumable way. * It should be requestable which build artifacts are to be retained. * There should be a remote backend performing builds via ssh. * There should be a backend supporting a container thingy (e.g. `debspawn`, diff --git a/mdbp/build_schema.json b/mdbp/build_schema.json index 138de76..85bcd00 100644 --- a/mdbp/build_schema.json +++ b/mdbp/build_schema.json @@ -123,6 +123,11 @@ "directory": { "type": "string", "description": "target directory to place output artifacts, can be specified relative to the location of this json file" + }, + "log": { + "type": "boolean", + "default": true, + "description": "whether to output the build log on the stdout file descriptor" } } } diff --git a/mdbp/mmdebstrap.py b/mdbp/mmdebstrap.py index 4538067..21862c6 100644 --- a/mdbp/mmdebstrap.py +++ b/mdbp/mmdebstrap.py @@ -76,6 +76,7 @@ def main() -> None: "libc-dev:" + hostarch, "libstdc++-dev:" + hostarch)) buildpath = pathlib.PurePath(build.get("buildpath", "/build/build")) + enablelog = build["output"].get("log", True) with get_dsc(build) as dscpath, \ tempfile.NamedTemporaryFile("w+") as script: @@ -91,7 +92,7 @@ def main() -> None: all=["--indep-only"]).get(build.get("type"), [])) cmd.extend(profile_option(build, "--build-profiles")) cmd.append(str(buildpath.parent / dscpath.name)) - if build.get("bd-uninstallable-explainer") == "apt": + if build.get("bd-uninstallable-explainer") == "apt" and enablelog: script.write("if ! %s\nthen\n" % priv_drop(cmd, chroot=True)) cmd[-1:-1] = ['-oDebug::pkgProblemResolver=true', '-oDebug::pkgDepCache::Marker=1', @@ -132,7 +133,7 @@ def main() -> None: pathlib.Path(script.name).chmod(0o755) cmd = [ "mmdebstrap", - "--verbose", + "--verbose" if enablelog else "--quiet", "--mode=unshare", "--variant=apt", "--architectures=" + @@ -153,7 +154,11 @@ def main() -> None: args.mirror, ] cmd.extend(build.get("extrarepositories", ())) - proc = subprocess.Popen(cmd) + proc = subprocess.Popen(cmd, + stdout=None if enablelog + else subprocess.DEVNULL, + stderr=subprocess.STDOUT if enablelog + else subprocess.DEVNULL) sys.exit(proc.wait()) if __name__ == "__main__": diff --git a/mdbp/pbuilder.py b/mdbp/pbuilder.py index 8e2556d..a5f734a 100644 --- a/mdbp/pbuilder.py +++ b/mdbp/pbuilder.py @@ -18,6 +18,7 @@ def main() -> None: args = parser.parse_args() build = args.buildjson + enablelog = build["output"].get("log", True) if build.get("lintian", {}).get("run"): raise ValueError("running lintian not supported") if "bd-uninstallable-explainer" in build: @@ -55,9 +56,15 @@ def main() -> None: build.get("type", "binary")]) cmd.extend(profile_option(build, "--profiles")) cmd.extend(["--buildresult", build["output"]["directory"]]) + if not enablelog: + cmd.extend(["--loglevel", "E"]) with get_dsc(build) as dscpath: cmd.append(str(dscpath)) - proc = subprocess.Popen(cmd, env=compute_env(build)) + proc = subprocess.Popen(cmd, env=compute_env(build), + stdout=None if enablelog + else subprocess.DEVNULL, + stderr=subprocess.STDOUT if enablelog + else subprocess.DEVNULL) sys.exit(proc.wait()) if __name__ == "__main__": diff --git a/mdbp/sbuild.py b/mdbp/sbuild.py index 6b9c33d..ffaeaf2 100644 --- a/mdbp/sbuild.py +++ b/mdbp/sbuild.py @@ -47,7 +47,12 @@ def main() -> None: with get_dsc(build) as dscpath: cmd.append(str(dscpath.absolute())) proc = subprocess.Popen(cmd, env=compute_env(build), - cwd=build["output"]["directory"]) + cwd=build["output"]["directory"], + stdout=None if build["output"].get("log", True) + else subprocess.DEVNULL, + stderr=subprocess.STDOUT + if build["output"].get("log", True) + else subprocess.DEVNULL) sys.exit(proc.wait()) if __name__ == "__main__": |