summaryrefslogtreecommitdiff
path: root/mdbp/sbuild.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2021-04-18 14:42:27 +0200
committerHelmut Grohne <helmut@subdivi.de>2021-04-18 14:42:27 +0200
commitcf999acb17c8123ddee407d0e486ca3b275a5d7c (patch)
treebfe9307dc9d2dd49fd46111bab0e3fbe324d6687 /mdbp/sbuild.py
downloadmdbp-cf999acb17c8123ddee407d0e486ca3b275a5d7c.tar.gz
initial checkin of mdbp
Proof-of-concept status. Some things work.
Diffstat (limited to 'mdbp/sbuild.py')
-rw-r--r--mdbp/sbuild.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/mdbp/sbuild.py b/mdbp/sbuild.py
new file mode 100644
index 0000000..6f1d75a
--- /dev/null
+++ b/mdbp/sbuild.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: MIT
+"""mdbp backend using sbuild"""
+
+import argparse
+import subprocess
+
+from .common import buildjson, compute_env, get_dsc, make_option, \
+ profile_option
+
+def main() -> None:
+ """Entry point for mdbp-sbuild backend"""
+ parser = argparse.ArgumentParser()
+ parser.add_argument("buildjson", type=buildjson)
+ args = parser.parse_args()
+ build = args.buildjson
+
+ if build.get("network") == "disable":
+ raise ValueError("disabling network not supported with sbuild")
+
+ cmd = [
+ "sbuild",
+ "--dist=" + build["distribution"],
+ "--no-arch-any" if build.get("type") == "all" else "--arch-any",
+ "--no-arch-all" if build.get("type") == "any" else "--arch-all",
+ "--bd-uninstallable-explainer=" +
+ (build.get("bd-uninstallable-explainer") or ""),
+ "--run-lintian" if build.get("lintian", {}).get("run") else
+ "--no-run-lintian",
+ ]
+ cmd.extend(make_option("--build=", build.get("buildarch")))
+ cmd.extend(make_option("--host=", build.get("hostarch")))
+ cmd.extend(map("--extra-repository=".__add__,
+ build.get("extrarepositories", ())))
+ cmd.extend(profile_option(build, "--profiles="))
+ cmd.extend(make_option("--build-path=", build.get("buildpath")))
+ if build.get("network") == "try-disable":
+ cmd.extend([
+ "--starting-build-commands="
+ "mv /etc/resolv.conf /etc/resolv.conf.disabled",
+ "--finished-build-commands="
+ "mv /etc/resolv.conf.disabled /etc/resolv.conf",
+ ])
+ with get_dsc(build) as dscpath:
+ cmd.append(str(dscpath.absolute()))
+ proc = subprocess.Popen(cmd, env=compute_env(build),
+ cwd=build["output"]["directory"])
+ proc.wait()
+
+if __name__ == "__main__":
+ main()