From a06c63daf5d63fc1d74f7a6e2606d5a08062c739 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 17 Mar 2011 01:51:08 +0000 Subject: [PATCH] =?utf8?q?Write=20the=20prerm=20and=20postrm=20maintainer?= =?utf8?q?=20script=20fragments=20in=20reverse=20order=20when=20DH=5FCOMPA?= =?utf8?q?T=20=E2=89=A5=205,=20to=20match=20debhelper=E2=80=99s=20behavior?= =?utf8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn+ssh://svn.mit.edu/athena/trunk/debathena/debathena/config-package-dev@25061 728af825-273c-0410-89f9-f7d3b574a069 --- debconf-divert.mk | 14 +++++++++++++- debian/changelog | 4 +++- divert.mk | 21 ++++++++++++++++++--- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/debconf-divert.mk b/debconf-divert.mk index fbb587c..84de2d5 100644 --- a/debconf-divert.mk +++ b/debconf-divert.mk @@ -27,6 +27,8 @@ 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))) +dh_compat_5 := $(shell if [ '$(DH_COMPAT)' -ge 5 ]; then echo y; fi) + $(patsubst %,debian-debconf-hack/%,$(DEB_DEBCONF_HACK_PACKAGES)) :: debian-debconf-hack/%: set -e; \ { \ @@ -48,12 +50,22 @@ $(patsubst %,debian-debconf-hack/%,$(DEB_DEBCONF_HACK_PACKAGES)) :: debian-debco } >> $(CURDIR)/debian/$(cdbs_curpkg).postinst.debhelper set -e; \ { \ + $(if $(dh_compat_5),, \ + if [ -e $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper ]; then \ + cat $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper; \ + fi;) \ cat $(DEB_DEBCONF_HACK_SCRIPT); \ echo 'if [ -f /var/cache/$(cdbs_curpkg).debconf-save ]; then'; \ echo ' debconf_set > $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper + $(if $(dh_compat_5), \ + if [ -e $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper ]; then \ + cat $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper; \ + fi;) \ + } >> $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper.new + mv $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper.new \ + $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper $(patsubst %,binary-fixup/%,$(DEB_DEBCONF_HACK_PACKAGES)) :: binary-fixup/%: debian-debconf-hack/% diff --git a/debian/changelog b/debian/changelog index 685a7ec..f6a8d65 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,8 +13,10 @@ config-package-dev (4.12) unstable; urgency=low * Remove DEB_UNDIVERT_VERSION_file and DEB_UNREMOVE_VERSION_file, and instead test for the undiverted file in the postinst. (Patch from Evan Broder.) + * Write the prerm and postrm maintainer script fragments in reverse + order when DH_COMPAT ≥ 5, to match debhelper’s behavior. - -- Anders Kaseorg Sat, 06 Nov 2010 19:02:52 -0400 + -- Anders Kaseorg Sat, 05 Feb 2011 21:21:59 -0500 config-package-dev (4.11) unstable; urgency=low diff --git a/divert.mk b/divert.mk index ffa4d31..6212abe 100644 --- a/divert.mk +++ b/divert.mk @@ -57,6 +57,11 @@ divert_files_replace_name = $(shell echo $(1) | perl -pe 's/(.*)\Q$(DEB_DIVERT_E # removed remove_files_name = /usr/share/$(cdbs_curpkg)/$(shell $(DEB_DIVERT_ENCODER) $(1)) +dh_compat_5 := $(shell if [ '$(DH_COMPAT)' -ge 5 ]; then echo y; fi) + +reverse = $(foreach n,$(shell seq $(words $(1)) -1 1),$(word $(n),$(1))) +reverse_dh_compat_5 = $(if $(dh_compat_5),$(call reverse,$(1)),$(1)) + debian-divert/%: package = $(subst debian-divert/,,$@) debian-divert/%: divert_files = $(DEB_DIVERT_FILES_$(package)) $(DEB_TRANSFORM_FILES_$(package)) debian-divert/%: divert_remove_files = $(DEB_REMOVE_FILES_$(package)) @@ -88,16 +93,26 @@ $(patsubst %,debian-divert/%,$(DEB_DIVERT_PACKAGES)) :: debian-divert/%: # Add code to prerm script to undo diversions when package is removed. set -e; \ { \ + $(if $(dh_compat_5),, \ + if [ -e $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper ]; then \ + cat $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper; \ + fi;) \ sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \ $(if $(divert_files_thispkg), \ echo 'if [ "$$1" = "remove" ]; then'; \ - $(foreach file,$(divert_files), \ + $(foreach file,$(call reverse_dh_compat_5,$(divert_files)), \ echo " undivert_unlink $(call divert_files_replace_name,$(file), )";) \ - $(foreach file,$(divert_remove_files), \ + $(foreach file,$(call reverse_dh_compat_5,$(divert_remove_files)), \ echo " undivert_unremove $(file) $(cdbs_curpkg)";) \ echo 'fi'; \ ) \ - } >> $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper + $(if $(dh_compat_5), \ + if [ -e $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper ]; then \ + cat $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper; \ + fi;) \ + } >> $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper.new + mv $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper.new \ + $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper # Add an encoding of the names of the diverted files to the Provides: # and Conflicts: lists. This prevents two packages diverting the same # file from being installed simultaneously (it cannot work, and this -- 2.45.0