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

Revision 22918, 2.6 KB checked in by tabbott, 16 years ago (diff)
In config-package-dev: * Add new DEB_REMOVE_FILES_$package variable designed for removing files in .d directories. * Move the "configure-" in the filename encoding from the encode script to divert.mk, so that we can re-use the encoder for DEB_REMOVE_FILES. * Add new DEB_UNDIVERT_FILES_package and DEB_UNREMOVE_FILES_package API variables for having a new version of the package stop diverting a file. * Correct check for not generating an empty if clause when no files are being diverted. * Remove only the last DEB_DIVERT_EXTENSION from filenames.
Line 
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
20ifndef _cdbs_rules_check_files
21_cdbs_rules_check_files = 1
22
23include /usr/share/cdbs/1/rules/divert.mk
24
25DEB_CHECK_FILES_DIR = debian/check_file_copies
26
27debian_check_files_source = $(if $(DEB_CHECK_FILES_SOURCE_$(1)),$(DEB_CHECK_FILES_SOURCE_$(1)),$(1))
28debian_check_files_check = $(call divert_files_replace_name,$(call debian_check_files_source,$(1)))
29
30debian_check_files = $(patsubst %,$(DEB_CHECK_FILES_DIR)%,$(1))
31undebian_check_files = $(patsubst $(DEB_CHECK_FILES_DIR)%,%,$(1))
32
33debian_check_files_tmp = $(patsubst %,%.tmp,$(call debian_check_files,$(1)))
34undebian_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
60clean::
61        rm -rf $(DEB_CHECK_FILES_DIR)
62
63endif
Note: See TracBrowser for help on using the repository browser.