Subject: Bug#472199: Generate machine readable copyright file

From: Reinhard Tartler <[email-masked]>
Date: Mon, 05 Apr 2010 09:48:53 +0200

Package: devscripts
Severity: normal

While discussing the topic of using cdbs on pkg-multimedia, I found that
there are some interesting bits in cdbs that might have a better home in
the devscripts package. Among others is the licensecheck2dep5 scripts,
which can be found attached. It is driven by this rules in
1/rules/utils.mk, which can be trivially translated to shell or perl

,----[excerpt from 1/rules/utils.mk.in
| debian/stamp-copyright-check:
| 	@set -e; if [ ! -f debian/copyright_hints ]; then \
| 		echo; \
| 		echo '$(if $(DEB_COPYRIGHT_CHECK_STRICT),ERROR,WARNING): copyright-check disabled - touch debian/copyright_hints to enable.'; \
| 		echo; \
| 		$(if $(DEB_COPYRIGHT_CHECK_STRICT),exit 1,:); \
| 	elif [ licensecheck = $(DEB_COPYRIGHT_CHECK_SCRIPT) ] && ! which licensecheck > /dev/null; then \
| 		echo; \
| 		echo '$(if $(DEB_COPYRIGHT_CHECK_STRICT),ERROR,WARNING): copyright-check disabled - licensecheck (from devscripts package) is missing.'; \
| 		echo; \
| 		$(if $(DEB_COPYRIGHT_CHECK_STRICT),exit 1,:); \
| 	elif [ licensecheck = $(DEB_COPYRIGHT_CHECK_SCRIPT) ] && ! licensecheck --help | grep -qv -- --copyright; then \
| 		echo; \
| 		echo '$(if $(DEB_COPYRIGHT_CHECK_STRICT),ERROR,WARNING): copyright-check disabled - licensecheck (from devscripts package) seems older than needed 2.10.7.'; \
| 		echo; \
| 		$(if $(DEB_COPYRIGHT_CHECK_STRICT),exit 1,:); \
| 	else \
| 		echo; \
| 		echo 'Scanning upstream source for new/changed copyright notices...'; \
| 		echo; \
| 		echo "$(DEB_COPYRIGHT_CHECK_INVOKE) | $(_cdbs_scripts_path)/licensecheck2dep5 > debian/copyright_newhints"; \
| 		export LC_ALL=C; \
| 		$(DEB_COPYRIGHT_CHECK_INVOKE) | $(_cdbs_scripts_path)/licensecheck2dep5 > debian/copyright_newhints; \
| 		echo "`grep -c ^Files: debian/copyright_hints` combinations of copyright and licensing found."; \
| 		newstrings=`diff -a -u debian/copyright_hints debian/copyright_newhints | sed '1,2d' | egrep -a '^\+' - | sed 's/^\+//'`; \
| 		if [ -n "$$newstrings" ]; then \
| 			echo "$(if $(DEB_COPYRIGHT_CHECK_STRICT),ERROR,WARNING): The following (and possibly more) new or changed notices discovered:"; \
| 			echo; \
| 			echo "$$newstrings" \
| 				| perl -ne '/^.{0,60}$$/ or s/^(.{0,60})\b.*$$/$$1…/;s/[^[:print:][:space:]…]//g;$$_ ne $$prev and (($$prev) = $$_) and print' \
| 				| sort -m \
| 				| head -n 200; \
| 			echo; \
| 			echo "To fix the situation please do the following:"; \
| 			echo "  1) Fully compare debian/copyright_hints with debian/copyright_newhints"; \
| 			echo "  2) Update debian/copyright as needed"; \
| 			echo "  3) Replace debian/copyright_hints with debian/copyright_newhints"; \
| 			$(if $(DEB_COPYRIGHT_CHECK_STRICT),exit 1,:); \
| 		else \
| 			echo 'No new copyright notices found - assuming no news is good news...'; \
| 		fi; \
| 		rm -f debian/copyright_newhints; \
| 	fi
| 	touch $@
`----

Please consider merging this into the devscripts package.

I also not that an alternate implementation has been posted to this bug,
which I haven't examined yet. This shows that there is (some) common
interest in this functionality.

-- System Information:
Debian Release: squeeze/sid
  APT prefers lucid-updates
  APT policy: (500, 'lucid-updates'), (500, 'lucid')
Architecture: i386 (i686)