common/tools/ats/hlm_prep_package.pl
changeset 1140 8f963b9f9cb4
child 1150 50e59fd71bf2
equal deleted inserted replaced
1128:14c8058c3fa1 1140:8f963b9f9cb4
       
     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 and ini files.
       
    15 
       
    16 use strict;
       
    17 use File::Copy;
       
    18 use Tie::File;
       
    19 use File::Find;
       
    20 
       
    21 my @files;
       
    22 my @ini_files;
       
    23 my @lines;
       
    24 my $file;
       
    25 my $n;
       
    26 my $file_fixed;
       
    27 sub Wanted;
       
    28 sub Parse_ini;
       
    29 
       
    30 my $package_path;
       
    31 if ($ARGV[0]) {
       
    32   $package_path = $ARGV[0];
       
    33  }
       
    34 else { die "Missing parameter \"package path\". For example: D:\\sf\\app\\musicplayer"; }
       
    35 
       
    36 find(\&Wanted, $package_path);
       
    37 
       
    38 Copy a pkg file and replace \armv5\urel with $(platform)\$(target)
       
    39 foreach $file (@files) { #Replace "//v800020/Publish" with "http://cdn.symbian,org"
       
    40 	copy($file,$file . ".orig") or die ("Cannot copy file \"$file\". $!\n");
       
    41 	tie (@lines, 'Tie::File', $file, recsep => "\n") or die ("Cannot tie file \"$file\". $!\n");
       
    42 	$n = 0;
       
    43 	$file_fixed = 0;
       
    44 	foreach (@lines) {
       
    45 		if (lc(@lines[$n]) =~ m/epoc32\\release\\armv5\\urel\\/) {
       
    46 			@lines[$n] = lc(@lines[$n]);
       
    47 			@lines[$n] =~ s/\\armv5\\urel\\/\\\$(platform)\\\$(target)\\/;
       
    48 			$file_fixed = 1;
       
    49 		}
       
    50 		if (lc(@lines[$n]) =~ m/epoc32\\release\\armv5\\udeb\\/) {
       
    51 			@lines[$n] = lc(@lines[$n]);
       
    52 			@lines[$n] =~ s/\\armv5\\udeb\\/\\\$(platform)\\\$(target)\\/;
       
    53 			$file_fixed = 1;
       
    54 		}
       
    55 		$n++;
       
    56 	}
       
    57 	if ($file_fixed) { print $file . " fixed.\n"; }
       
    58 	untie @lines;
       
    59 }
       
    60 
       
    61 find(\&Parse_ini, $package_path);
       
    62 
       
    63 foreach $file (@ini_files) {
       
    64 	if ($file =~ m/\/init\//) { # Only operate on files from /init/ directories
       
    65 		copy($file,$file . ".orig") or die ("Cannot copy file \"$file\". $!\n");
       
    66 		tie (@lines, 'Tie::File', $file, recsep => "\n") or die ("Cannot tie file \"$file\". $!\n");
       
    67 		$n = 0;
       
    68 		$file_fixed = 0;
       
    69 		foreach (@lines) {
       
    70 			if (lc(@lines[$n]) =~ m/^separateprocesses/) {
       
    71 				@lines[$n] = '#' . @lines[$n];
       
    72 				$file_fixed = 1;
       
    73 			}
       
    74 			if (lc(@lines[$n]) =~ m/^uitestingsupport/) {
       
    75 				@lines[$n] = '#' . @lines[$n];
       
    76 				$file_fixed = 1;
       
    77 			}
       
    78 			$n++;
       
    79 		}
       
    80 		if ($file_fixed) { print $file . " fixed.\n"; }
       
    81 		untie @lines;
       
    82 	}
       
    83 }
       
    84 
       
    85 sub Wanted {
       
    86     # only operate on .pkg files
       
    87 	/.pkg$/ or return;
       
    88     push (@files, $File::Find::name);
       
    89 }
       
    90 
       
    91 sub Parse_ini {
       
    92     # only operate on .ini files
       
    93 	/\.ini$/ or return;
       
    94     push (@ini_files, $File::Find::name);
       
    95 }