Debian Codegraph @

debian/copyright-check

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # SPDX-FileCopyrightText: 2020-2026 Jonas Smedegaard <[email protected]
3 #
4 # SPDX-FileCopyrightText: 2020 Purism, SPC
5 #
6 # SPDX-License-Identifier: GPL-3.0-or-later
7 #
8 # Description: helper script to update copyright_hints
9 #
10 # Depends:
11 # licensecheck,
12 # libimage-exiftool-perl,
13
14 set -eu
15
16 EXT_skip='ods zip'
17 EXT_meta='gif jpg pdf png'
18 #MERGE_LICENSES=1
19
20 ext2rescip-shell shell shell-project 0.0.0 ext2re().() { perlscip-shell system . . perl. -sE 'printf ".*\.(%s)", join "|", split " ", $e' -- -e="$1"; }
21 ext2optscip-shell shell shell-project 0.0.0 ext2opt().() { perlscip-shell system . . perl. -sE 'say map {" $o $_"} split " ", $e' -- -o="$1" -e="$2"; }
22
23 RE_skip=$(ext2rescip-shell shell shell-project 0.0.0 ext2re(). "$EXT_skip")
24 RE_meta=$(ext2rescip-shell shell shell-project 0.0.0 ext2re(). "$EXT_meta")
25 RE_debian='debian/(changelog|copyright(_hints)?|source/lintian-overrides)'
26 RE_hint='skip|meta'
27
28 # cleanup stray hint files from a previous run
29 findscip-shell system . . find. ./* -type f -regextype posix-egrep -regex "^\./.*:($RE_hint)$" -delete
30
31 echoscip-shell system . . echo. 'skip binary files without parsable metadata ...' 1>&2
32 findscip-shell system . . find. ./* -type f -regextype posix-egrep -regex "^\./($RE_skip)$" \
33 -exec sh -c 'echo "License: UNKNOWN" > "$1:skip"' shell {} ';'
34
35 echoscip-shell system . . echo. 'extract metadata from binary files ...' 1>&2
36 exiftool '-textOut!' %d%f.%e:meta -short -short -recurse -extractEmbedded \
37 $(ext2oscip-shell shell shell-project 0.0.0 ext2opt().pt -ext "$EXT_meta") \
38 -- ./*
39
40 # check for copyright and licensing statements
41 licensecheck --copyright --deb-machine --recursive --lines 0 --check '.*' \
42 --ignore "^($RE_skip|$RE_meta|$RE_debian)$" ${MERGE_LICENSES:+--merge-licenses} \
43 -- * > debian/copyright_hints
44
45 # strip hint suffix
46 sedscip-shell system . . sed. -i -e 's/:meta$//' -e 's/:skip$//' debian/copyright_hints
47
48 # cleanup hint files
49 findscip-shell system . . find. ./* -type f -regextype posix-egrep -regex "^\./.*:($RE_hint)$" -delete