Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/debian/cdbs
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2008-08-16 10:39:21 (GMT)
committer Jonas Smedegaard <dr@jones.dk>2008-08-16 10:43:32 (GMT)
commitb236133f4a3a9cd613059f3516fe0ecb303cb9b8 (patch)
treef9e01d25ca9ecb801d1be85db6b9eaf704daca7d /debian/cdbs
parent81c0f35a037e2214ad368be47885461379e19a27 (diff)
Update cdbs snippets, copyright-hints and dependencies.
* Update cdbs snippets: + Move dependency cleanup to new local snippet package-relations.mk. + Update copyright-check output to more closely match proposed new copyright file format. Update copyright-hints. + Minor improvements to flavor-enhanced autotools- and makefile- snippets. + Update README.cdbs-tweaks. * Add DEB_MAINTAINER_MODE in debian/rules (thanks to Romain Beauxis). * Semi-auto-update debian/control to update dependencies: DEB_MAINTAINER_MODE=1 fakeroot debian/rules clean
Diffstat (limited to 'debian/cdbs')
-rw-r--r--debian/cdbs/1/class/autotools-vars.mk2
-rw-r--r--debian/cdbs/1/class/autotools.mk26
-rw-r--r--debian/cdbs/1/class/makefile-vars.mk14
-rw-r--r--debian/cdbs/1/class/makefile.mk56
-rw-r--r--debian/cdbs/1/rules/copyright-check.mk26
-rw-r--r--debian/cdbs/1/rules/package-relations.mk50
6 files changed, 125 insertions, 49 deletions
diff --git a/debian/cdbs/1/class/autotools-vars.mk b/debian/cdbs/1/class/autotools-vars.mk
index 4b6de38..87e3a3c 100644
--- a/debian/cdbs/1/class/autotools-vars.mk
+++ b/debian/cdbs/1/class/autotools-vars.mk
@@ -28,7 +28,7 @@ _cdbs_class_autotools_vars = 1
#include $(_cdbs_class_path)/makefile.mk$(_cdbs_makefile_suffix)
include debian/cdbs/1/class/makefile.mk
-DEB_MAKE_INSTALL_TARGET = install DESTDIR=$(DEB_DESTDIR)
+DEB_MAKE_INSTALL_TARGET = install DESTDIR=$(cdbs_curpkgdestdir)
DEB_MAKE_CLEAN_TARGET = distclean
#DEB_MAKE_CHECK_TARGET = check
diff --git a/debian/cdbs/1/class/autotools.mk b/debian/cdbs/1/class/autotools.mk
index bcff6e4..98850d7 100644
--- a/debian/cdbs/1/class/autotools.mk
+++ b/debian/cdbs/1/class/autotools.mk
@@ -28,32 +28,28 @@ _cdbs_class_autotools = 1
include debian/cdbs/1/class/autotools-vars.mk
include $(_cdbs_class_path)/autotools-files.mk$(_cdbs_makefile_suffix)
-cdbs_autotools_configure_stamps = $(if $(DEB_MAKE_FLAVORS),$(cdbs_make_builddir_check)$(patsubst %,debian/stamp-autotools-configure/%,$(DEB_MAKE_FLAVORS)),debian/stamp-autotools-configure)
+cdbs_configure_stamps = $(if $(cdbs_make_multibuilds),$(cdbs_make_builddir_check)$(patsubst %,debian/stamp-autotools/%,$(cdbs_make_multibuilds)),debian/stamp-autotools)
# Overriden from makefile-vars.mk. We pass CFLAGS and friends to ./configure, so
# no need to pass them to make.
DEB_MAKE_INVOKE = $(DEB_MAKE_ENVVARS) $(MAKE) -C $(cdbs_make_curbuilddir)
pre-build::
- $(if $(DEB_MAKE_FLAVORS),mkdir -p debian/stamp-autotools-configure)
+ $(if $(cdbs_make_multibuilds),mkdir -p debian/stamp-autotools)
common-configure-arch common-configure-indep:: common-configure-impl
-common-configure-impl:: $(cdbs_autotools_configure_stamps)
-$(cdbs_autotools_configure_stamps):
+common-configure-impl:: $(cdbs_configure_stamps)
+$(cdbs_configure_stamps):
chmod a+x $(DEB_CONFIGURE_SCRIPT)
- mkdir -p $(cdbs_make_curbuilddir)
- $(DEB_CONFIGURE_INVOKE) $(cdbs_autotools_flags) $(DEB_CONFIGURE_EXTRA_FLAGS) $(DEB_CONFIGURE_USER_FLAGS)
+ $(if $(call cdbs_streq,$(cdbs_make_curbuilddir),$(DEB_BUILDDIR_$(cdbs_curpkg))),,mkdir -p $(cdbs_make_curbuilddir))
+ $(DEB_CONFIGURE_INVOKE) $(cdbs_configure_flags) $(DEB_CONFIGURE_EXTRA_FLAGS) $(DEB_CONFIGURE_USER_FLAGS)
$(if $(filter post,$(DEB_AUTO_UPDATE_LIBTOOL)),if [ -e $(cdbs_make_curbuilddir)/libtool ]; then cp -f /usr/bin/libtool $(cdbs_make_curbuilddir)/libtool; fi)
touch $@
-cleanbuilddir:: $(patsubst %,cleanbuilddir/%,$(DEB_MAKE_FLAVORS))
- rm -rf debian/stamp-autotools-configure
-
-DEB_PHONY_RULES += $(patsubst %,cleanbuilddir/%,$(DEB_MAKE_FLAVORS))
-$(patsubst %,cleanbuilddir/%,$(DEB_MAKE_FLAVORS))::
- -rmdir $(cdbs_make_curbuilddir)
-# FIXME: Avoid force-removing!
-# -rm -rf $(cdbs_make_curbuilddir)
- rm -f debian/stamp-autotools-configure/$(cdbs_make_curflavor)
+makefile-clean::
+ $(if $(cdbs_make_multibuilds),-rmdir --ignore-fail-on-non-empty debian/stamp-autotools,rm -f debian/stamp-autotools)
+$(cdbs_make_clean_nonstamps)::
+ $(if $(call cdbs_streq,$(cdbs_make_curbuilddir),$(DEB_BUILDDIR_$(cdbs_curpkg))),,-rmdir --ignore-fail-on-non-empty $(cdbs_make_curbuilddir))
+ $(if $(cdbs_make_multibuilds),rm -f $(@:makefile-clean%=debian/stamp-autotools%))
endif
diff --git a/debian/cdbs/1/class/makefile-vars.mk b/debian/cdbs/1/class/makefile-vars.mk
index 1719791..d731493 100644
--- a/debian/cdbs/1/class/makefile-vars.mk
+++ b/debian/cdbs/1/class/makefile-vars.mk
@@ -42,6 +42,8 @@ DEB_MAKE_BUILD_TARGET = $(DEB_BUILD_MAKE_TARGET)
# looks like: install DESTDIR=$(DEB_DESTDIR)
# If you're using automake though, you likely want to be including autotools.mk instead
# of this file.
+# For multi-flavored builds (see below) installed per-flavor, it looks like this:
+# install DESTDIR=$(cdbs_curpkgdestdir)
# This variable is deprecated.
DEB_CLEAN_MAKE_TARGET = clean
@@ -57,8 +59,14 @@ _cdbs_deprecated_vars += DEB_MAKE_TEST_TARGET
# New in 0.4.2.
DEB_MAKE_CHECK_TARGET = $(DEB_MAKE_TEST_TARGET)
-# NB! This needs to be declared _before_ including makefile
-#DEB_MAKE_FLAVORS =
-DEB_MAKE_FLAVORS_BUILDDIRSKEL = $(DEB_BUILDDIR)/@FLAVOR@
+# If DEB_MAKE_FLAVORS is set compilation is done once per flavor.
+# NB! This must be declared _before_ including makefile.mk
+#DEB_MAKE_FLAVORS = light normal enhanced
+
+# If building multiple flavors, skeleton strings are used for
+# DEB_BUILDDIR and DEB_DESTDIR, with @FLAVOR@ expanding to actual
+# flavor.
+DEB_MAKE_BUILDDIRSKEL = $(cdbs_curpkgbuilddir)/@FLAVOR@
+DEB_MAKE_DESTDIRSKEL = $(cdbs_curpkgdestdir)/@FLAVOR@
endif
diff --git a/debian/cdbs/1/class/makefile.mk b/debian/cdbs/1/class/makefile.mk
index 7f931ec..2f4e98f 100644
--- a/debian/cdbs/1/class/makefile.mk
+++ b/debian/cdbs/1/class/makefile.mk
@@ -29,51 +29,55 @@ include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
#include $(_cdbs_class_path)/makefile-vars.mk$(_cdbs_makefile_suffix)
include debian/cdbs/1/class/makefile-vars.mk
-DEB_PHONY_RULES += makefile-clean
-
-# TODO: Move this to buildvars.mk
+# TODO: Move these to buildcore.mk
cdbs_curpkgbuilddir = $(if $(DEB_BUILDDIR_$(cdbs_curpkg)),$(DEB_BUILDDIR_$(cdbs_curpkg)),$(DEB_BUILDDIR))
-
+cdbs_curpkgdestdir = $(if $(DEB_DESTDIR_$(cdbs_curpkg)),$(DEB_DESTDIR_$(cdbs_curpkg)),$(DEB_DESTDIR))
+
+cdbs_make_multibuilds = $(sort $(DEB_MAKE_FLAVORS))
cdbs_make_builddir_check = $(if $(call cdbs_streq,$(DEB_BUILDDIR),$(DEB_SRCDIR)),$(error DEB_MAKE_FLAVORS in use: DEB_BUILDDIR must be different from DEB_SRCDIR, and needs to be declared before including makefile.mk))
-cdbs_make_build_targets = $(if $(DEB_MAKE_FLAVORS),$(cdbs_make_builddir_check)$(patsubst %,debian/stamp-makefile-build/%,$(DEB_MAKE_FLAVORS)),debian/stamp-makefile-build)
-cdbs_make_install_targets = $(if $(DEB_MAKE_FLAVORS),$(cdbs_make_builddir_check)$(patsubst %,debian/stamp-makefile-install/%,$(DEB_MAKE_FLAVORS)),debian/stamp-makefile-install)
-cdbs_make_check_targets = $(if $(DEB_MAKE_FLAVORS),$(cdbs_make_builddir_check)$(patsubst %,debian/stamp-makefile-check/%,$(DEB_MAKE_FLAVORS)),debian/stamp-makefile-check)
-cdbs_make_clean_targets = $(if $(DEB_MAKE_CLEAN_TARGET),$(if $(DEB_MAKE_FLAVORS),$(patsubst %,makefile-clean/%,$(DEB_MAKE_FLAVORS)),makefile-clean))
-cdbs_make_curflavor = $(notdir $@)
-cdbs_make_curbuilddir = $(if $(DEB_MAKE_FLAVORS),$(subst @FLAVOR@,$(cdbs_make_curflavor),$(DEB_MAKE_FLAVORS_BUILDDIRSKEL)),$(cdbs_curpkgbuilddir))
+cdbs_make_build_stamps = $(if $(cdbs_make_multibuilds),$(cdbs_make_builddir_check)$(patsubst %,debian/stamp-makefile-build/%,$(cdbs_make_multibuilds)),debian/stamp-makefile-build)
+cdbs_make_install_stamps = $(if $(cdbs_make_multibuilds),$(cdbs_make_builddir_check)$(patsubst %,debian/stamp-makefile-install/%,$(cdbs_make_multibuilds)),debian/stamp-makefile-install)
+cdbs_make_check_stamps = $(if $(cdbs_make_multibuilds),$(cdbs_make_builddir_check)$(patsubst %,debian/stamp-makefile-check/%,$(cdbs_make_multibuilds)),debian/stamp-makefile-check)
+cdbs_make_clean_nonstamps = $(if $(cdbs_make_multibuilds),$(patsubst %,makefile-clean/%,$(cdbs_make_multibuilds)),makefile-clean)
+cdbs_make_curflavor = $(filter-out %/,$(subst /,/ ,$@))
+cdbs_make_curbuilddir = $(if $(cdbs_make_multibuilds),$(subst @FLAVOR@,$(cdbs_make_curflavor),$(DEB_MAKE_BUILDDIRSKEL)),$(cdbs_curpkgbuilddir))
+
+DEB_PHONY_RULES += makefile-clean $(cdbs_make_clean_nonstamps)
pre-build::
- $(if $(DEB_MAKE_FLAVORS),mkdir -p debian/stamp-makefile-build debian/stamp-makefile-install)
- $(if $(and $(DEB_MAKE_FLAVORS),$(DEB_MAKE_CHECK_TARGET)),mkdir -p debian/stamp-makefile-check)
+ $(if $(cdbs_make_multibuilds),mkdir -p debian/stamp-makefile-build debian/stamp-makefile-install)
+ $(and $(cdbs_make_multibuilds),$(not $(findstring nocheck,$(DEB_BUILD_OPTIONS))),$(DEB_MAKE_CHECK_TARGET),mkdir -p debian/stamp-makefile-check)
-common-build-arch common-build-indep:: $(cdbs_make_build_targets)
-$(cdbs_make_build_targets):
+common-build-arch common-build-indep:: $(cdbs_make_build_stamps)
+$(cdbs_make_build_stamps):
+$(DEB_MAKE_INVOKE) $(DEB_MAKE_BUILD_TARGET)
touch $@
cleanbuilddir:: makefile-clean
-makefile-clean:: $(cdbs_make_clean_targets)
- $(if $(DEB_MAKE_CLEAN_TARGET),,@echo "DEB_MAKE_CLEAN_TARGET unset, not running clean")
- rm -rf debian/stamp-makefile-build debian/stamp-makefile-install
+makefile-clean:: $(if $(cdbs_make_multibuilds),$(cdbs_make_clean_nonstamps))
+ $(if $(cdbs_make_multibuilds),-rmdir --ignore-fail-on-non-empty debian/stamp-makefile-build debian/stamp-makefile-install,rm -f debian/stamp-makefile-build debian/stamp-makefile-install)
-DEB_PHONY_RULES += makefile-clean $(cdbs_make_clean_targets)
-$(cdbs_make_clean_targets)::
- +-$(DEB_MAKE_INVOKE) -k $(DEB_MAKE_CLEAN_TARGET)
+$(cdbs_make_clean_nonstamps)::
+ $(if $(DEB_MAKE_CLEAN_TARGET),+-$(DEB_MAKE_INVOKE) -k $(DEB_MAKE_CLEAN_TARGET),@echo "DEB_MAKE_CLEAN_TARGET unset, not running clean")
+ $(if $(cdbs_make_multibuilds),rm -f $(@:makefile-clean%=debian/stamp-makefile-build%) $(@:makefile-clean%=debian/stamp-makefile-install%))
common-install-arch common-install-indep:: common-install-impl
-common-install-impl:: $(cdbs_make_install_targets)
-$(cdbs_make_install_targets):
+common-install-impl:: $(cdbs_make_install_stamps)
+$(cdbs_make_install_stamps)::
$(if $(DEB_MAKE_INSTALL_TARGET),+$(DEB_MAKE_INVOKE) $(DEB_MAKE_INSTALL_TARGET),@echo "DEB_MAKE_INSTALL_TARGET unset, skipping default makefile.mk common-install target")
$(if $(DEB_MAKE_INSTALL_TARGET),touch $@)
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
-common-build-arch common-build-indep:: $(cdbs_make_check_targets)
-$(cdbs_make_check_targets) : debian/stamp-makefile-check% : debian/stamp-makefile-build%
+common-build-arch common-build-indep:: $(cdbs_make_check_stamps)
+$(cdbs_make_check_stamps) : debian/stamp-makefile-check% : debian/stamp-makefile-build%
$(if $(DEB_MAKE_CHECK_TARGET),+$(DEB_MAKE_INVOKE) $(DEB_MAKE_CHECK_TARGET),@echo "DEB_MAKE_CHECK_TARGET unset, not running checks")
$(if $(DEB_MAKE_CHECK_TARGET),touch $@)
-clean::
- rm -rf debian/stamp-makefile-check
+makefile-clean::
+ $(if $(DEB_MAKE_CHECK_TARGET),rm -f debian/stamp-makefile-check)
+
+$(cdbs_make_clean_nonstamps)::
+ $(if $(cdbs_make_multibuilds),rm -f $(@:makefile-clean%=debian/stamp-makefile-check%))
endif
endif
diff --git a/debian/cdbs/1/rules/copyright-check.mk b/debian/cdbs/1/rules/copyright-check.mk
index 645363b..d96681a 100644
--- a/debian/cdbs/1/rules/copyright-check.mk
+++ b/debian/cdbs/1/rules/copyright-check.mk
@@ -28,6 +28,9 @@ include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), devscripts (>= 2.10.7)
+# Set to yes to fail on changed/new hints are found
+#DEB_COPYRIGHT_CHECK_STRICT := yes
+
# Single regular expression for files to include or ignore
DEB_COPYRIGHT_CHECK_REGEX = .*
DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^(debian/.*|(.*/)?config\.(guess|sub|rpath)(\..*)?)$
@@ -35,13 +38,17 @@ DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^(debian/.*|(.*/)?config\.(guess|sub|rpath)(\
pre-build:: debian/stamp-copyright-check
debian/stamp-copyright-check:
- @echo 'Scanning upstream source for new/changed copyright notices (except debian subdir!)...'
+ @echo 'Scanning upstream source for new/changed copyright notices...'
+ @echo licensecheck -c '$(DEB_COPYRIGHT_CHECK_REGEX)' -r --copyright -i '$(DEB_COPYRIGHT_CHECK_IGNORE_REGEX)' * \
+ "| some-output-filtering..."
# Perl in shell in make requires extra care:
# * Single-quoting ('...') protects against shell expansion
# * Double-dollar ($$) expands to plain dollar ($) in make
- licensecheck -c '$(DEB_COPYRIGHT_CHECK_REGEX)' -r --copyright -i '$(DEB_COPYRIGHT_CHECK_IGNORE_REGEX)' * \
+ @licensecheck -c '$(DEB_COPYRIGHT_CHECK_REGEX)' -r --copyright -i '$(DEB_COPYRIGHT_CHECK_IGNORE_REGEX)' * \
| LC_ALL=C perl -e \
+ 'print "Format-Specification: http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=XXX\n";'\
+ 'print "Upstream-Name: Untrusted draft - double-check copyrights yourself!\n\n";'\
'$$n=0; while (<>) {'\
' s/[^[:print:]]//g;'\
' if (/^([^:\s][^:]+):[\s]+(\S.*?)\s*$$/) {'\
@@ -56,8 +63,15 @@ debian/stamp-copyright-check:
'foreach $$file (@files) {'\
' $$file->{license} =~ s/\s*\(with incorrect FSF address\)//;'\
' $$file->{license} =~ s/\s+\(v([^)]+) or later\)/-$$1+/;'\
+ ' $$file->{license} =~ s/\s*(\*No copyright\*)\s*// and $$file->{copyright} = $$1;'\
+ ' $$file->{license} =~ s/^\s*(GENERATED FILE)/UNKNOWN ($$1)/;'\
+ ' $$file->{license} =~ s/\s+(GENERATED FILE)/ ($$1)/;'\
' $$file->{copyright} =~ s/(?<=(\b\d{4}))(?{$$y=$$^N})\s*[,-]\s*((??{$$y+1}))\b/-$$2/g;'\
' $$file->{copyright} =~ s/(?<=\b\d{4})\s*-\s*\d{4}(?=\s*-\s*(\d{4})\b)//g;'\
+ ' $$file->{copyright} =~ s/\b(\d{4})\s+([\S^\d])/$$1, $$2/g;'\
+ ' $$file->{copyright} =~ s/^\W*\s+\/\s+//g;'\
+ ' $$file->{copyright} =~ s/\s+\/\s+\W*$$//;'\
+ ' $$file->{copyright} =~ s/\s+\/\s+/\n\t/g;'\
' $$pattern = "$$file->{license} [$$file->{copyright}]";'\
' push @{ $$patternfiles{"$$pattern"} }, $$file->{name};'\
'};'\
@@ -66,7 +80,10 @@ debian/stamp-copyright-check:
' ||'\
' $$a cmp $$b'\
' } keys %patternfiles ) {'\
- ' print "$$pattern: ", join("\n\t", sort @{ $$patternfiles{$$pattern} }), "\n";'\
+ ' ($$license, $$copyright) = $$pattern =~ /(.*) \[(.*)\]/s;'\
+ ' print "Files: ", join("\n\t", sort @{ $$patternfiles{$$pattern} }), "\n";'\
+ ' print "Copyright: $$copyright\n";'\
+ ' print "License: $$license\n\n";'\
'};'\
> debian/copyright_newhints
@patterncount="`cat debian/copyright_newhints | sed 's/^[^:]*://' | LANG=C sort -u | grep . -c -`"; \
@@ -74,13 +91,14 @@ debian/stamp-copyright-check:
@if [ ! -f debian/copyright_hints ]; then touch debian/copyright_hints; fi
@newstrings=`diff -u debian/copyright_hints debian/copyright_newhints | sed '1,2d' | egrep '^\+' - | sed 's/^\+//'`; \
if [ -n "$$newstrings" ]; then \
- echo "WARNING: The following new or changed copyright notices discovered:"; \
+ echo "$(if $(DEB_COPYRIGHT_CHECK_STRICT),ERROR,WARNING): The following new or changed copyright notices discovered:"; \
echo; \
echo "$$newstrings"; \
echo; \
echo "To fix the situation please do the following:"; \
echo " 1) Investigate the above changes and update debian/copyright as needed"; \
echo " 2) Replace debian/copyright_hints with debian/copyright_newhints"; \
+ $(if $(DEB_COPYRIGHT_CHECK_STRICT),exit 1,:); \
else \
echo 'No new copyright notices found - assuming no news is good news...'; \
rm -f debian/copyright_newhints; \
diff --git a/debian/cdbs/1/rules/package-relations.mk b/debian/cdbs/1/rules/package-relations.mk
new file mode 100644
index 0000000..3a92eb7
--- /dev/null
+++ b/debian/cdbs/1/rules/package-relations.mk
@@ -0,0 +1,50 @@
+# -*- mode: makefile; coding: utf-8 -*-
+# Copyright © 2004-2006 Jonas Smedegaard <dr@jones.dk>
+# Description: Resolve, cleanup and apply package relationships
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2, or (at
+# your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+_cdbs_scripts_path ?= /usr/lib/cdbs
+_cdbs_rules_path ?= /usr/share/cdbs/1/rules
+_cdbs_class_path ?= /usr/share/cdbs/1/class
+
+ifndef _cdbs_rules_package_relations
+_cdbs_rules_package_relations = 1
+
+include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
+
+# Merge build-dependencies on same packages
+# TODO: rewrite (in perl, probably) to be more generic
+CDBS_BUILD_DEPENDS := $(shell echo '$(CDBS_BUILD_DEPENDS)' | sed -e '/\bcdbs (>= 0.4.43)/ s/ *,* *\bcdbs (>= \(0.4.23-1.1\|0.4.27\|0.4.39\)) *,* */, /g')
+CDBS_BUILD_DEPENDS := $(shell echo '$(CDBS_BUILD_DEPENDS)' | sed -e '/\bcdbs (>= 0.4.39)/ s/ *,* *\bcdbs (>= \(0.4.23-1.1\|0.4.27\)) *,* */, /g')
+CDBS_BUILD_DEPENDS := $(shell echo '$(CDBS_BUILD_DEPENDS)' | sed -e '/\bcdbs (>= 0.4.27)/ s/ *,* *\bcdbs (>= \(0.4.23-1.1\)) *,* */, /g')
+CDBS_BUILD_DEPENDS := $(shell echo '$(CDBS_BUILD_DEPENDS)' | sed -e '/\bdebhelper (>= 5.0.44)/ s/ *,* *\bdebhelper (>= \(4.1.60\|4.2.0\|4.2.21\|4.2.28\|5\|5.0.37.2\)) *,* */, /g')
+CDBS_BUILD_DEPENDS := $(shell echo '$(CDBS_BUILD_DEPENDS)' | sed -e '/\bdebhelper (>= 5.0.37.2)/ s/ *,* *\bdebhelper (>= \(4.1.60\|4.2.0\|4.2.21\|4.2.28\|5\)) *,* */, /g')
+CDBS_BUILD_DEPENDS := $(shell echo '$(CDBS_BUILD_DEPENDS)' | sed -e '/\bdebhelper (>= 5)/ s/ *,* *\bdebhelper (>= \(4.1.60\|4.2.0\|4.2.21\|4.2.28\)) *,* */, /g')
+CDBS_BUILD_DEPENDS := $(shell echo '$(CDBS_BUILD_DEPENDS)' | sed -e '/\bdebhelper (>= 4.2.28)/ s/ *,* *\bdebhelper (>= \(4.1.60\|4.2.0\|4.2.21\)) *,* */, /g')
+CDBS_BUILD_DEPENDS := $(shell echo '$(CDBS_BUILD_DEPENDS)' | sed -e '/\bdebhelper (>= 4.2.21)/ s/ *,* *\bdebhelper (>= \(4.1.60\|4.2.0\)) *,* */, /g')
+CDBS_BUILD_DEPENDS := $(shell echo '$(CDBS_BUILD_DEPENDS)' | sed -e '/\bdebhelper (>= 4.2.0)/ s/ *,* *\bdebhelper (>= \(4.1.60\)) *,* */, /g')
+
+# Cleanup superfluous commas
+CDBS_BUILD_DEPENDS := $(shell echo '$(CDBS_BUILD_DEPENDS)' | sed -e 's/ *,/,/g' -e 's/^ *, *//' -e 's/ *, *$$//')
+
+# Apply CDBS-declared dependencies to binary packages
+$(patsubst %,binary-predeb/%,$(DEB_PACKAGES)) :: binary-predeb/%:
+ echo 'cdbs:Depends=$(CDBS_DEPENDS_ALL), $(or $(CDBS_DEPENDS_$(cdbs_curpkg)),$(CDBS_DEPENDS))' \
+ | sed -e 's/ *,/,/g' -e 's/^ *, *//' -e 's/ *, *$$//' \
+ >> debian/$(cdbs_curpkg).substvars
+
+endif