common/tools/ats/hlm_prep_package.pl
author Dario Sestito <darios@symbian.org>
Mon, 12 Jul 2010 12:02:01 +0100
changeset 1163 b60154bd7ef7
parent 1155 1bd0e92dbd45
child 1209 10d9bc494ce9
permissions -rw-r--r--
Fix: envinfo in bit database is reversed
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;
1155
1bd0e92dbd45 Updated hlm_prep_package to replace e: with c: drive in pkg files
Maciej Seroka <maciejs@symbian.org>
parents: 1150
diff changeset
    44
	print @lines[49] . "\n";
1140
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    45
	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
    46
		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
    47
			@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
    48
			@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
    49
			$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
    50
		}
1155
1bd0e92dbd45 Updated hlm_prep_package to replace e: with c: drive in pkg files
Maciej Seroka <maciejs@symbian.org>
parents: 1150
diff changeset
    51
		if (lc(@lines[$n]) =~ m/epoc32\/release\/armv5\/urel\//) {
1bd0e92dbd45 Updated hlm_prep_package to replace e: with c: drive in pkg files
Maciej Seroka <maciejs@symbian.org>
parents: 1150
diff changeset
    52
			@lines[$n] = lc(@lines[$n]);
1bd0e92dbd45 Updated hlm_prep_package to replace e: with c: drive in pkg files
Maciej Seroka <maciejs@symbian.org>
parents: 1150
diff changeset
    53
			@lines[$n] =~ s/\/armv5\/urel\//\/\$(platform)\/\$(target)\//;
1bd0e92dbd45 Updated hlm_prep_package to replace e: with c: drive in pkg files
Maciej Seroka <maciejs@symbian.org>
parents: 1150
diff changeset
    54
			$file_fixed = 1;
1bd0e92dbd45 Updated hlm_prep_package to replace e: with c: drive in pkg files
Maciej Seroka <maciejs@symbian.org>
parents: 1150
diff changeset
    55
		}
1140
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    56
		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
    57
			@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
    58
			@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
    59
			$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
    60
		}
1155
1bd0e92dbd45 Updated hlm_prep_package to replace e: with c: drive in pkg files
Maciej Seroka <maciejs@symbian.org>
parents: 1150
diff changeset
    61
#		if (lc(@lines[$n]) =~ m/e:\\/) { # Replace e: with c:
1bd0e92dbd45 Updated hlm_prep_package to replace e: with c: drive in pkg files
Maciej Seroka <maciejs@symbian.org>
parents: 1150
diff changeset
    62
#			@lines[$n] = lc(@lines[$n]);
1bd0e92dbd45 Updated hlm_prep_package to replace e: with c: drive in pkg files
Maciej Seroka <maciejs@symbian.org>
parents: 1150
diff changeset
    63
#			@lines[$n] =~ s/e:\\/c:\\/;
1bd0e92dbd45 Updated hlm_prep_package to replace e: with c: drive in pkg files
Maciej Seroka <maciejs@symbian.org>
parents: 1150
diff changeset
    64
#			$file_fixed = 1;
1bd0e92dbd45 Updated hlm_prep_package to replace e: with c: drive in pkg files
Maciej Seroka <maciejs@symbian.org>
parents: 1150
diff changeset
    65
#		}
1140
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    66
		$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
	}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    68
	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
    69
	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
    70
}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    71
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    72
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
    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
foreach $file (@ini_files) {
1155
1bd0e92dbd45 Updated hlm_prep_package to replace e: with c: drive in pkg files
Maciej Seroka <maciejs@symbian.org>
parents: 1150
diff changeset
    75
	if ((lc($file) =~ m/\/init\//) || (lc($file) =~ m/\/group\//)) { # Only operate on files from /init/ directories
1140
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    76
		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
    77
		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
    78
		$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
    79
		$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
    80
		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
    81
			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
    82
				@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
    83
				$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
    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
			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
    86
				@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
    87
				$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
    88
			}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    89
			$n++;
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
		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
    92
		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
    93
	}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    94
}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    95
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    96
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
    97
    # 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
    98
	/.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
    99
    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
   100
}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   101
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   102
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
   103
    # 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
   104
	/\.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
   105
    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
   106
}