#!/bin/sh

set -eu

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

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

# extract metadata
exiftool '-textOut!' %d%f.%e:meta --short --short -recurse -ext jpg -ext png .
RE_exif='.*\.(jpg|png)'

licensecheck --copyright --deb-machine --recursive --lines 0 --check '.*' --ignore "^($RE_exif|$RE_debian)$" -- * > debian/copyright_hints

sed -i -e 's/:meta$//' debian/copyright_hints

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