]> andersk Git - config-package-dev.git/blobdiff - debconf-divert.mk
Write the prerm and postrm maintainer script fragments in reverse order when DH_COMPA...
[config-package-dev.git] / debconf-divert.mk
index fbb587c353ad2b9953c2c9bf5a93667f2c8a2877..84de2d5139c79e6e4180e2f99688e0e529a67b6a 100644 (file)
@@ -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 </var/cache/$(cdbs_curpkg).debconf-save'; \
            echo '    rm -f /var/cache/$(cdbs_curpkg).debconf-save'; \
            echo 'fi'; \
-       } >> $(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/%
 
This page took 0.052143 seconds and 4 git commands to generate.