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 | |
---|
20 | ifndef _cdbs_rules_check_files |
---|
21 | _cdbs_rules_check_files = 1 |
---|
22 | |
---|
23 | include /usr/share/cdbs/1/rules/divert.mk |
---|
24 | |
---|
25 | DEB_CHECK_FILES_DIR = debian/check_file_copies |
---|
26 | |
---|
27 | debian_check_files_source = $(if $(DEB_CHECK_FILES_SOURCE_$(1)),$(DEB_CHECK_FILES_SOURCE_$(1)),$(1)) |
---|
28 | debian_check_files_check = $(call divert_files_replace_name,$(call debian_check_files_source,$(1))) |
---|
29 | |
---|
30 | debian_check_files = $(patsubst %,$(DEB_CHECK_FILES_DIR)%,$(1)) |
---|
31 | undebian_check_files = $(patsubst $(DEB_CHECK_FILES_DIR)%,%,$(1)) |
---|
32 | |
---|
33 | debian_check_files_tmp = $(patsubst %,%.tmp,$(call debian_check_files,$(1))) |
---|
34 | undebian_check_files_tmp = $(call undebian_check_files,$(patsubst %.tmp,%,$(1))) |
---|
35 | |
---|
36 | $(call debian_check_files,%): $(call debian_check_files_tmp,%) |
---|
37 | mv $< $@ |
---|
38 | |
---|
39 | $(call debian_check_files_tmp,%): target = $(call undebian_check_files_tmp,$@) |
---|
40 | $(call debian_check_files_tmp,%): name = $(call debian_check_files_check,$(target)) |
---|
41 | $(call debian_check_files_tmp,%): truename = $(shell /usr/sbin/dpkg-divert --truename $(name)) |
---|
42 | $(call debian_check_files_tmp,%): package = $(shell dpkg -S $(name) | grep -v "^diversion by" | cut -f1 -d:) |
---|
43 | $(call debian_check_files_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 $(DEB_CHECK_FILES_DIR) |
---|
62 | |
---|
63 | endif |
---|