1
# -*- mode: makefile; coding: utf-8 -*-
2
# Copyright © 2005-2007 Jonas Smedegaard <dr@jones.dk>
3
# Description: Check for changes to copyright notices in source
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.
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.
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
20
# TODO: Save scan as "file: match" (needs rewrite of main loop in perl)
22
# TODO: Save scan as "file (license): match" (needs /usr/bin/licensecheck from kdesdk-scripts)
24
_cdbs_scripts_path ?= /usr/lib/cdbs
25
_cdbs_rules_path ?= /usr/share/cdbs/1/rules
26
_cdbs_class_path ?= /usr/share/cdbs/1/class
28
ifndef _cdbs_rules_copyright-check
29
_cdbs_rules_copyright-check := 1
31
include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
33
cdbs_copyright-check_find_opts := -not -regex 'debian/.*' -not -regex '\(.*/\)?config\.\(guess\|sub\|log\|rpath\)\(\..*\)?'
34
cdbs_copyright-check_egrep_opts := --text -rih '(copyright|\(c\) ).*[0-9]{4}'
36
pre-build:: debian/stamp-copyright-check
38
debian/stamp-copyright-check:
39
@echo 'Scanning upstream source for new/changed copyright notices (except debian subdir!)...'
40
find * -type f $(cdbs_copyright-check_find_opts) -exec cat '{}' ';' \
42
| LC_ALL=C sed -e 's/[^[:print:]]//g' \
43
| egrep $(cdbs_copyright-check_egrep_opts) \
44
| sed -e 's/^[[:space:]*#]*//' -e 's/[[:space:]]*$$//' \
46
> debian/copyright_newhints
47
@if [ ! -f debian/copyright_hints ]; then touch debian/copyright_hints; fi
48
@newstrings=`diff -u debian/copyright_hints debian/copyright_newhints | sed '1,2d' | egrep '^\+' | sed 's/^\+//'`; \
49
if [ -n "$$newstrings" ]; then \
50
echo "Error: The following new or changed copyright notices discovered:"; \
51
echo "$$newstrings"; \
52
echo "Trying to locate the files containing the new/changed copyright notices..."; \
53
echo "(Strings part of binary data you need to resolve yourself)"; \
54
find * -type f $(cdbs_copyright-check_find_opts) -exec grep -F -l -e "$$newstrings" '{}' ';'; \
56
echo "To fix the situation please do the following:"; \
57
echo " 1) Investigate the above changes and update debian/copyright as needed"; \
58
echo " 2) Replace debian/copyright_hints with debian/copyright_newhints"; \
62
@echo 'No new copyright notices found - assuming no news is good news...'
63
rm -f debian/copyright_newhints
67
rm -f debian/stamp-copyright-check