#!/bin/sh

set -eu

# cleanup stray hint files from a previous run
find -type f -name '*:skip' -delete

1>&2 echo 'omit files unlikely to contain copyright or license info ...'
RE_omit='Resource/.*\.(ics|json|txt|vcf|xml)|Resource/CalDAV/errors/calendar\.1000\.tgz'

# omit non-copyright-protected Debian files
RE_debian='debian/(changelog|copyright(-check|_hints)?|source/lintian-overrides)'

1>&2 echo 'check for copyright and licensing statements ...'
licensecheck --copyright --deb-machine --recursive --lines 0 --check '.*' --ignore "^($RE_omit|$RE_debian)$" -- * > debian/copyright_hints

# tidy listing of diverted files
sed -i -e 's/:skip$//' debian/copyright_hints

# cleanup hint files
find -type f -name '*:skip' -delete
