Debian Codegraph @

debian/copyright-check

raw
1 #!/bin/sh
2 # Copyright 2020, 2022-2023, 2025 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 EXT_skip='abw bmp doc hash icns ico odt po session strings xsl zabw'
26 EXT_meta='png tif'
27
28 SKIPFILES='skip|meta'
29
30 # cleanup stray hint files from a previous run
31 find ./* -type f -regextype posix-egrep -regex "^\./.*:($SKIPFILES)$" -delete
32
33 1>&2 echo 'skip binary files without parsable metadata ...'
34 #RE_skip=$(echo "$EXT_skip" | perl -aE '$"="|";say ".*\\.(@F)"') #"
35 RE_skip=$(perl -sE '$e =~ tr/ /|/s; say ".*\\.($e)"' -- -e="$EXT_skip") #"
36 find ./* -type f -regextype posix-egrep -regex "^\./($RE_skip)$" -exec sh -c 'echo "License: UNKNOWN" > "$1:skip"' shell {} ';'
37
38 1>&2 echo 'extract metadata from binary files ...'
39 #RE_meta=$(echo "$EXT_meta" | perl -aE '$"="|";say ".*\\.(@F)"') #"
40 RE_meta=$(perl -sE '$e =~ tr/ /|/s; say ".*\\.($e)"' -- -e="$EXT_meta") #"
41 exiftool '-textOut!' %d%f.%e:meta -short -short -recurse -extractEmbedded $(perl -sE 'say map {" -ext $_"} split " ", $e' -- -e="$EXT_meta") -- ./*
42
43 RE_SKIP="$RE_skip|$RE_meta"
44
45 # skip non-copyright-protected Debian files
46 RE_debian='debian/(changelog|copyright(_hints)?|source/lintian-overrides)'
47
48 # check for copyright and licensing statements
49 licensecheck --merge-licenses --copyright --deb-machine --recursive --lines 0 --check '.*' --ignore "^($RE_SKIP|$RE_debian)$" -- * > debian/copyright_hints
50
51 # tidy listing of diverted files
52 sed -i -e 's/:meta$//' -e 's/:skip$//' debian/copyright_hints
53
54 # cleanup hint files
55 find ./* -type f -regextype posix-egrep -regex "^\./.*:($SKIPFILES)$" -delete