--- /dev/null
+# -*- mode: makefile; coding: utf-8 -*-
+# Copyright © 2007-2008 Anders Kaseorg <andersk@mit.edu> and
+# Tim Abbott <tabbott@mit.edu>
+#
+# 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.
+
+ifndef _cdbs_rules_check_files
+_cdbs_rules_check_files = 1
+
+include /usr/share/cdbs/1/rules/divert.mk
+
+DEB_CHECK_FILES_DIR = debian/check_file_copies
+
+debian_check_files_source = $(if $(DEB_CHECK_FILES_SOURCE_$(1)),$(DEB_CHECK_FILES_SOURCE_$(1)),$(1))
+debian_check_files_check = $(subst $(DEB_DIVERT_EXTENSION),,$(call debian_check_files_source,$(1)))
+
+debian_check_files = $(patsubst %,$(DEB_CHECK_FILES_DIR)%,$(1))
+undebian_check_files = $(patsubst $(DEB_CHECK_FILES_DIR)%,%,$(1))
+
+debian_check_files_tmp = $(patsubst %,%.tmp,$(call debian_check_files,$(1)))
+undebian_check_files_tmp = $(call undebian_check_files,$(patsubst %.tmp,%,$(1)))
+
+$(call debian_check_files,%): $(call debian_check_files_tmp,%)
+ mv $< $@
+
+$(call debian_check_files_tmp,%): target = $(call undebian_check_files_tmp,$@)
+$(call debian_check_files_tmp,%): name = $(call debian_check_files_check,$(target))
+$(call debian_check_files_tmp,%): truename = $(shell /usr/sbin/dpkg-divert --truename $(name))
+$(call debian_check_files_tmp,%): package = $(shell dpkg -S $(name) | grep -v "^diversion by" | cut -f1 -d:)
+$(call debian_check_files_tmp,%): $(truename)
+ [ -n $(package) ]
+ mkdir -p $(@D)
+ cp "$(truename)" $@
+ md5=$$(dpkg-query --showformat='$${Conffiles}\n' --show $(package) | \
+ sed -n 's,^ $(name) \([0-9a-f]*\)$$,\1 $@, p'); \
+ if [ -n "$$md5" ]; then \
+ echo "$$md5" | md5sum -c; \
+ elif [ -e /var/lib/dpkg/info/$(package).md5sums ]; then \
+ md5=$$(sed -n 's,^\([0-9a-f]*\) $(patsubst /%,%,$(name))$$,\1 $@, p' \
+ /var/lib/dpkg/info/$(package).md5sums); \
+ [ -n "$$md5" ] && echo "$$md5" | md5sum -c; \
+ else \
+ echo "warning: $(package) does not include md5sums!"; \
+ echo "warning: md5sum for $(name) not verified."; \
+ fi
+
+clean::
+ rm -rf $(DEB_CHECK_FILES_DIR)
+
+endif
--- /dev/null
+# -*- mode: makefile; coding: utf-8 -*-
+# Copyright © 2007-2008 Anders Kaseorg <andersk@mit.edu> and
+# Tim Abbott <tabbott@mit.edu>
+#
+# 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.
+
+ifndef _cdbs_rules_debconf_divert
+_cdbs_rules_debconf_divert = 1
+
+CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), config-package-dev (>= 3.2~)
+
+DEB_DEBCONF_HACK_SCRIPT = /usr/share/config-package-dev/debconf-hack.sh
+
+DEB_DEBCONF_HACK_PACKAGES += $(foreach package,$(DEB_ALL_PACKAGES), \
+ $(if $(wildcard debian/$(package).debconf-hack),$(package)))
+
+$(patsubst %,debian-debconf-hack/%,$(DEB_DEBCONF_HACK_PACKAGES)) :: debian-debconf-hack/%:
+ ( \
+ cat $(DEB_DEBCONF_HACK_SCRIPT); \
+ echo 'if [ ! -f /var/cache/$(cdbs_curpkg).debconf-save ]; then'; \
+ echo ' debconf_get $(shell cut -d' ' -f2 debian/$(cdbs_curpkg).debconf-hack) >/var/cache/$(cdbs_curpkg).debconf-save'; \
+ echo ' debconf_set <<EOF'; \
+ sed 's/$$/ true/' debian/$(cdbs_curpkg).debconf-hack; \
+ echo 'EOF'; \
+ echo 'fi'; \
+ ) >> $(CURDIR)/debian/$(cdbs_curpkg).preinst.debhelper
+ ( \
+ cat $(DEB_DEBCONF_HACK_SCRIPT); \
+ echo 'if [ -f /var/cache/$(cdbs_curpkg).debconf-save ]; then'; \
+ echo ' debconf_set </var/cache/$(cdbs_curpkg).debconf-save'; \
+ echo ' rm -f /var/cache/$(cdbs_curpkg).debconf-save'; \
+ echo 'fi'; \
+ ) >> $(CURDIR)/debian/$(cdbs_curpkg).postinst.debhelper
+ ( \
+ cat $(DEB_DEBCONF_HACK_SCRIPT); \
+ echo 'if [ -f /var/cache/$(cdbs_curpkg).debconf-save ]; then'; \
+ echo ' debconf_set </var/cache/$(cdbs_curpkg).debconf-save'; \
+ echo ' rm -f /var/cache/$(cdbs_curpkg).debconf-save'; \
+ echo 'fi'; \
+ ) >> $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper
+
+$(patsubst %,binary-fixup/%,$(DEB_DEBCONF_HACK_PACKAGES)) :: binary-fixup/%: debian-debconf-hack/%
+
+endif
--- /dev/null
+debconf_get () {
+ perl -MDebconf::Db -MDebconf::Question -e '
+ Debconf::Db->load(readonly => "true");
+ for $label (@ARGV) {
+ if ($q = Debconf::Question->get($label)) {
+ print $q->owners."\t".$q->name."\t".$q->type."\t".$q->value."\t".$q->flag("seen")."\n";
+ } else {
+ print "\t$label\t\t\tfalse\n";
+ }
+ }' -- "$@"
+}
+
+debconf_set () {
+ perl -MDebconf::Db -MDebconf::Template -MDebconf::Question -e '
+ Debconf::Db->load;
+ while (<>) {
+ chomp;
+ ($owners, $label, $type, $value, $seen) = split("\t");
+ @o{split(", ", $owners)} = ();
+ unless ($t = Debconf::Template->get($label)) {
+ next unless ($owners);
+ $t = Debconf::Template->new($label, $owners[0], $type);
+ $t->description("Dummy template");
+ $t->extended_description("This is a fake template used to pre-seed the debconf database. If you are seeing this, something is probably wrong.");
+ }
+ @to{split(", ", $t->owners)} = ();
+ map { $t->addowner($_) unless exists $to{$_}; } keys %o;
+ map { $t->removeowner($_) unless exists $o{$_}; } keys %to;
+ next unless ($q = Debconf::Question->get($label));
+ $q->value($value);
+ $q->flag("seen", $seen);
+ @qo{split(", ", $q->owners)} = ();
+ map { $q->addowner($_) unless exists $qo{$_}; } keys %o;
+ map { $q->removeowner($_) unless exists $o{$_}; } keys %qo;
+ }
+ Debconf::Db->save;'
+}
--- /dev/null
+config-package-dev (4.2) unstable; urgency=low
+
+ * Rename DEB_REPLACE_FILES_SOURCE to DEB_CHECK_FILES_SOURCE, and
+ move it to check-files.mk, since it really is a check-files.mk
+ feature.
+ * Make check-files.mk include divert.mk.
+ * Don't directly include divert.mk in replace-files.mk.
+
+ -- Tim Abbott <tabbott@mit.edu> Sun, 17 Feb 2008 23:01:08 -0500
+
+config-package-dev (4.1) unstable; urgency=low
+
+ * Rename various API variables to make interface cleaner.
+ * Rename variables involving DEBIAN to DEB in variable names.
+ * Rename CONFFILES to FILES in variable names.
+ * Rename divert:Diverted to divert:Files
+ * Replace DEB_CONFFILE_DEST with DEB_REPLACE_FILES_SOURCE, changing the
+ source rather than the destination.
+ * Rename replace-conffiles.mk and check-conffiles.mk to *-files.mk.
+ * Add support for multiple files with same basename to replace_files.mk
+ via the DEB_TRANSFORM_SCRIPT variable.
+ * Remove deprecated check-files interface.
+ * Rename DEB_DIVERT_SUFFIX to DEB_DIVERT_EXTENSION.
+
+ -- Tim Abbott <tabbott@mit.edu> Mon, 4 Feb 2008 02:07:16 -0500
+
+config-package-dev (4.0) unstable; urgency=low
+
+ * Rename variables to be appropriate for non-MIT sites.
+
+ -- Tim Abbott <tabbott@mit.edu> Thu, 31 Jan 2008 15:15:20 -0500
+
+debathena-config-build-common (3.6) unstable; urgency=low
+
+ * Add new debathena-replace-conffiles.mk, a more user-friendly wrapper
+ for debathena-check-conffiles.mk and debathena-divert.mk.
+ * Change debathena-check-conffiles.mk to allow checking md5sums of
+ packaged files which are not marked as configuration files
+ (e.g. /etc/adduser/adduser.conf).
+ * Change debathena-divert.mk to not set DEBATHENA_DIVERT_SUFFIX unless
+ it is not already set.
+ * Change debathena-divert.mk to support adding Provides: and Conflicts:
+ lines for each diverted configuration file.
+ * Change debathena-divert.mk to divert everything in
+ DEBATHENA_REPLACE_CONFFILES.
+
+ -- Tim Abbott <tabbott@mit.edu> Wed, 30 Jan 2008 20:03:36 -0500
+
+debathena-config-build-common (3.5) unstable; urgency=low
+
+ * Change check-conffiles interface to make it work properly with
+ dpkg-diverted files.
+
+ -- Anders Kaseorg <andersk@mit.edu> Mon, 13 Aug 2007 17:59:43 -0400
+
+debathena-config-build-common (3.4) unstable; urgency=low
+
+ * Need [ -e ] || [ -L ] to check for existence, instead of just [ -e ].
+
+ -- Anders Kaseorg <andersk@mit.edu> Mon, 06 Aug 2007 06:57:18 -0400
+
+debathena-config-build-common (3.3) unstable; urgency=low
+
+ * Add check-conffiles script.
+
+ -- Anders Kaseorg <andersk@mit.edu> Fri, 03 Aug 2007 17:50:20 -0400
+
+debathena-config-build-common (3.2) unstable; urgency=low
+
+ * Add debconf-hack script.
+
+ -- Anders Kaseorg <andersk@mit.edu> Tue, 24 Jul 2007 20:41:13 -0400
+
+debathena-config-build-common (3.1) unstable; urgency=low
+
+ * Divert with the current package name, not the empty string.
+ * Add this package as an automatic build dependency of anything that
+ uses it.
+
+ -- Anders Kaseorg <andersk@mit.edu> Wed, 18 Jul 2007 01:13:40 -0400
+
+debathena-config-build-common (3.0debathena1) unstable; urgency=low
+
+ * Fix divert script version.
+
+ -- Anders Kaseorg <andersk@mit.edu> Fri, 13 Jul 2007 15:57:19 -0400
+
+debathena-config-build-common (3.0) unstable; urgency=low
+
+ * Initial release.
+
+ -- Anders Kaseorg <andersk@mit.edu> Fri, 06 Jul 2007 19:30:41 -0400
--- /dev/null
+divert.mk usr/share/cdbs/1/rules/
+debconf-divert.mk usr/share/cdbs/1/rules/
+check-files.mk usr/share/cdbs/1/rules/
+replace-files.mk usr/share/cdbs/1/rules/
+encode usr/share/config-package-dev/
+divert.sh.in usr/share/config-package-dev/
+debconf-hack.sh usr/share/config-package-dev/
--- /dev/null
+Source: config-package-dev
+Section: devel
+Priority: extra
+Maintainer: Debian-Athena Project <debathena@mit.edu>
+Build-Depends: cdbs (>= 0.4.23-1.1), debhelper (>= 4.2.0)
+Standards-Version: 3.7.2
+
+Package: config-package-dev
+Architecture: all
+Depends: cdbs, ${misc:Depends}
+Description: CDBS modules for building configuration packages
+ This package contains a system of CDBS modules for creating Debian
+ configuration packages: packages that configure an existing Debian
+ system by using dpkg-divert on configuration files. These modules
+ attempt to make the process of creating configuration packages
+ efficient by checking the md5sums of upstream configuration files
+ that are to be modified and automatically generating the relevant
+ postinst code to perform the diversions using the standard debhelper
+ mechanism.
+ .
+ The config-package-dev modules are optimized for site defaults (i.e.
+ configuration for a university or a company), though they are useful
+ for other applications as well.
+ .
+ Homepage: http://debathena.mit.edu/config-packages/
--- /dev/null
+Source: config-package-dev
+Section: devel
+Priority: extra
+Maintainer: Debian-Athena Project <debathena@mit.edu>
+Build-Depends: @cdbs@
+Standards-Version: 3.7.2
+
+Package: config-package-dev
+Architecture: all
+Depends: cdbs, ${misc:Depends}
+Description: CDBS modules for building configuration packages
+ This package contains a system of CDBS modules for creating Debian
+ configuration packages: packages that configure an existing Debian
+ system by using dpkg-divert on configuration files. These modules
+ attempt to make the process of creating configuration packages
+ efficient by checking the md5sums of upstream configuration files
+ that are to be modified and automatically generating the relevant
+ postinst code to perform the diversions using the standard debhelper
+ mechanism.
+ .
+ The config-package-dev modules are optimized for site defaults (i.e.
+ configuration for a university or a company), though they are useful
+ for other applications as well.
+ .
+ Homepage: http://debathena.mit.edu/config-packages/
--- /dev/null
+Authors: Tim Abbott <tabbott@mit.edu>
+ Anders Kaseorg <andersk@mit.edu>
+
+Copyright:
+
+ 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 of the License, 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.
+
+On Debian systems, the complete text of the GNU General Public License
+can be found in the file /usr/share/common-licenses/GPL.
--- /dev/null
+#!/usr/bin/make -f
+
+DEB_AUTO_UPDATE_DEBIAN_CONTROL = 1
+include /usr/share/cdbs/1/rules/debhelper.mk
--- /dev/null
+# -*- mode: makefile; coding: utf-8 -*-
+# Copyright © 2007-2008 Anders Kaseorg <andersk@mit.edu> and
+# Tim Abbott <tabbott@mit.edu>
+#
+# 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.
+
+ifndef _cdbs_rules_divert
+_cdbs_rules_divert = 1
+
+CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), config-package-dev
+
+DEB_DIVERT_SCRIPT = /usr/share/config-package-dev/divert.sh.in
+
+DEB_DIVERT_PACKAGES += $(foreach package,$(DEB_ALL_PACKAGES), \
+ $(if $(DEB_DIVERT_FILES_$(package)),$(package)))
+
+DEB_DIVERT_PACKAGES += $(foreach package,$(DEB_ALL_PACKAGES), \
+ $(if $(DEB_REPLACE_FILES_$(package)),$(package)))
+
+ifeq ($(DEB_DIVERT_EXTENSION),)
+DEB_DIVERT_EXTENSION = .divert
+endif
+
+DEB_DIVERT_ENCODER = /usr/share/config-package-dev/encode
+
+debian-divert/%: package = $(subst debian-divert/,,$@)
+debian-divert/%: replace_inputs = $(DEB_REPLACE_FILES_$(package))
+debian-divert/%: replace_files = $(foreach file,$(replace_inputs),$(file))
+debian-divert/%: divert_files = $(DEB_DIVERT_FILES_$(package)) $(replace_files)
+$(patsubst %,debian-divert/%,$(DEB_DIVERT_PACKAGES)) :: debian-divert/%:
+ ( \
+ sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \
+ $(if $(divert_files), \
+ echo 'if [ "$$1" = "configure" ]; then'; \
+ $(foreach file,$(divert_files), \
+ echo " divert_link $(subst $(DEB_DIVERT_EXTENSION), ,$(file))";) \
+ echo 'fi'; \
+ ) \
+ ) >> $(CURDIR)/debian/$(cdbs_curpkg).postinst.debhelper
+ ( \
+ sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \
+ $(if $(divert_files), \
+ echo 'if [ "$$1" = "remove" ]; then'; \
+ $(foreach file,$(divert_files), \
+ echo " undivert_unlink $(subst $(DEB_DIVERT_EXTENSION), ,$(file))";) \
+ echo 'fi'; \
+ ) \
+ ) >> $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper
+ ( \
+ echo -n "diverted-files="; \
+ $(foreach file,$(divert_files),\
+ ${DEB_DIVERT_ENCODER} "$(subst $(DEB_DIVERT_EXTENSION),,$(file))"; \
+ echo -n ", ";) \
+ echo \
+ ) >> $(CURDIR)/debian/$(cdbs_curpkg).substvars
+
+$(patsubst %,binary-fixup/%,$(DEB_DIVERT_PACKAGES)) :: binary-fixup/%: debian-divert/%
+
+endif
--- /dev/null
+#
+# divert_link <prefix> <suffix>
+#
+# Ensures that the file <prefix><suffix> is properly diverted to
+# <prefix>.divert-orig<suffix> by this package, and becomes a
+# symbolic link to either <prefix>.divert<suffix> (default) or
+# <prefix>.divert-orig<suffix>.
+#
+# undivert_unlink <prefix> <suffix>
+#
+# Undoes the action of divert_link <prefix> <suffix> specified
+# above.
+#
+# Version: 3.4
+#
+
+package=#PACKAGE#
+
+ours=#DEB_DIVERT_EXTENSION#
+theirs=#DEB_DIVERT_EXTENSION#-orig
+
+divert_link()
+{
+ prefix=$1
+ suffix=$2
+
+ file=$prefix$suffix
+ ourfile=$prefix$ours$suffix
+ theirfile=$prefix$theirs$suffix
+
+ if ! dpkg-divert --list "$package" | \
+ grep -xFq "diversion of $file to $theirfile by $package"; then
+ dpkg-divert --divert "$theirfile" --rename --package "$package" --add "$file"
+ fi
+ if [ ! -L "$file" ] && [ ! -e "$file" ]; then
+ ln -s "$(basename "$ourfile")" "$file"
+ elif [ ! -L "$file" ] || \
+ [ "$(readlink "$file")" != "$(basename "$ourfile")" -a \
+ "$(readlink "$file")" != "$(basename "$theirfile")" ]; then
+ echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2
+ fi
+}
+
+undivert_unlink()
+{
+ prefix=$1
+ suffix=$2
+
+ file=$prefix$suffix
+ ourfile=$prefix$ours$suffix
+ theirfile=$prefix$theirs$suffix
+
+ if [ ! -L "$file" ] || \
+ [ "$(readlink "$file")" != "$(basename "$ourfile")" -a \
+ "$(readlink "$file")" != "$(basename "$theirfile")" ]; then
+ echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2
+ else
+ rm -f "$file"
+ fi
+ if [ ! -L "$file" ] && [ ! -e "$file" ]; then
+ dpkg-divert --remove --rename --package "$package" "$file"
+ else
+ echo "Not removing diversion of $file by $package" >&2
+ fi
+}
+
--- /dev/null
+#!/usr/bin/perl
+# Encode name of a file in a Debian package name.
+#
+# DO NOT CHANGE THIS FUNCTION OR WE WILL ALL BURN IN CONFLICT HELL
+#
+# The purpose of this encoding is to cause Debian configuration
+# packages (potentially from different sites) that divert the same
+# configuration file to conflict with each other. Thus, it is
+# important that all sites using this Debian configuration package
+# system use this encoding.
+#
+# This encoding is intended to be human-readable, so that users can
+# determine the cause of conflicts between different configuration
+# packages.
+
+print "configures-";
+$ARGV[0] =~ s,^/,,;
+split('', $ARGV[0]);
+foreach (@_){
+ if (m/[a-z0-9.-]/) {
+ print "$_";
+ } elsif (m/[A-Z]/) {
+ print "+".lc($_)."+";
+ } elsif ($_ eq '/') {
+ print "++";
+ } elsif ($_ eq '_') {
+ print "+-+";
+ } else{
+ print "+x".hex(ord($_))."+";
+ }
+}
--- /dev/null
+# -*- mode: makefile; coding: utf-8 -*-
+# Copyright © 2008 Tim Abbott <tabbott@mit.edu> and
+# Anders Kaseorg <andersk@mit.edu>
+#
+# 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.
+
+ifndef _cdbs_rules_replace_files
+_cdbs_rules_replace_files = 1
+
+include /usr/share/cdbs/1/rules/check-files.mk
+
+DEB_REPLACE_FILES = $(foreach package,$(DEB_ALL_PACKAGES),$(DEB_REPLACE_FILES_$(package)))
+
+DEB_REPLACE_FILES_DIR=debian/replace_file_copies
+
+debian_replace_files = $(patsubst %,$(DEB_REPLACE_FILES_DIR)%,$(1))
+undebian_replace_files = $(patsubst $(DEB_REPLACE_FILES_DIR)%,%,$(1))
+
+common-build-indep:: $(foreach file,$(DEB_REPLACE_FILES),$(call debian_replace_files,$(file)))
+
+$(call debian_replace_files,%): $(call debian_check_files,%)
+ mkdir -p $(@D)
+ $(if $(DEB_TRANSFORM_SCRIPT_$(call undebian_replace_files,$@)), \
+ $(DEB_TRANSFORM_SCRIPT_$(call undebian_replace_files,$@)), \
+ debian/transform_$(notdir $(call undebian_replace_files,$@))) < $< > $@
+
+$(patsubst %,binary-install/%,$(DEB_ALL_PACKAGES)) :: binary-install/%:
+ $(foreach file,$(DEB_REPLACE_FILES_$(cdbs_curpkg)), \
+ install -d $(DEB_DESTDIR)/$(dir $(file)); \
+ cp -a $(DEB_REPLACE_FILES_DIR)$(file) \
+ $(DEB_DESTDIR)/$(dir $(file));)
+
+clean::
+ $(foreach file,$(DEB_REPLACE_FILES),rm -f debian/$(notdir $(file)))
+ rm -rf $(DEB_REPLACE_FILES_DIR)
+
+endif