From ab8e2a67ce47fada2ae30371f954ab9dd570245c Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sun, 6 Apr 2008 22:50:26 +0000 Subject: [PATCH] Initial import of the config-package-dev system. git-svn-id: svn+ssh://svn.mit.edu/athena/trunk/debathena/debathena/config-package-dev@22854 728af825-273c-0410-89f9-f7d3b574a069 --- check-files.mk | 63 +++++++++++++++++++++ debconf-divert.mk | 57 +++++++++++++++++++ debconf-hack.sh | 37 +++++++++++++ debian/changelog | 92 +++++++++++++++++++++++++++++++ debian/compat | 1 + debian/config-package-dev.install | 7 +++ debian/control | 25 +++++++++ debian/control.in | 25 +++++++++ debian/copyright | 17 ++++++ debian/rules | 4 ++ divert.mk | 72 ++++++++++++++++++++++++ divert.sh.in | 66 ++++++++++++++++++++++ encode | 31 +++++++++++ replace-files.mk | 50 +++++++++++++++++ 14 files changed, 547 insertions(+) create mode 100644 check-files.mk create mode 100644 debconf-divert.mk create mode 100644 debconf-hack.sh create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/config-package-dev.install create mode 100644 debian/control create mode 100644 debian/control.in create mode 100644 debian/copyright create mode 100755 debian/rules create mode 100644 divert.mk create mode 100644 divert.sh.in create mode 100755 encode create mode 100644 replace-files.mk diff --git a/check-files.mk b/check-files.mk new file mode 100644 index 0000000..ca97c21 --- /dev/null +++ b/check-files.mk @@ -0,0 +1,63 @@ +# -*- mode: makefile; coding: utf-8 -*- +# Copyright © 2007-2008 Anders Kaseorg and +# Tim Abbott +# +# 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 diff --git a/debconf-divert.mk b/debconf-divert.mk new file mode 100644 index 0000000..eb132c1 --- /dev/null +++ b/debconf-divert.mk @@ -0,0 +1,57 @@ +# -*- mode: makefile; coding: utf-8 -*- +# Copyright © 2007-2008 Anders Kaseorg and +# Tim Abbott +# +# 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 <> $(CURDIR)/debian/$(cdbs_curpkg).preinst.debhelper + ( \ + cat $(DEB_DEBCONF_HACK_SCRIPT); \ + echo 'if [ -f /var/cache/$(cdbs_curpkg).debconf-save ]; then'; \ + echo ' debconf_set > $(CURDIR)/debian/$(cdbs_curpkg).postinst.debhelper + ( \ + cat $(DEB_DEBCONF_HACK_SCRIPT); \ + echo 'if [ -f /var/cache/$(cdbs_curpkg).debconf-save ]; then'; \ + echo ' debconf_set > $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper + +$(patsubst %,binary-fixup/%,$(DEB_DEBCONF_HACK_PACKAGES)) :: binary-fixup/%: debian-debconf-hack/% + +endif diff --git a/debconf-hack.sh b/debconf-hack.sh new file mode 100644 index 0000000..f77fb8a --- /dev/null +++ b/debconf-hack.sh @@ -0,0 +1,37 @@ +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;' +} diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..a4f4d06 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,92 @@ +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 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 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 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 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 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 Mon, 06 Aug 2007 06:57:18 -0400 + +debathena-config-build-common (3.3) unstable; urgency=low + + * Add check-conffiles script. + + -- Anders Kaseorg Fri, 03 Aug 2007 17:50:20 -0400 + +debathena-config-build-common (3.2) unstable; urgency=low + + * Add debconf-hack script. + + -- Anders Kaseorg 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 Wed, 18 Jul 2007 01:13:40 -0400 + +debathena-config-build-common (3.0debathena1) unstable; urgency=low + + * Fix divert script version. + + -- Anders Kaseorg Fri, 13 Jul 2007 15:57:19 -0400 + +debathena-config-build-common (3.0) unstable; urgency=low + + * Initial release. + + -- Anders Kaseorg Fri, 06 Jul 2007 19:30:41 -0400 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +4 diff --git a/debian/config-package-dev.install b/debian/config-package-dev.install new file mode 100644 index 0000000..e2d8b70 --- /dev/null +++ b/debian/config-package-dev.install @@ -0,0 +1,7 @@ +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/ diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..879f750 --- /dev/null +++ b/debian/control @@ -0,0 +1,25 @@ +Source: config-package-dev +Section: devel +Priority: extra +Maintainer: Debian-Athena Project +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/ diff --git a/debian/control.in b/debian/control.in new file mode 100644 index 0000000..b7da15e --- /dev/null +++ b/debian/control.in @@ -0,0 +1,25 @@ +Source: config-package-dev +Section: devel +Priority: extra +Maintainer: Debian-Athena Project +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/ diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..7496900 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,17 @@ +Authors: Tim Abbott + Anders Kaseorg + +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. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..6bf6850 --- /dev/null +++ b/debian/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +DEB_AUTO_UPDATE_DEBIAN_CONTROL = 1 +include /usr/share/cdbs/1/rules/debhelper.mk diff --git a/divert.mk b/divert.mk new file mode 100644 index 0000000..229f999 --- /dev/null +++ b/divert.mk @@ -0,0 +1,72 @@ +# -*- mode: makefile; coding: utf-8 -*- +# Copyright © 2007-2008 Anders Kaseorg and +# Tim Abbott +# +# 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 diff --git a/divert.sh.in b/divert.sh.in new file mode 100644 index 0000000..47f006c --- /dev/null +++ b/divert.sh.in @@ -0,0 +1,66 @@ +# +# divert_link +# +# Ensures that the file is properly diverted to +# .divert-orig by this package, and becomes a +# symbolic link to either .divert (default) or +# .divert-orig. +# +# undivert_unlink +# +# Undoes the action of divert_link 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 +} + diff --git a/encode b/encode new file mode 100755 index 0000000..e69cdf6 --- /dev/null +++ b/encode @@ -0,0 +1,31 @@ +#!/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($_))."+"; + } +} diff --git a/replace-files.mk b/replace-files.mk new file mode 100644 index 0000000..4305432 --- /dev/null +++ b/replace-files.mk @@ -0,0 +1,50 @@ +# -*- mode: makefile; coding: utf-8 -*- +# Copyright © 2008 Tim Abbott and +# Anders Kaseorg +# +# 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 -- 2.45.0