Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
# |
3 |
# Find copyright and license problems in Koha source files. At this |
4 |
# time it only looks for references to the old FSF address in GPLv2 |
5 |
# license notices, but it might in the future be extended to look for |
6 |
# other things, too. |
7 |
# |
8 |
# Copyright 2010 Catalyst IT Ltd |
9 |
# Copyright 2020 Koha Development Team |
10 |
# |
11 |
# This file is part of Koha. |
12 |
# |
13 |
# Koha is free software; you can redistribute it and/or modify it |
14 |
# under the terms of the GNU General Public License as published by |
15 |
# the Free Software Foundation; either version 3 of the License, or |
16 |
# (at your option) any later version. |
17 |
# |
18 |
# Koha is distributed in the hope that it will be useful, but |
19 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
20 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 |
# GNU General Public License for more details. |
22 |
# |
23 |
# You should have received a copy of the GNU General Public License |
24 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
25 |
|
26 |
use Modern::Perl; |
27 |
use Test::More; |
28 |
|
29 |
use File::Spec; |
30 |
use File::Find; |
31 |
|
32 |
my @files; |
33 |
sub wanted { |
34 |
my $name = $File::Find::name; |
35 |
push @files, $name |
36 |
unless $name =~ /\/(\.git|koha-tmpl|node_modules|swagger-ui)(\/.*)?$/ || |
37 |
$name =~ /\.(gif|jpg|odt|ogg|pdf|png|po|psd|svg|swf|zip|patch)$/ || |
38 |
$name =~ m[(xt/find-license-problems|xt/fix-old-fsf-address)] || |
39 |
! -f $name; |
40 |
} |
41 |
|
42 |
find({ wanted => \&wanted, no_chdir => 1 }, File::Spec->curdir()); |
43 |
|
44 |
foreach my $name (@files) { |
45 |
open( FILE, $name ) || return 0; |
46 |
my ( $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, |
47 |
$hasfranklinst, $is_not_us ) = (0)x7; |
48 |
while ( my $line = <FILE> ) { |
49 |
$hascopyright = 1 if ( $line =~ /^(#|--)?\s*Copyright.*\d\d/ ); |
50 |
$hasgpl = 1 if ( $line =~ /GNU General Public License/ ); |
51 |
$hasv3 = 1 if ( $line =~ /either version 3/ ); |
52 |
$hasorlater = 1 |
53 |
if ( $line =~ /any later version/ |
54 |
|| $line =~ /at your option/ ); |
55 |
$haslinktolicense = 1 if $line =~ m|http://www\.gnu\.org/licenses|; |
56 |
$hasfranklinst = 1 if ( $line =~ /51 Franklin Street/ ); |
57 |
$is_not_us = 1 if $line =~ m|This file is part of the Zebra server|; |
58 |
} |
59 |
next unless $hascopyright; |
60 |
next if $is_not_us; |
61 |
is( $hasgpl |
62 |
&& $hasv3 |
63 |
&& $hasorlater |
64 |
&& $haslinktolicense |
65 |
&& !$hasfranklinst, 1 ) or diag(sprintf "File %s has wrong copyright: hasgpl=%s, hasv3=%s, hasorlater=%s, haslinktolicense=%s, hasfranklinst=%s", $name, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst); |
66 |
} |
67 |
done_testing; |