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 # Koha is free software; you can redistribute it and/or modify it
16 # under the terms of the GNU General Public License as published by
17 # the Free Software Foundation; either version 3 of the License, or
18 # (at your option) any later version.
20 # Koha is distributed in the hope that it will be useful, but
21 # 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
26 # along with Koha; if not, see <http://www.gnu.org/licenses>.
32 use File
::Temp qw
/ tempfile /;
35 my $temple = << 'eof';
36 You should have received a copy of the GNU General Public License along with
37 Koha
; if not, write to the Free Software Foundation
, Inc
., 59 Temple Place
,
38 Suite
330, Boston
, MA
02111-1307 USA
41 my $franklin = << 'eof';
42 You should have received a copy of the GNU General Public License along
43 with Koha
; if not, write to the Free Software Foundation
, Inc
.,
44 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301 USA
.
48 my $temple2 = << 'eof';
49 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
,
50 Suite
330, Boston
, MA
02111-1307 USA
53 my $franklin2 = << 'eof';
54 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
,
55 Fifth Floor
, Boston
, MA
02110-1301 USA
.
59 my $temple3 = << 'eof';
60 You should have received a copy of the GNU General Public License
61 along with this program
; if not, write to the Free Software
62 Foundation
, Inc
., 50 Temple Place
, Suite
330, Boston
, MA
02111-1307 USA
65 my $franklin3 = << 'eof';
66 You should have received a copy of the GNU General Public License
67 along with this program
; if not, write to the Free Software Foundation
, Inc
.,
68 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301 USA
.
72 my $temple4 = << 'eof';
73 You should have received a copy of the GNU General Public License
74 along with Zebra
; see the file LICENSE
.zebra
. If
not, write to the
75 Free Software Foundation
, 59 Temple Place
- Suite
330, Boston
, MA
79 my $franklin4 = << 'eof';
80 You should have received a copy of the GNU General Public License
81 along with Zebra
; see the file LICENSE
.zebra
. If
not, write to the
82 Free Software Foundation
, 51 Franklin Street
, Fifth Floor
, Boston
,
87 my @patterns = ($temple, $temple2, $temple3, $temple4);
88 my @replacements = ($franklin, $franklin2, $franklin3, $franklin4);
93 my @lines = split /\n/, $str;
95 foreach my $line (@lines) {
96 push @result, "# $line\n";
98 return join "", @result
104 my @lines = split /\n/, $str;
106 foreach my $line (@lines) {
107 push @result, "-- $line\n";
109 return join "", @result
115 open(FILE
, $filename) || die("Can't open $filename for reading");
117 while (my $line = <FILE
>) {
121 return join '', @lines;
126 my ($data, @patterns) = @_;
132 my ($filename, $data) = @_;
133 my ($fh, $tempname) = tempfile
(DIR
=> dirname
($filename));
136 copy
($tempname, $filename);
141 sub fix_temple_street
{
143 my $data = readfile
($filename);
144 my @pats = map { ($_, hashcomment
($_), dashcomment
($_)) } @patterns;
145 my @repls = map { ($_, hashcomment
($_), dashcomment
($_)) } @replacements;
147 my $pat = shift @pats;
148 my $repl = shift @repls;
149 my $index = index($data, $pat);
150 next if $index == -1;
151 my $length = length($pat);
152 my $before = substr($data, 0, $index);
153 my $after = substr($data, $index + $length);
154 overwrite
($filename, "$before$repl$after");
157 die("Cannot find old address in $filename");
161 while (my $filename = <>) {
163 fix_temple_street
($filename);