common/tools/ats/hlm_prep_package.pl
author Johan Groth <johan.groth@cell-telecom.com>
Tue, 06 Jul 2010 16:30:27 +0100
changeset 1151 b15dfb01fee6
parent 1150 50e59fd71bf2
child 1155 1bd0e92dbd45
permissions -rw-r--r--
Updated rev to 3.0.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1140
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     1
#!/usr/bin/perl
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     2
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     8
#
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    11
#   Maciej Seroka, maciej@symbian.org
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    12
#
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    13
# Description:
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    14
#   This is a script for fixing pkg and ini files.
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    15
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    16
use strict;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    17
use File::Copy;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    18
use Tie::File;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    19
use File::Find;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    20
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    21
my @files;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    22
my @ini_files;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    23
my @lines;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    24
my $file;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    25
my $n;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    26
my $file_fixed;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    27
sub Wanted;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    28
sub Parse_ini;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    29
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    30
my $package_path;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    31
if ($ARGV[0]) {
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    32
  $package_path = $ARGV[0];
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    33
 }
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    34
else { die "Missing parameter \"package path\". For example: D:\\sf\\app\\musicplayer"; }
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    35
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    36
find(\&Wanted, $package_path);
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    37
1150
50e59fd71bf2 Added comments in hlm_prep_package script
Maciej Seroka <maciejs@symbian.org>
parents: 1140
diff changeset
    38
#Copy a pkg file and replace \armv5\urel with $(platform)\$(target)
1140
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    39
foreach $file (@files) { #Replace "//v800020/Publish" with "http://cdn.symbian,org"
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    40
	copy($file,$file . ".orig") or die ("Cannot copy file \"$file\". $!\n");
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    41
	tie (@lines, 'Tie::File', $file, recsep => "\n") or die ("Cannot tie file \"$file\". $!\n");
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    42
	$n = 0;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    43
	$file_fixed = 0;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    44
	foreach (@lines) {
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    45
		if (lc(@lines[$n]) =~ m/epoc32\\release\\armv5\\urel\\/) {
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    46
			@lines[$n] = lc(@lines[$n]);
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    47
			@lines[$n] =~ s/\\armv5\\urel\\/\\\$(platform)\\\$(target)\\/;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    48
			$file_fixed = 1;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    49
		}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    50
		if (lc(@lines[$n]) =~ m/epoc32\\release\\armv5\\udeb\\/) {
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    51
			@lines[$n] = lc(@lines[$n]);
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    52
			@lines[$n] =~ s/\\armv5\\udeb\\/\\\$(platform)\\\$(target)\\/;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    53
			$file_fixed = 1;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    54
		}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    55
		$n++;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    56
	}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    57
	if ($file_fixed) { print $file . " fixed.\n"; }
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    58
	untie @lines;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    59
}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    60
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    61
find(\&Parse_ini, $package_path);
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    62
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    63
foreach $file (@ini_files) {
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    64
	if ($file =~ m/\/init\//) { # Only operate on files from /init/ directories
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    65
		copy($file,$file . ".orig") or die ("Cannot copy file \"$file\". $!\n");
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    66
		tie (@lines, 'Tie::File', $file, recsep => "\n") or die ("Cannot tie file \"$file\". $!\n");
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    67
		$n = 0;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    68
		$file_fixed = 0;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    69
		foreach (@lines) {
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    70
			if (lc(@lines[$n]) =~ m/^separateprocesses/) {
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    71
				@lines[$n] = '#' . @lines[$n];
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    72
				$file_fixed = 1;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    73
			}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    74
			if (lc(@lines[$n]) =~ m/^uitestingsupport/) {
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    75
				@lines[$n] = '#' . @lines[$n];
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    76
				$file_fixed = 1;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    77
			}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    78
			$n++;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    79
		}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    80
		if ($file_fixed) { print $file . " fixed.\n"; }
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    81
		untie @lines;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    82
	}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    83
}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    84
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    85
sub Wanted {
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    86
    # only operate on .pkg files
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    87
	/.pkg$/ or return;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    88
    push (@files, $File::Find::name);
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    89
}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    90
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    91
sub Parse_ini {
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    92
    # only operate on .ini files
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    93
	/\.ini$/ or return;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    94
    push (@ini_files, $File::Find::name);
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    95
}