summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2021-05-18 18:25:18 +0200
committerHelmut Grohne <helmut@subdivi.de>2021-05-18 18:25:18 +0200
commit43b4aafecbe355a72aed4ef2819423e7e8d8e600 (patch)
treec80a6cf92bf145de164f9b066a504e737b9d5f5b
parentb6f54633e5b4cafa851fdec80e8e982d46109be3 (diff)
downloadmdbp-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.
-rw-r--r--mdbp/build_schema.json15
-rw-r--r--mdbp/mmdebstrap.py16
-rw-r--r--mdbp/pbuilder.py2
-rw-r--r--mdbp/sbuild.py14
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"],