source: trunk/debathena/debathena/config-package-dev/check-files.mk @ 25844

Revision 25844, 3.7 KB checked in by geofft, 11 years ago (diff)
Sync config-package-dev 5.0 from Debian unstable.
RevLine 
[22854]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
[23076]20# Don't include check-files.mk in your rules files directly; instead
21# use config-package.mk.
22
23# check-files.mk is used to verify that files on local disk have not
24# been modified from the upstream packaged version.  Its only API
25# function is adding the following function as a dependency:
26#
27# $(call debian_check_files,filename)
28#
29#   Returns the path to a copy of filename that is verified to be
30# unmodified from the version shipped by the distribution (by checking
31# md5sums).  The function causes the package to fail to build if the
32# relevant configuration file has been modified on the build machine.
33
[22854]34ifndef _cdbs_rules_check_files
35_cdbs_rules_check_files = 1
36
[25844]37include /usr/share/cdbs/1/rules/displace.mk
[22854]38
[23076]39DEB_CHECK_FILES_TMPDIR = debian/check_file_copies
[22854]40
[25844]41debian_check_files_source = $(if $(DEB_CHECK_FILES_SOURCE_$(1)),$(DEB_CHECK_FILES_SOURCE_$(1)),$(call displace_files_replace_name,$(1)))
[22854]42
[23076]43debian_check_files = $(patsubst %,$(DEB_CHECK_FILES_TMPDIR)%,$(1))
44undebian_check_files = $(patsubst $(DEB_CHECK_FILES_TMPDIR)%,%,$(1))
[22854]45
46debian_check_files_tmp = $(patsubst %,%.tmp,$(call debian_check_files,$(1)))
47undebian_check_files_tmp = $(call undebian_check_files,$(patsubst %.tmp,%,$(1)))
48
[23076]49# We need a level of indirection here in order to make sure that
50# normal makefile targets, like "clean", are not affected by the
51# debian_check_files rules.
[22854]52$(call debian_check_files,%): $(call debian_check_files_tmp,%)
53        mv $< $@
54
[23076]55# We check md5sums from both /var/lib/dpkg/info/$(package).md5sums
56# (the md5sums database for non-conffiles) and the conffiles database
57# used for prompting about conffiles being changed (via dpkg-query).
58#
59# There is some wrangling here because the formats of these sources differ.
[22854]60$(call debian_check_files_tmp,%): target = $(call undebian_check_files_tmp,$@)
[25800]61$(call debian_check_files_tmp,%): name = $(call debian_check_files_source,$(target))
[22854]62$(call debian_check_files_tmp,%): truename = $(shell /usr/sbin/dpkg-divert --truename $(name))
[25427]63$(call debian_check_files_tmp,%): package = $(shell LC_ALL=C dpkg -S $(name) | sed -n '/^diversion by /! s/: .*$$// p')
[22854]64$(call debian_check_files_tmp,%): $(truename)
[24906]65        [ -n "$(package)" ]
[22854]66        mkdir -p $(@D)
67        cp "$(truename)" $@
[23197]68        set -e; \
[25426]69        md5sums="$$(dpkg-query --control-path $(package) md5sums 2>/dev/null)" || \
70            md5sums=/var/lib/dpkg/info/$(package).md5sums; \
[22854]71        md5=$$(dpkg-query --showformat='$${Conffiles}\n' --show $(package) | \
72            sed -n 's,^ $(name) \([0-9a-f]*\)$$,\1  $@, p'); \
73        if [ -n "$$md5" ]; then \
74            echo "$$md5" | md5sum -c; \
[25426]75        elif [ -e "$$md5sums" ]; then \
[22854]76            md5=$$(sed -n 's,^\([0-9a-f]*\)  $(patsubst /%,%,$(name))$$,\1  $@, p' \
[25426]77                "$$md5sums"); \
[22854]78            [ -n "$$md5" ] && echo "$$md5" | md5sum -c; \
79        else \
[23076]80            echo "config-package-dev: warning: $(package) does not include md5sums!"; \
81            echo "config-package-dev: warning: md5sum for $(name) not verified."; \
[22854]82        fi
83
84clean::
[23076]85        rm -rf $(DEB_CHECK_FILES_TMPDIR)
[22854]86
87endif
Note: See TracBrowser for help on using the repository browser.