Fix for Bug 6291, Cart printing truncated in Firefox
[koha.git] / xt / find-license-problems
blobd0c5c3059c9dbe1cc3a3d7fab3e8c3c4b0bcffdc
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 strict;
28 use warnings;
30 use File::Find;
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;
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/);
59 return ! $hascopyright ||
60 ($hasgpl && $hasv2 && $hasorlater && $hasfranklinst);
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";