diff options
author | Helmut Grohne <helmut@subdivi.de> | 2021-05-18 18:25:18 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2021-05-18 18:25:18 +0200 |
commit | 43b4aafecbe355a72aed4ef2819423e7e8d8e600 (patch) | |
tree | c80a6cf92bf145de164f9b066a504e737b9d5f5b /mdbp/mmdebstrap.py | |
parent | b6f54633e5b4cafa851fdec80e8e982d46109be3 (diff) | |
download | mdbp-43b4aafecbe355a72aed4ef2819423e7e8d8e600.tar.gz |
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.
Diffstat (limited to 'mdbp/mmdebstrap.py')
-rw-r--r-- | mdbp/mmdebstrap.py | 16 |
1 files changed, 14 insertions, 2 deletions
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, |