Bug 7864: Reintroduce list of subscribers to a serial alert message
[koha.git] / xt / find-license-problems
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 #
10 # This file is part of Koha.
11 #
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License along
23 # with this program; if not, write to the Free Software Foundation, Inc.,
24 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
26
27 use strict;
28 use warnings;
29
30 use File::Find;
31
32
33 my @files;
34 sub wanted {
35     my $name = $File::Find::name;
36     push @files, $name
37         unless $name =~ /\/(\.git|koha-tmpl)(\/.*)?$/ ||
38                $name =~ /\.(gif|jpg|odt|ogg|pdf|png|po|psd|svg|swf|zip)$/ ||
39                ! -f $name;
40 }
41
42
43 sub has_gpl2plus_and_current_fsf_address {
44     my ($name) = @_;
45     my $hascopyright;
46     my $hasgpl;
47     my $hasv2;
48     my $hasorlater;
49     my $hasfranklinst;
50     open(FILE, $name) || return 0;
51     while (my $line = <FILE>) {
52         $hascopyright = 1 if ($line =~ /Copyright.*\d\d/);
53         $hasgpl = 1 if ($line =~ /GNU General Public License/);
54         $hasv2 = 1 if ($line =~ /either version 2/);
55         $hasorlater = 1 if ($line =~ /any later version/ ||
56                             $line =~ /at your option/);
57         $hasfranklinst = 1 if ($line =~ /51 Franklin Street/);
58     }
59     return ! $hascopyright ||
60            ($hasgpl && $hasv2 && $hasorlater && $hasfranklinst);
61 }
62
63
64 find({ wanted => \&wanted, no_chdir => 1 }, @ARGV);
65 foreach my $name (@files) {
66     if (! has_gpl2plus_and_current_fsf_address($name)) {
67         print "$name\n";
68     }
69 }