Debian Codegraph @

debian/copyright-check

raw
1 #!/bin/sh
2 # Copyright 2020, 2022-2023 Jonas Smedegaard <[email protected]>
3 # Copyright 2020, 2022 Purism, SPC
4 # Description: helper script to update copyright_hints
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
9 # any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 # Depends:
20 # licensecheck,
21 # libimage-exiftool-perl,
22
23 set -eu
24
25 SKIPFILES='skip|meta'
26
27 # cleanup stray hint files from a previous run
28 find ./* -type f -regextype posix-egrep -regex "^\./.*:($SKIPFILES)$" -delete
29
30 1>&2 echo 'skip binary files without parsable metadata ...'
31 RE_skip='.*\.(icns|nib|pbxproj|plist|strings)'
32 find ./* -type f -regextype posix-egrep -regex "^\./($RE_skip)$" -exec sh -c 'echo "License: UNKNOWN" > "$1:skip"' shell {} ';'
33
34 1>&2 echo 'extract metadata from binary files ...'
35 EXT_meta='gif tiff'
36 RE_meta=$(echo "$EXT_meta" | perl -aE '$"="|";say ".*\\.(@F)|Resource/Font/.*"') #"
37 exiftool '-textOut!' %d%f.%e:meta -short -short -recurse -extractEmbedded $(echo "$EXT_meta" | perl -aE 'say map {" -ext $_"} @F') -- ./*
38
39 RE_SKIP="$RE_skip|$RE_meta"
40
41 # skip non-copyright-protected Debian files
42 RE_debian='debian/(changelog|copyright(_hints)?|source/lintian-overrides)'
43
44 # check for copyright and licensing statements
45 licensecheck --copyright --deb-machine --recursive --lines 0 --check '.*' --ignore "^($RE_SKIP|$RE_debian)$" -- * > debian/copyright_hints
46
47 # tidy listing of diverted files
48 sed -i -e 's/:meta$//' -e 's/:skip$//' debian/copyright_hints
49
50 # cleanup hint files
51 find ./* -type f -regextype posix-egrep -regex "^\./.*:($SKIPFILES)$" -delete