author | William Roberts <williamr@symbian.org> |
Tue, 22 Sep 2009 17:01:01 +0100 | |
changeset 59 | 69e9b8ca3ae9 |
child 60 | e86c659b78a0 |
permissions | -rw-r--r-- |
59
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
1 |
#!/usr/bin/perl |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
2 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
3 |
# Copyright (c) 2009 Symbian Foundation Ltd |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
4 |
# This component and the accompanying materials are made available |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
5 |
# under the terms of the License "Eclipse Public License v1.0" |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
6 |
# which accompanies this distribution, and is available |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
8 |
# |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
9 |
# Initial Contributors: |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
10 |
# Symbian Foundation Ltd - initial contribution. |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
11 |
# |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
12 |
# Contributors: |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
13 |
# |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
14 |
# Description: |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
15 |
# Map the SFL license to the EULA license, keeping a copy of the original file |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
16 |
# in a parallel tree for creation of a "repair" kit to reinstate the SFL |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
17 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
18 |
use strict; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
19 |
use File::Copy; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
20 |
use File::Path; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
21 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
22 |
my $debug = 0; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
23 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
24 |
sub map_eula($$$) |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
25 |
{ |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
26 |
my ($file,$shadowdir,$name) = @_; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
27 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
28 |
open FILE, "<$file" or print "ERROR: Cannot open $file: $!\n" and return "Cannot open"; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
29 |
my @lines = <FILE>; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
30 |
close FILE; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
31 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
32 |
my $updated = 0; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
33 |
my @newlines = (); |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
34 |
while (my $line = shift @lines) |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
35 |
{ |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
36 |
# under the terms of the License "Symbian Foundation License v1.0" |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
37 |
# which accompanies this distribution, and is available |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
38 |
# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
39 |
if ($line =~ /terms of the License "Symbian Foundation License v1.0"/) |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
40 |
{ |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
41 |
my $midline = shift @lines; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
42 |
my $nextline = shift @lines; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
43 |
if ($nextline =~ /the URL "http:\/\/www.symbianfoundation.org\/legal\/sfl-v10.html"/) |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
44 |
{ |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
45 |
# Found it - assume that there's only one instance |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
46 |
$line =~ s/Symbian Foundation License v1.0/Symbian End User License v1.0/; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
47 |
$nextline =~ s/legal\/sfl-v10.html/legal\/eula-v10.html/; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
48 |
push @newlines, $line, $midline, $nextline, @lines; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
49 |
$updated = 1; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
50 |
last; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
51 |
} |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
52 |
else |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
53 |
{ |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
54 |
print STDERR "Problem in $file: incorrectly formatted >\n$line$nextline\n"; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
55 |
last; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
56 |
} |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
57 |
} |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
58 |
push @newlines, $line; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
59 |
} |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
60 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
61 |
return if (!$updated); |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
62 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
63 |
mkpath($shadowdir, {verbose=>0}); |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
64 |
move($file, "$shadowdir/$name") or die("Cannot move $file to $shadowdir/$name: $!\n"); |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
65 |
open NEWFILE, ">$file" or die("Cannot overwrite $file: $!\n"); |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
66 |
print NEWFILE @newlines; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
67 |
close NEWFILE or die("Failed to update $file: $!\n"); |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
68 |
print "* updated $file\n"; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
69 |
} |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
70 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
71 |
# Process tree |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
72 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
73 |
sub scan_directory($$) |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
74 |
{ |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
75 |
my ($path, $shadow) = @_; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
76 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
77 |
opendir DIR, $path; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
78 |
my @files = grep !/^\.\.?$/, readdir DIR; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
79 |
closedir DIR; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
80 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
81 |
foreach my $file (@files) |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
82 |
{ |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
83 |
my $newpath = "$path/$file"; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
84 |
my $newshadow = "$shadow/$file"; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
85 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
86 |
if (-d $newpath) |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
87 |
{ |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
88 |
scan_directory($newpath, $newshadow); |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
89 |
next; |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
90 |
} |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
91 |
next if (-B $newpath); # ignore binary files |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
92 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
93 |
map_eula($newpath, $shadow, $file); |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
94 |
} |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
95 |
} |
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
96 |
|
69e9b8ca3ae9
Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
97 |
scan_directory("/epoc32", "/sfl_epoc32"); |