1 | # -*- mode: makefile; coding: utf-8 -*- |
---|
2 | |
---|
3 | ifndef _cdbs_rules_debathena_check_conffiles |
---|
4 | _cdbs_rules_debathena_check_conffiles = 1 |
---|
5 | |
---|
6 | ifneq ($(DEBATHENA_CHECK_CONFFILES),) |
---|
7 | # Deprecated interface. |
---|
8 | |
---|
9 | CDBS_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 | |
---|
17 | FORCE: |
---|
18 | |
---|
19 | .PRECIOUS: $(DEBATHENA_CHECK_CONFFILES) |
---|
20 | |
---|
21 | else |
---|
22 | |
---|
23 | include /usr/share/cdbs/1/rules/debathena-divert.mk |
---|
24 | |
---|
25 | DEBATHENA_CHECK_CONFFILES_DIR = debian/conffile-copies |
---|
26 | |
---|
27 | debathena_check_conffiles_source = $(if $(DEBATHENA_CHECK_CONFFILES_SOURCE_$(1)),$(DEBATHENA_CHECK_CONFFILES_SOURCE_$(1)),$(1)) |
---|
28 | debathena_check_conffiles_check = $(subst $(DEBATHENA_DIVERT_SUFFIX),,$(call debathena_check_conffiles_source,$(1))) |
---|
29 | |
---|
30 | debathena_check_conffiles = $(patsubst %,$(DEBATHENA_CHECK_CONFFILES_DIR)%,$(1)) |
---|
31 | undebathena_check_conffiles = $(patsubst $(DEBATHENA_CHECK_CONFFILES_DIR)%,%,$(1)) |
---|
32 | |
---|
33 | debathena_check_conffiles_tmp = $(patsubst %,%.tmp,$(call debathena_check_conffiles,$(1))) |
---|
34 | undebathena_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 | |
---|
60 | clean:: |
---|
61 | rm -rf $(DEBATHENA_CHECK_CONFFILES_DIR) |
---|
62 | |
---|
63 | endif |
---|
64 | |
---|
65 | endif |
---|