]> andersk Git - config-package-dev.git/commitdiff
Initial import of the config-package-dev system. 4.2
authorTim Abbott <tabbott@mit.edu>
Sun, 6 Apr 2008 22:50:26 +0000 (22:50 +0000)
committerTim Abbott <tabbott@mit.edu>
Sun, 6 Apr 2008 22:50:26 +0000 (22:50 +0000)
git-svn-id: svn+ssh://svn.mit.edu/athena/trunk/debathena/debathena/config-package-dev@22854 728af825-273c-0410-89f9-f7d3b574a069

14 files changed:
check-files.mk [new file with mode: 0644]
debconf-divert.mk [new file with mode: 0644]
debconf-hack.sh [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/config-package-dev.install [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/control.in [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/rules [new file with mode: 0755]
divert.mk [new file with mode: 0644]
divert.sh.in [new file with mode: 0644]
encode [new file with mode: 0755]
replace-files.mk [new file with mode: 0644]

diff --git a/check-files.mk b/check-files.mk
new file mode 100644 (file)
index 0000000..ca97c21
--- /dev/null
@@ -0,0 +1,63 @@
+# -*- 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
diff --git a/debconf-divert.mk b/debconf-divert.mk
new file mode 100644 (file)
index 0000000..eb132c1
--- /dev/null
@@ -0,0 +1,57 @@
+# -*- 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
diff --git a/debconf-hack.sh b/debconf-hack.sh
new file mode 100644 (file)
index 0000000..f77fb8a
--- /dev/null
@@ -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 (file)
index 0000000..a4f4d06
--- /dev/null
@@ -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 <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
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..b8626c4
--- /dev/null
@@ -0,0 +1 @@
+4
diff --git a/debian/config-package-dev.install b/debian/config-package-dev.install
new file mode 100644 (file)
index 0000000..e2d8b70
--- /dev/null
@@ -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 (file)
index 0000000..879f750
--- /dev/null
@@ -0,0 +1,25 @@
+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/
diff --git a/debian/control.in b/debian/control.in
new file mode 100644 (file)
index 0000000..b7da15e
--- /dev/null
@@ -0,0 +1,25 @@
+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/
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..7496900
--- /dev/null
@@ -0,0 +1,17 @@
+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.
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..6bf6850
--- /dev/null
@@ -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 (file)
index 0000000..229f999
--- /dev/null
+++ b/divert.mk
@@ -0,0 +1,72 @@
+# -*- 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
diff --git a/divert.sh.in b/divert.sh.in
new file mode 100644 (file)
index 0000000..47f006c
--- /dev/null
@@ -0,0 +1,66 @@
+#
+# 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
+}
+
diff --git a/encode b/encode
new file mode 100755 (executable)
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 (file)
index 0000000..4305432
--- /dev/null
@@ -0,0 +1,50 @@
+# -*- 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
This page took 0.327341 seconds and 5 git commands to generate.