common/tools/ats/hlm_fix_pkg_files.pl
changeset 1119 9d4b5a298764
equal deleted inserted replaced
1118:abbcac685ab1 1119:9d4b5a298764
       
     1 #!/usr/bin/perl
       
     2 
       
     3 # Copyright (c) 2009 Symbian Foundation Ltd
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of the License "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Symbian Foundation Ltd - initial contribution.
       
    11 #   Maciej Seroka, maciej@symbian.org
       
    12 #
       
    13 # Description:
       
    14 #   This is a script for fixing pkg files.
       
    15 
       
    16 use strict;
       
    17 use File::Copy;
       
    18 use Tie::File;
       
    19 use File::Find;
       
    20 
       
    21 my @files;
       
    22 my @lines;
       
    23 my $file;
       
    24 my $n;
       
    25 my $file_fixed;
       
    26 sub Wanted;
       
    27 
       
    28 my $package_path;
       
    29 if ($ARGV[0]) {
       
    30   $package_path = $ARGV[0];
       
    31  }
       
    32 else { die "Missing parameter \"package path\". For example: D:\\sf\\app\\musicplayer"; }
       
    33 
       
    34 find(\&Wanted, $package_path);
       
    35 
       
    36 #Copy a pkg file and replace \armv5\urel with $(platform)\$(target)
       
    37 foreach $file (@files) { #Replace "//v800020/Publish" with "http://cdn.symbian,org"
       
    38 	copy($file,$file . ".orig") or die ("Cannot copy file \"$file\". $!\n");
       
    39 	tie (@lines, 'Tie::File', $file, recsep => "\n") or die ("Cannot tie file \"$file\". $!\n");
       
    40 	$n = 0;
       
    41 	$file_fixed = 0;
       
    42 	foreach (@lines) {
       
    43 		if (lc(@lines[$n]) =~ m/epoc32\\release\\armv5\\urel\\/) {
       
    44 			@lines[$n] = lc(@lines[$n]);
       
    45 			@lines[$n] =~ s/\\armv5\\urel\\/\\\$(platform)\\\$(target)\\/;
       
    46 			$file_fixed = 1;
       
    47 		}
       
    48 		if (lc(@lines[$n]) =~ m/epoc32\\release\\armv5\\udeb\\/) {
       
    49 			@lines[$n] = lc(@lines[$n]);
       
    50 			@lines[$n] =~ s/\\armv5\\udeb\\/\\\$(platform)\\\$(target)\\/;
       
    51 			$file_fixed = 1;
       
    52 		}
       
    53 		$n++;
       
    54 	}
       
    55 	if ($file_fixed) { print $file . " fixed.\n"; }
       
    56 	untie @lines;
       
    57 }
       
    58 
       
    59 sub Wanted {
       
    60     # only operate on .pkg files
       
    61 	/.pkg$/ or return;
       
    62     push (@files, $File::Find::name);
       
    63 }