Bug 18309: UNIMARC update from IFLA - authority (fr) (FA)
[koha.git] / xt / find-license-problems
blobc18f2c195a19644243fd5799a0ce21e2ee7dd052
1 #!/usr/bin/perl
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.
8 # Copyright 2010 Catalyst IT Ltd
10 # This file is part of Koha.
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.
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.
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.
27 use Modern::Perl;
29 use File::Find;
32 my @files;
33 sub wanted {
34 my $name = $File::Find::name;
35 push @files, $name
36 unless $name =~ /\/(\.git|koha-tmpl)(\/.*)?$/ ||
37 $name =~ /\.(gif|jpg|odt|ogg|pdf|png|po|psd|svg|swf|zip)$/ ||
38 ! -f $name;
42 sub has_gpl2plus_and_current_fsf_address {
43 my ($name) = @_;
44 my $hascopyright;
45 my $hasgpl;
46 my $hasv2;
47 my $hasorlater;
48 my $hasfranklinst;
49 open(FILE, $name) || return 0;
50 while (my $line = <FILE>) {
51 $hascopyright = 1 if ($line =~ /Copyright.*\d\d/);
52 $hasgpl = 1 if ($line =~ /GNU General Public License/);
53 $hasv2 = 1 if ($line =~ /either version 2/);
54 $hasorlater = 1 if ($line =~ /any later version/ ||
55 $line =~ /at your option/);
56 $hasfranklinst = 1 if ($line =~ /51 Franklin Street/);
58 return ! $hascopyright ||
59 ($hasgpl && $hasv2 && $hasorlater && $hasfranklinst);
63 find({ wanted => \&wanted, no_chdir => 1 }, @ARGV);
64 foreach my $name (@files) {
65 if (! has_gpl2plus_and_current_fsf_address($name)) {
66 print "$name\n";