From db8e7a2186e5f33e0e1665653f3b480b5e3986d9 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 11 Sep 2018 00:59:07 +0100 Subject: [PATCH] Add support for specifying build-dependencies in binary package templates This will allow removing a lot of the repetition introduced in the preceding commits. --- debian/README.source | 8 ++++++ debian/changelog | 1 + debian/lib/python/debian_linux/gencontrol.py | 29 ++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/debian/README.source b/debian/README.source index 5131e29bd..06fe9115c 100644 --- a/debian/README.source +++ b/debian/README.source @@ -189,6 +189,14 @@ into the templates: Normally, the arch-specific contents should be controlled by adjusting the corresponding defines file. +Build-dependencies that relate to specific binary packages can be +specified in a Build-Depends field in the template for that binary +package. gencontrol.py will append the value to the source package's +Build-Depends-Arch or Build-Depends-Indep field, as appropriate. It +will also use the binary package's Architecture and Build-Profile as +the architecture-qualification and/or restriction for each build- +dependency that doesn't already have them. + TODO: - Patches applied to the upstream source - How to define a flavour diff --git a/debian/changelog b/debian/changelog index ca13dc57e..042c9e6f3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,7 @@ linux (4.19~rc3-1~exp2) UNRELEASED; urgency=medium * debian/lib/python: Use raw strings for all regexes * debian/control: Fix restrictions for build-deps on asciidoctor and patchutils + * Add support for specifying build-dependencies in binary package templates -- Ben Hutchings Mon, 10 Sep 2018 22:25:53 +0100 diff --git a/debian/lib/python/debian_linux/gencontrol.py b/debian/lib/python/debian_linux/gencontrol.py index b4764e244..c46f9991d 100644 --- a/debian/lib/python/debian_linux/gencontrol.py +++ b/debian/lib/python/debian_linux/gencontrol.py @@ -91,6 +91,7 @@ class Gencontrol(object): self.do_main(packages, makefile) self.do_extra(packages, makefile) + self.merge_build_depends(packages) self.write(packages, makefile) def do_source(self, packages): @@ -313,6 +314,34 @@ class Gencontrol(object): return re.sub(r'@([-_a-z0-9]+)@', subst, str(s)) + def merge_build_depends(self, packages): + # Merge Build-Depends pseudo-fields from binary packages into the + # source package + source = packages["source"] + arch_all = PackageArchitecture("all") + for name, package in packages.items(): + if name == "source": + continue + dep = package.get("Build-Depends") + if not dep: + continue + del package["Build-Depends"] + for group in dep: + for item in group: + if package["Architecture"] != arch_all and not item.arches: + item.arches = sorted(package["Architecture"]) + if package.get("Build-Profiles") and not item.restrictions: + profiles = package["Build-Profiles"] + assert profiles[0] == "<" and profiles[-1] == ">" + item.restrictions = re.split(r"\s+", profiles[1:-1]) + if package["Architecture"] == arch_all: + dep_type = "Build-Depends-Indep" + else: + dep_type = "Build-Depends-Arch" + if dep_type not in source: + source[dep_type] = PackageRelation() + source[dep_type].extend(dep) + def write(self, packages, makefile): self.write_control(packages.values()) self.write_makefile(makefile)