File: copyright-check

package info (click to toggle)
basilisk2 0.9.20251105%2Bdfsg-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 16,296 kB
  • sloc: cpp: 222,117; ansic: 48,328; sh: 3,713; asm: 1,904; makefile: 1,332; objc: 752; perl: 198; xml: 16
file content (51 lines) | stat: -rwxr-xr-x 2,063 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
# Copyright 2020, 2022-2023  Jonas Smedegaard <dr@jones.dk>
# Copyright 2020, 2022       Purism, SPC
# Description: helper script to update copyright_hints
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Depends:
#  licensecheck,
#  libimage-exiftool-perl,

set -eu

SKIPFILES='skip|meta'

# cleanup stray hint files from a previous run
find ./* -type f -regextype posix-egrep -regex "^\./.*:($SKIPFILES)$" -delete

1>&2 echo 'skip binary files without parsable metadata ...'
RE_skip='.*\.(icns|nib|pbxproj|plist|strings)'
find ./* -type f -regextype posix-egrep -regex "^\./($RE_skip)$" -exec sh -c 'echo "License: UNKNOWN" > "$1:skip"' shell {} ';'

1>&2 echo 'extract metadata from binary files ...'
EXT_meta='gif tiff'
RE_meta=$(echo "$EXT_meta" | perl -aE '$"="|";say ".*\\.(@F)|Resource/Font/.*"') #"
exiftool '-textOut!' %d%f.%e:meta -short -short -recurse -extractEmbedded $(echo "$EXT_meta" | perl -aE 'say map {" -ext $_"} @F') -- ./*

RE_SKIP="$RE_skip|$RE_meta"

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

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

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

# cleanup hint files
find ./* -type f -regextype posix-egrep -regex "^\./.*:($SKIPFILES)$" -delete