From 43b4aafecbe355a72aed4ef2819423e7e8d8e600 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Tue, 18 May 2021 18:25:18 +0200 Subject: enable building a source package by name and version If a package is specified by name, it is downloaded inside the chroot using the embedded deb-src uris. sbuild implements this natively, pbuilder does not implement this yet, but there is #988419 and mmdebstrap can make it work. --- mdbp/mmdebstrap.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'mdbp/mmdebstrap.py') 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, -- cgit v1.2.3