diff options
author | Helmut Grohne <helmut@subdivi.de> | 2021-04-18 14:42:27 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2021-04-18 14:42:27 +0200 |
commit | cf999acb17c8123ddee407d0e486ca3b275a5d7c (patch) | |
tree | bfe9307dc9d2dd49fd46111bab0e3fbe324d6687 /mdbp/pbuilder.py | |
download | mdbp-cf999acb17c8123ddee407d0e486ca3b275a5d7c.tar.gz |
initial checkin of mdbp
Proof-of-concept status. Some things work.
Diffstat (limited to 'mdbp/pbuilder.py')
-rw-r--r-- | mdbp/pbuilder.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/mdbp/pbuilder.py b/mdbp/pbuilder.py new file mode 100644 index 0000000..51111e3 --- /dev/null +++ b/mdbp/pbuilder.py @@ -0,0 +1,63 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: MIT +"""mdbp backend using pbuilder""" + +import argparse +import os +import pathlib +import subprocess + +from .common import buildjson, compute_env, get_dsc, make_option, \ + profile_option + +def main() -> None: + """Entry point for mdbp-pbuilder backend""" + parser = argparse.ArgumentParser() + parser.add_argument("buildjson", type=buildjson) + args = parser.parse_args() + build = args.buildjson + + if build.get("lintian", {}).get("run"): + raise ValueError("running lintian not supported") + if build.get("bd-uinstallable-explainer"): + raise ValueError("bd-uninstallable-explainer %r not supported" % + build.get("bd-uinstallable-explainer")) + if build.get("buildpath"): + raise ValueError("buildpath not supported") + if build["distribution"] in ("sid", "unstable"): + basetgz = None + else: + for pat in ("/var/cache/pbuilder/%s-base.tgz", + "/var/cache/pbuidler/%s.tgz"): + basetgz = pat % build["distribution"] + if pathlib.Path(basetgz).is_file(): + break + else: + raise ValueError("unsupported distribution %s" % + build["distribution"]) + + cmd = [] + if os.getuid() != 0: + cmd.extend(["sudo", "-E", "--"]) + cmd.extend(["/usr/sbin/pbuilder", "build"]) + cmd.extend(make_option("--basetgz", basetgz)) + cmd.extend(make_option("--architecture", build.get("buildarch"))) + cmd.extend(make_option("--host-arch", build.get("hostarch"))) + cmd.extend(make_option("--othermirror", + "|".join(build.get("extrarepositories", ())))) + cmd.extend(make_option("--use-network", + {"enable": "yes", "try-enable": "yes", "disable": "no", + "try-disable": "no"}.get(build.get("network")))) + cmd.extend(dict(any=["--binary-arch"], + all=["--binary-indep"], + binary=["--debbuildopts", "-b"])[ + build.get("type", "binary")]) + cmd.extend(profile_option(build, "--profiles")) + cmd.extend(["--buildresult", build["output"]["directory"]]) + with get_dsc(build) as dscpath: + cmd.append(str(dscpath)) + proc = subprocess.Popen(cmd, env=compute_env(build)) + proc.wait() + +if __name__ == "__main__": + main() |