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.
34 use File
::Temp qw
/ tempfile /;
37 my $temple = << 'eof';
38 You should have received a copy of the GNU General Public License along with
39 Koha
; if not, write to the Free Software Foundation
, Inc
., 59 Temple Place
,
40 Suite
330, Boston
, MA
02111-1307 USA
43 my $franklin = << 'eof';
44 You should have received a copy of the GNU General Public License along
45 with Koha
; if not, write to the Free Software Foundation
, Inc
.,
46 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301 USA
.
50 my $temple2 = << 'eof';
51 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
,
52 Suite
330, Boston
, MA
02111-1307 USA
55 my $franklin2 = << 'eof';
56 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
,
57 Fifth Floor
, Boston
, MA
02110-1301 USA
.
61 my $temple3 = << 'eof';
62 You should have received a copy of the GNU General Public License
63 along with this program
; if not, write to the Free Software
64 Foundation
, Inc
., 50 Temple Place
, Suite
330, Boston
, MA
02111-1307 USA
67 my $franklin3 = << 'eof';
68 You should have received a copy of the GNU General Public License
69 along with this program
; if not, write to the Free Software Foundation
, Inc
.,
70 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301 USA
.
74 my $temple4 = << 'eof';
75 You should have received a copy of the GNU General Public License
76 along with Zebra
; see the file LICENSE
.zebra
. If
not, write to the
77 Free Software Foundation
, 59 Temple Place
- Suite
330, Boston
, MA
81 my $franklin4 = << 'eof';
82 You should have received a copy of the GNU General Public License
83 along with Zebra
; see the file LICENSE
.zebra
. If
not, write to the
84 Free Software Foundation
, 51 Franklin Street
, Fifth Floor
, Boston
,
89 my @patterns = ($temple, $temple2, $temple3, $temple4);
90 my @replacements = ($franklin, $franklin2, $franklin3, $franklin4);
95 my @lines = split /\n/, $str;
97 foreach my $line (@lines) {
98 push @result, "# $line\n";
100 return join "", @result
106 my @lines = split /\n/, $str;
108 foreach my $line (@lines) {
109 push @result, "-- $line\n";
111 return join "", @result
117 open(FILE
, $filename) || die("Can't open $filename for reading");
119 while (my $line = <FILE
>) {
123 return join '', @lines;
128 my ($data, @patterns) = @_;
134 my ($filename, $data) = @_;
135 my ($fh, $tempname) = tempfile
(DIR
=> dirname
($filename));
138 copy
($tempname, $filename);
143 sub fix_temple_street
{
145 my $data = readfile
($filename);
146 my @pats = map { ($_, hashcomment
($_), dashcomment
($_)) } @patterns;
147 my @repls = map { ($_, hashcomment
($_), dashcomment
($_)) } @replacements;
149 my $pat = shift @pats;
150 my $repl = shift @repls;
151 my $index = index($data, $pat);
152 next if $index == -1;
153 my $length = length($pat);
154 my $before = substr($data, 0, $index);
155 my $after = substr($data, $index + $length);
156 overwrite
($filename, "$before$repl$after");
159 die("Cannot find old address in $filename");
163 while (my $filename = <>) {
165 fix_temple_street
($filename);