source: config-package-dev/debconf-divert.mk @ 9350e97

Revision 9350e97, 3.0 KB checked in by Anders Kaseorg <andersk@…>, 12 years ago (diff)
Reverse {pre,post}rm maintainer script fragments when DH_COMPAT ≥ 6, not 5 Reported-by: Geoffrey Thomas <geofft@mit.edu> Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Property mode set to 100644
Line 
1# -*- mode: makefile; coding: utf-8 -*-
2# Copyright © 2007-2008 Anders Kaseorg <andersk@mit.edu> and
3#                       Tim Abbott <tabbott@mit.edu>
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License as
7# published by the Free Software Foundation; either version 2, or (at
8# your option) any later version.
9#
10# This program is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18# 02111-1307 USA.
19
20ifndef _cdbs_rules_debconf_divert
21_cdbs_rules_debconf_divert = 1
22
23CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), config-package-dev (>= 3.2~)
24
25DEB_DEBCONF_HACK_SCRIPT = /usr/share/config-package-dev/debconf-hack.sh
26
27DEB_DEBCONF_HACK_PACKAGES += $(foreach package,$(DEB_ALL_PACKAGES), \
28    $(if $(wildcard debian/$(package).debconf-hack),$(package)))
29
30dh_compat_6 := $(shell if [ '$(DH_COMPAT)' -ge 6 ]; then echo y; fi)
31
32$(patsubst %,debian-debconf-hack/%,$(DEB_DEBCONF_HACK_PACKAGES)) :: debian-debconf-hack/%:
33        set -e; \
34        { \
35            cat $(DEB_DEBCONF_HACK_SCRIPT); \
36            echo 'if [ ! -f /var/cache/$(cdbs_curpkg).debconf-save ]; then'; \
37            echo '    debconf_get $(shell cut -d'       ' -f2 debian/$(cdbs_curpkg).debconf-hack) >/var/cache/$(cdbs_curpkg).debconf-save'; \
38            echo '    debconf_set <<EOF'; \
39            sed 's/$$/  true/' debian/$(cdbs_curpkg).debconf-hack; \
40            echo 'EOF'; \
41            echo 'fi'; \
42        } >> $(CURDIR)/debian/$(cdbs_curpkg).preinst.debhelper
43        set -e; \
44        { \
45            cat $(DEB_DEBCONF_HACK_SCRIPT); \
46            echo 'if [ -f /var/cache/$(cdbs_curpkg).debconf-save ]; then'; \
47            echo '    debconf_set </var/cache/$(cdbs_curpkg).debconf-save'; \
48            echo '    rm -f /var/cache/$(cdbs_curpkg).debconf-save'; \
49            echo 'fi'; \
50        } >> $(CURDIR)/debian/$(cdbs_curpkg).postinst.debhelper
51        set -e; \
52        { \
53            $(if $(dh_compat_6),, \
54                if [ -e $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper ]; then \
55                    cat $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper; \
56                fi;) \
57            cat $(DEB_DEBCONF_HACK_SCRIPT); \
58            echo 'if [ -f /var/cache/$(cdbs_curpkg).debconf-save ]; then'; \
59            echo '    debconf_set </var/cache/$(cdbs_curpkg).debconf-save'; \
60            echo '    rm -f /var/cache/$(cdbs_curpkg).debconf-save'; \
61            echo 'fi'; \
62            $(if $(dh_compat_6), \
63                if [ -e $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper ]; then \
64                    cat $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper; \
65                fi;) \
66        } >> $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper.new
67        mv $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper.new \
68            $(CURDIR)/debian/$(cdbs_curpkg).postrm.debhelper
69
70$(patsubst %,binary-fixup/%,$(DEB_DEBCONF_HACK_PACKAGES)) :: binary-fixup/%: debian-debconf-hack/%
71
72endif
Note: See TracBrowser for help on using the repository browser.