3 # Fix GPLv2 license blurbs that have the old FSF address at Temple Street,
4 # instead of the Franklin Street one. Files to be fixed are read from
5 # stdin. Typical usage would be:
7 # ./xt/find-license-problems . |
8 # grep -vFx -f ./xt/fix-old-fsf-address.exclude |
9 # ./xt/fix-old-fsf-address
11 # Copyright 2010 Catalyst IT Ltd
13 # This file is part of Koha.
15 # This program is free software; you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation; either version 2 of the License, or
18 # (at your option) any later version.
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License along
26 # with this program; if not, write to the Free Software Foundation, Inc.,
27 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
35 use File
::Temp qw
/ tempfile /;
38 my $temple = << 'eof';
39 You should have received a copy of the GNU General Public License along with
40 Koha
; if not, write to the Free Software Foundation
, Inc
., 59 Temple Place
,
41 Suite
330, Boston
, MA
02111-1307 USA
44 my $franklin = << 'eof';
45 You should have received a copy of the GNU General Public License along
46 with Koha
; if not, write to the Free Software Foundation
, Inc
.,
47 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301 USA
.
51 my $temple2 = << 'eof';
52 You should have received a copy of the GNU General Public License along with Koha
; if not, write to the Free Software Foundation
, Inc
., 59 Temple Place
,
53 Suite
330, Boston
, MA
02111-1307 USA
56 my $franklin2 = << 'eof';
57 You should have received a copy of the GNU General Public License along with Koha
; if not, write to the Free Software Foundation
, Inc
., 51 Franklin Street
,
58 Fifth Floor
, Boston
, MA
02110-1301 USA
.
62 my $temple3 = << 'eof';
63 You should have received a copy of the GNU General Public License
64 along with this program
; if not, write to the Free Software
65 Foundation
, Inc
., 50 Temple Place
, Suite
330, Boston
, MA
02111-1307 USA
68 my $franklin3 = << 'eof';
69 You should have received a copy of the GNU General Public License
70 along with this program
; if not, write to the Free Software Foundation
, Inc
.,
71 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301 USA
.
75 my $temple4 = << 'eof';
76 You should have received a copy of the GNU General Public License
77 along with Zebra
; see the file LICENSE
.zebra
. If
not, write to the
78 Free Software Foundation
, 59 Temple Place
- Suite
330, Boston
, MA
82 my $franklin4 = << 'eof';
83 You should have received a copy of the GNU General Public License
84 along with Zebra
; see the file LICENSE
.zebra
. If
not, write to the
85 Free Software Foundation
, 51 Franklin Street
, Fifth Floor
, Boston
,
90 my @patterns = ($temple, $temple2, $temple3, $temple4);
91 my @replacements = ($franklin, $franklin2, $franklin3, $franklin4);
96 my @lines = split /\n/, $str;
98 foreach my $line (@lines) {
99 push @result, "# $line\n";
101 return join "", @result
107 my @lines = split /\n/, $str;
109 foreach my $line (@lines) {
110 push @result, "-- $line\n";
112 return join "", @result
118 open(FILE
, $filename) || die("Can't open $filename for reading");
120 while (my $line = <FILE
>) {
124 return join '', @lines;
129 my ($data, @patterns) = @_;
135 my ($filename, $data) = @_;
136 my ($fh, $tempname) = tempfile
(DIR
=> dirname
($filename));
139 copy
($tempname, $filename);
144 sub fix_temple_street
{
146 my $data = readfile
($filename);
147 my @pats = map { ($_, hashcomment
($_), dashcomment
($_)) } @patterns;
148 my @repls = map { ($_, hashcomment
($_), dashcomment
($_)) } @replacements;
150 my $pat = shift @pats;
151 my $repl = shift @repls;
152 my $index = index($data, $pat);
153 next if $index == -1;
154 my $length = length($pat);
155 my $before = substr($data, 0, $index);
156 my $after = substr($data, $index + $length);
157 overwrite
($filename, "$before$repl$after");
160 die("Cannot find old address in $filename");
164 while (my $filename = <>) {
166 fix_temple_street
($filename);