17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20
ifndef _cdbs_bootstrap
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)
21
24
_cdbs_scripts_path ?= /usr/lib/cdbs
22
25
_cdbs_rules_path ?= /usr/share/cdbs/1/rules
23
26
_cdbs_class_path ?= /usr/share/cdbs/1/class
26
28
ifndef _cdbs_rules_copyright-check
27
29
_cdbs_rules_copyright-check := 1
29
31
include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
31
cdbs_copyright-check_find_opts := -not -regex '\./debian/.*'
33
cdbs_copyright-check_find_opts := -not -regex 'debian/.*' -not -regex '\(.*/\)?config\.\(guess\|sub\|rpath\)\(\..*\)?'
32
34
cdbs_copyright-check_egrep_opts := --text -rih '(copyright|\(c\) ).*[0-9]{4}'
35
@echo 'Scanning upstream source for new/changed copyright notices...'
36
@echo '(the debian/ subdir is _not_ examined - do that manually!)'
37
find . -type f $(cdbs_copyright-check_find_opts) -exec cat '{}' ';' \
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' \
38
43
| egrep $(cdbs_copyright-check_egrep_opts) \
39
44
| sed -e 's/^[[:space:]*#]*//' -e 's/[[:space:]]*$$//' \
40
45
| LC_ALL=C sort -u \
41
46
> debian/copyright_newhints
42
if [ ! -f debian/copyright_hints ]; then touch debian/copyright_hints; fi
43
@echo "diff --normal debian/copyright_hints debian/copyright_newhints | egrep '^>'"
44
@diff --normal debian/copyright_hints debian/copyright_newhints | egrep '^>'; \
45
if [ "$$?" -eq "0" ]; then \
46
echo "New or changed copyright notices discovered! Do this:"; \
47
echo " 1) Search source for each of the above lines ('grep -r' is your friend)"; \
48
echo " 2) Update debian/copyright as needed"; \
49
echo " 3) Replace debian/copyright_hints with 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"; \
53
62
@echo 'No new copyright notices found - assuming no news is good news...'
54
63
rm -f debian/copyright_newhints
67
rm -f debian/stamp-copyright-check