forked from jellyfin/JavascriptSubtitlesOctopus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlicense_lint.awk
More file actions
executable file
·60 lines (50 loc) · 1.09 KB
/
Copy pathlicense_lint.awk
File metadata and controls
executable file
·60 lines (50 loc) · 1.09 KB
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
52
53
54
55
56
57
58
59
60
#!/usr/bin/awk -f
# Copyright 2021 Oneric
# SPDX-License-Identifier: ISC
# Check that we have the full text of all licenses
# being used in the JSO and subprojects
#
# Usage: license_lint.awk <license info files ...> <fulltext file>
function canonicalise_name(l)
{
sub(/\++$/, "", l)
sub(/(.0)+$/, "", l)
return l
}
BEGIN {
FS = ": | and/or "
split("", licenses)
fulltext = 0
errors = 0
}
FNR == 1 && FILENAME == ARGV[ARGC-1] {
fulltext = 1
}
!fulltext && /^License: / {
for(i=2; i<=NF; ++i) {
l = canonicalise_name($2)
++licenses[l]
}
}
fulltext && /^License: / {
for(i=2; i<=NF; ++i) {
l = canonicalise_name($2)
if(!(l in licenses)) {
print "Superfluous full text for '"l"'!" | "cat>&2"
++errors
} else {
delete licenses[l]
}
}
}
END {
for (l in licenses) {
if(l == "public-domain" || l == "Unlicense")
continue # No notice required
print "Missing full text for '"l"'!" | "cat>&2"
++errors
}
if (errors) {
exit 1
}
}