diff options
-rw-r--r-- | mdbp/build_schema.json | 15 | ||||
-rw-r--r-- | mdbp/mmdebstrap.py | 16 | ||||
-rw-r--r-- | mdbp/pbuilder.py | 2 | ||||
-rw-r--r-- | mdbp/sbuild.py | 14 |
4 files changed, 42 insertions, 5 deletions
diff --git a/mdbp/build_schema.json b/mdbp/build_schema.json index d971f0d..e7c203c 100644 --- a/mdbp/build_schema.json +++ b/mdbp/build_schema.json @@ -31,6 +31,21 @@ "description": "a mapping of checksum algorithms to the expected values" } } + }, { + "required": [ "sourcename" ], + "additionalProperties": false, + "properties": { + "sourcename": { + "type": "string", + "pattern": "^[a-z0-9][a-z0-9.+-]*$", + "description": "name of a source package to fetch from the configured distribution" + }, + "version": { + "type": "string", + "pattern": "^([0-9]+:)?[a-zA-Z0-9.+~-]+$", + "description": "request a particular version of the source package" + } + } } ] }, "distribution": { diff --git a/mdbp/mmdebstrap.py b/mdbp/mmdebstrap.py index 62d3195..0a7dba4 100644 --- a/mdbp/mmdebstrap.py +++ b/mdbp/mmdebstrap.py @@ -3,6 +3,7 @@ """mdbp backend using mmdebstrap""" import argparse +import contextlib import ctypes import ctypes.util import functools @@ -67,10 +68,20 @@ def hook_main(buildjsonfilename: str, chrootname: str) -> None: if "dscpath" in build["input"]: dscpath = fullbuildpath.parent / \ pathlib.PurePath(build["input"]["dscpath"]).name - else: + elif "dscuri" in build["input"]: dscpath = download_dsc(build["input"], fullbuildpath.parent) priv_drop(["chown", "-R", "build:build", "."], chroot=chroot, chdir=buildpath.parent) + apt_get = ["apt-get", "--yes", "-oAPT::Keep-Downloaded-Packages=false"] + if "sourcename" in build["input"]: + sourcename = build["input"]["sourcename"] + with contextlib.suppress(KeyError): + sourcename += "=" + build["input"]["version"] + priv_drop([*apt_get, "--only-source", "--download-only", "source", + sourcename], + chroot=chroot, chdir=buildpath.parent, setuid="build") + [dscpath] = fullbuildpath.parent.glob(build["input"]["sourcename"] + + "_*.dsc") priv_drop(["dpkg-source", "--no-check", "--extract", dscpath.name, buildpath.name], setuid="build", chroot=chroot, chdir=buildpath.parent) @@ -78,7 +89,6 @@ def hook_main(buildjsonfilename: str, chrootname: str) -> None: path.unlink() hostarch = build.get("hostarch") or build.get("buildarch") or \ native_architecture() - apt_get = ["apt-get", "--yes", "-oAPT::Keep-Downloaded-Packages=false"] cmd = [*apt_get, "build-dep", "--host-architecture", hostarch, *dict(any=["--arch-only"], all=["--indep-only"]).get(build.get("type"), ()), @@ -182,6 +192,8 @@ def main() -> None: build["distribution"], "/dev/null", args.mirror, + *(["deb-src %s %s main" % (args.mirror, build["distribution"])] + if "sourcename" in build["input"] else ()), *build.get("extrarepositories", ()), ] proc = subprocess.Popen(cmd, diff --git a/mdbp/pbuilder.py b/mdbp/pbuilder.py index a5f734a..7208152 100644 --- a/mdbp/pbuilder.py +++ b/mdbp/pbuilder.py @@ -18,6 +18,8 @@ def main() -> None: args = parser.parse_args() build = args.buildjson + if "sourcename" in build["input"]: + raise ValueError("building a source package by name is not supported") enablelog = build["output"].get("log", True) if build.get("lintian", {}).get("run"): raise ValueError("running lintian not supported") diff --git a/mdbp/sbuild.py b/mdbp/sbuild.py index ef6b67d..defd0bc 100644 --- a/mdbp/sbuild.py +++ b/mdbp/sbuild.py @@ -75,11 +75,19 @@ def main() -> None: sbc["external_commands"]["finished-build-commands"] = \ ["mv /etc/resolv.conf.disabled /etc/resolv.conf"] - with tempfile.NamedTemporaryFile(mode="w") as sbuildconf, \ - get_dsc(build) as dscpath: + with contextlib.ExitStack() as stack: + sbuildconf = stack.enter_context(tempfile.NamedTemporaryFile(mode="w")) sbuildconf.write(perl_conf(sbc)) sbuildconf.flush() - proc = subprocess.Popen(["sbuild", str(dscpath.absolute())], + + try: + thing = build["input"]["sourcename"] + with contextlib.suppress(KeyError): + thing += "_" + build["input"]["version"] + except KeyError: + thing = str(stack.enter_context(get_dsc(build)).absolute()) + + proc = subprocess.Popen(["sbuild", thing], env=dict(SBUILD_CONFIG=sbuildconf.name, PATH="/usr/bin:/bin"), cwd=build["output"]["directory"], |