williamr/convert_to_epl.pl
author William Roberts <williamr@symbian.org>
Mon, 01 Feb 2010 12:04:35 +0000
changeset 139 7b2d146ef884
parent 75 649f18158270
permissions -rw-r--r--
version 0.3 - add command line processing, --dryrun option, --nosrc option Make sure that outstanding unzip commands are completed before unpacking "patch" files Refactor the unzipping, to implement dryrun and give scope for throttling the number of unzips in progress
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
75
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
     1
#!/usr/bin/perl
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
     2
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
     8
#
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    11
# 
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    12
# Contributors:
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    13
#
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    14
# Description:
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    15
# Map the SFL license to the EPL license, keeping a copy of the original file
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    16
# in a parallel tree 
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    17
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    18
use strict;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    19
use File::Copy;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    20
use File::Path;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    21
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    22
if (scalar @ARGV != 2)
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    23
  {
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    24
	print <<'EOF';
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    25
Incorrect number of arguments
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    26
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    27
Usage: perl convert_to_epl.pl workdir savedir
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    28
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    29
Recursively processes workdir to examine all of the text files and convert
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    30
all perfectly formed instances of the SFL copyright notice into EPL notices.
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    31
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    32
If a file is modified, the original is first copied to the corresponding place
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    33
under savedir. 
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    34
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    35
It is safe to rerun this script if it stopped for any reason, as no converted 
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    36
SFL notice will ever match on the second run through.
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    37
EOF
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    38
  exit 1;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    39
  }
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    40
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    41
my $work_root = $ARGV[0];
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    42
my $saved_root = $ARGV[1];
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    43
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    44
$work_root =~ s/\\/\//g;    # convert to Unix separators please
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    45
$saved_root =~ s/\\/\//g;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    46
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    47
print "* Processing $work_root, leaving the original of any modified file in $saved_root\n";
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    48
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    49
my $debug = 0;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    50
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    51
my @oldtext = (
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    52
  'terms of the License "Symbian Foundation License v1.0"',
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    53
  'the URL "http://www.symbianfoundation.org/legal/sfl-v10.html"'
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    54
);
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    55
my @newtext = (
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    56
  'terms of the License "Eclipse Public License v1.0"',
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    57
  'the URL "http://www.eclipse.org/legal/epl-v10.html"'
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    58
);
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    59
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    60
my @errorfiles = ();
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    61
my @multinoticefiles = ();
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    62
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    63
sub map_epl($$$)
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    64
  {
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    65
  my ($file,$shadowdir,$name) = @_;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    66
  
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    67
  open FILE, "<$file" or print "ERROR: Cannot open $file: $!\n" and return "Cannot open";
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    68
  my @lines = <FILE>;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    69
  close FILE;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    70
  
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    71
  my $updated = 0;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    72
  my @newlines = ();
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    73
  while (my $line = shift @lines)
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    74
    { 
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    75
    # under the terms of the License "Symbian Foundation License v1.0"
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    76
    # which accompanies this distribution, and is available
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    77
    # at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    78
    my $pos1 = index $line, $oldtext[0];
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    79
    if ($pos1 >= 0)
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    80
      {
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    81
      # be careful - oldtext is a prefix of newtext!
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    82
      if (index($line, $newtext[0]) >= 0)
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    83
        {
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    84
        # line already converted - nothing to do
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    85
        push @newlines, $line;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    86
        next;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    87
        }
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    88
      my $midline = shift @lines;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    89
      my $urlline = shift @lines;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    90
      my $pos2 = index $urlline, $oldtext[1];
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    91
      if ($pos2 >= 0)
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    92
        {
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    93
        # Found it - assume that there's only one instance
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    94
        substr $line, $pos1, length($oldtext[0]), $newtext[0];
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    95
        substr $urlline, $pos2, length($oldtext[1]), $newtext[1];
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    96
        push @newlines, $line, $midline, $urlline;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    97
        $updated += 1;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    98
        next;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
    99
        }
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   100
      else
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   101
        {
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   102
        if(!$updated)
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   103
          {
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   104
          my $lineno = 1 + (scalar @newlines);
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   105
          print STDERR "Problem in $file at $lineno: incorrectly formatted >\n$line$midline$urlline\n";
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   106
          push @errorfiles, $file;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   107
          }	
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   108
        last;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   109
        }
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   110
      }
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   111
    push @newlines, $line;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   112
    }
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   113
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   114
  return if (!$updated);
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   115
  
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   116
  if ($updated > 1)
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   117
    {
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   118
    push @multinoticefiles, $file;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   119
    print "! found $updated SFL notices in $file\n";
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   120
    }
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   121
 
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   122
  mkpath($shadowdir, {verbose=>0});
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   123
  move($file, "$shadowdir/$name") or die("Cannot move $file to $shadowdir/$name: $!\n");
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   124
  open NEWFILE, ">$file" or die("Cannot overwrite $file: $!\n");
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   125
  print NEWFILE @newlines, @lines;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   126
  close NEWFILE or die("Failed to update $file: $!\n");
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   127
  print "* updated $file\n";
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   128
  }
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   129
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   130
# Process tree
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   131
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   132
sub scan_directory($$)
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   133
  {
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   134
  my ($path, $shadow) = @_;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   135
  
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   136
  opendir DIR, $path;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   137
  my @files = grep !/^\.\.?$/, readdir DIR;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   138
  closedir DIR;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   139
  
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   140
  foreach my $file (@files)
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   141
    {
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   142
    my $newpath = "$path/$file";
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   143
    my $newshadow = "$shadow/$file";
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   144
    
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   145
    if (-d $newpath)
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   146
      {
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   147
      scan_directory($newpath, $newshadow);
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   148
      next;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   149
      }
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   150
    next if (-B $newpath);  # ignore binary files
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   151
    
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   152
    map_epl($newpath, $shadow, $file);
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   153
    }
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   154
  }
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   155
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   156
scan_directory($work_root, $saved_root);
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   157
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   158
printf "%d problem files\n", scalar @errorfiles;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   159
print "\t", join("\n\t", @errorfiles), "\n";
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   160
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   161
printf "%d files with multiple notices\n", scalar @multinoticefiles;
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   162
print "\t", join("\n\t", @multinoticefiles), "\n";
649f18158270 Version of convert_to_eula.pl which converts SFL to EPL - takes the directories to be processed as arguments
William Roberts <williamr@symbian.org>
parents:
diff changeset
   163