source: trunk/debathena/config/config-build-common/debathena-check-conffiles.mk @ 22760

Revision 22760, 2.5 KB checked in by andersk, 16 years ago (diff)
Guard against multiple inclusions.
Line 
1# -*- mode: makefile; coding: utf-8 -*-
2
3ifndef _cdbs_rules_debathena_check_conffiles
4_cdbs_rules_debathena_check_conffiles = 1
5
6ifneq ($(DEBATHENA_CHECK_CONFFILES),)
7# Deprecated interface.
8
9CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), debathena-config-build-common (>= 3.3~)
10
11$(DEBATHENA_CHECK_CONFFILES) :: %: FORCE
12        [ -e "$@" ]
13        dpkg-query --showformat='$${Conffiles}\n' --show "$$(dpkg -S $@ | cut -f1 -d:)" | \
14            grep -F " $@ " | sed 's/^ \(.*\) \(.*\)$$/\2  \1/' | \
15            md5sum -c  # Check that the file has not been modified.
16
17FORCE:
18
19.PRECIOUS: $(DEBATHENA_CHECK_CONFFILES)
20
21else
22
23include /usr/share/cdbs/1/rules/debathena-divert.mk
24
25DEBATHENA_CHECK_CONFFILES_DIR = debian/conffile-copies
26
27debathena_check_conffiles_source = $(if $(DEBATHENA_CHECK_CONFFILES_SOURCE_$(1)),$(DEBATHENA_CHECK_CONFFILES_SOURCE_$(1)),$(1))
28debathena_check_conffiles_check = $(subst $(DEBATHENA_DIVERT_SUFFIX),,$(call debathena_check_conffiles_source,$(1)))
29
30debathena_check_conffiles = $(patsubst %,$(DEBATHENA_CHECK_CONFFILES_DIR)%,$(1))
31undebathena_check_conffiles = $(patsubst $(DEBATHENA_CHECK_CONFFILES_DIR)%,%,$(1))
32
33debathena_check_conffiles_tmp = $(patsubst %,%.tmp,$(call debathena_check_conffiles,$(1)))
34undebathena_check_conffiles_tmp = $(call undebathena_check_conffiles,$(patsubst %.tmp,%,$(1)))
35
36$(call debathena_check_conffiles,%): $(call debathena_check_conffiles_tmp,%)
37        mv $< $@
38
39$(call debathena_check_conffiles_tmp,%): target = $(call undebathena_check_conffiles_tmp,$@)
40$(call debathena_check_conffiles_tmp,%): name = $(call debathena_check_conffiles_check,$(target))
41$(call debathena_check_conffiles_tmp,%): truename = $(shell /usr/sbin/dpkg-divert --truename $(name))
42$(call debathena_check_conffiles_tmp,%): package = $(shell dpkg -S $(name) | grep -v "^diversion by" | cut -f1 -d:)
43$(call debathena_check_conffiles_tmp,%): $(truename)
44        [ -n $(package) ]
45        mkdir -p $(@D)
46        cp "$(truename)" $@
47        md5=$$(dpkg-query --showformat='$${Conffiles}\n' --show $(package) | \
48            sed -n 's,^ $(name) \([0-9a-f]*\)$$,\1  $@, p'); \
49        if [ -n "$$md5" ]; then \
50            echo "$$md5" | md5sum -c; \
51        elif [ -e /var/lib/dpkg/info/$(package).md5sums ]; then \
52            md5=$$(sed -n 's,^\([0-9a-f]*\)  $(patsubst /%,%,$(name))$$,\1  $@, p' \
53                /var/lib/dpkg/info/$(package).md5sums); \
54            [ -n "$$md5" ] && echo "$$md5" | md5sum -c; \
55        else \
56            echo "warning: $(package) does not include md5sums!"; \
57            echo "warning: md5sum for $(name) not verified."; \
58        fi
59
60clean::
61        rm -rf $(DEBATHENA_CHECK_CONFFILES_DIR)
62
63endif
64
65endif
Note: See TracBrowser for help on using the repository browser.