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