common/tools/ats/hlm_prep_package.pl
author Maciej Seroka <maciejs@symbian.org>
Thu, 12 Aug 2010 12:46:48 +0100
changeset 1188 10d9bc494ce9
parent 1143 1bd0e92dbd45
permissions -rw-r--r--
Modified hlm_prep_package to accept sources.csv file as parameter
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1119
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;
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    17
use Getopt::Long;
1119
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 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
    19
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
    20
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
    21
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    22
my $package_path;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    23
my @pkg_paths; # Array needed as csv file may contain more than one.
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    24
my $pkg_path_num = 1; # By default at least one needs to be provided.
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    25
my $csv_file;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    26
my $bld_drive;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    27
my $line;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    28
my $help;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    29
my $repo;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    30
my $destination;
1119
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    31
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
    32
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
    33
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
    34
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
    35
my $n;
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    36
my $current_iteration;
1119
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    37
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
    38
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
    39
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
    40
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    41
sub usage($);
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    42
sub help();
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    43
sub usage_error();
1119
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    44
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    45
my %optmap = (  'package-path' => \$package_path,
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    46
			    'csv-file' => \$csv_file,
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    47
				'bld-drive' => \$bld_drive,
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    48
				'help' => \$help);
1119
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    49
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    50
GetOptions(\%optmap,
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    51
          'package-path=s',
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    52
          'csv-file=s',
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    53
		  'bld-drive=s',
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    54
		  'help!') 
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    55
          or usage_error();
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    56
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    57
if ($help) {
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    58
	help();
1119
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
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    61
usage_error(), unless ((defined($package_path)) || ((defined($csv_file)) && (defined($bld_drive))));
1119
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    62
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    63
if (defined($csv_file)) {
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    64
	$pkg_path_num = 0;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    65
	open FILE, "<$csv_file" or die("Failed to read $csv_file: $!\n");
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    66
	while ($line = <FILE>)
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    67
	{
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    68
		chomp $line;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    69
		($repo,$destination) = split /,/,$line;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    70
		if ((lc($destination) ne "dst") && (lc($destination) ne "")) { 
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    71
#			$package_path = $bld_drive . $destination;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    72
			push @pkg_paths, $bld_drive . $destination;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    73
			$pkg_path_num++;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    74
#			last; 
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    75
		}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    76
		
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    77
	}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    78
	close FILE;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    79
}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    80
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    81
$current_iteration = 0;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    82
while ($current_iteration < $pkg_path_num) {
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    83
	if (defined($csv_file)) {
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    84
		$package_path = @pkg_paths[$current_iteration];
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    85
	}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    86
	print "Processing: $package_path \n";
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    87
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    88
	find(\&Wanted, $package_path);
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    89
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    90
	#Copy a pkg file and replace \armv5\urel with $(platform)\$(target)
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    91
	foreach $file (@files) { #Replace "//v800020/Publish" with "http://cdn.symbian,org"
1119
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    92
		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
    93
		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
    94
		$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
    95
		$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
    96
		foreach (@lines) {
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    97
			if (lc(@lines[$n]) =~ m/epoc32\\release\\armv5\\urel\\/) {
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    98
				@lines[$n] = lc(@lines[$n]);
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
    99
				@lines[$n] =~ s/\\armv5\\urel\\/\\\$(platform)\\\$(target)\\/;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   100
				$file_fixed = 1;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   101
			}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   102
			if (lc(@lines[$n]) =~ m/epoc32\/release\/armv5\/urel\//) {
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   103
				@lines[$n] = lc(@lines[$n]);
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   104
				@lines[$n] =~ s/\/armv5\/urel\//\/\$(platform)\/\$(target)\//;
1119
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   105
				$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
   106
			}
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   107
			if (lc(@lines[$n]) =~ m/epoc32\\release\\armv5\\udeb\\/) {
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   108
				@lines[$n] = lc(@lines[$n]);
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   109
				@lines[$n] =~ s/\\armv5\\udeb\\/\\\$(platform)\\\$(target)\\/;
1119
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   110
				$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
   111
			}
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   112
#			if (lc(@lines[$n]) =~ m/e:\\/) { # Replace e: with c:
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   113
#				@lines[$n] = lc(@lines[$n]);
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   114
#				@lines[$n] =~ s/e:\\/c:\\/;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   115
#				$file_fixed = 1;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   116
#			}
1119
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   117
			$n++;
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   118
		}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   119
		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
   120
		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
   121
	}
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   122
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   123
	find(\&Parse_ini, $package_path);
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   124
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   125
	foreach $file (@ini_files) {
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   126
		if ((lc($file) =~ m/\/init\//) || (lc($file) =~ m/\/group\//)) { # Only operate on files from /init/ directories
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   127
			copy($file,$file . ".orig") or die ("Cannot copy file \"$file\". $!\n");
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   128
			tie (@lines, 'Tie::File', $file, recsep => "\n") or die ("Cannot tie file \"$file\". $!\n");
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   129
			$n = 0;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   130
			$file_fixed = 0;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   131
			foreach (@lines) {
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   132
				if (lc(@lines[$n]) =~ m/^separateprocesses/) {
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   133
					@lines[$n] = '#' . @lines[$n];
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   134
					$file_fixed = 1;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   135
				}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   136
				if (lc(@lines[$n]) =~ m/^uitestingsupport/) {
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   137
					@lines[$n] = '#' . @lines[$n];
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   138
					$file_fixed = 1;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   139
				}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   140
				$n++;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   141
			}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   142
			if ($file_fixed) { print $file . " fixed.\n"; }
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   143
			untie @lines;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   144
		}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   145
	}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   146
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   147
	$current_iteration++;
1119
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   148
}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   149
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   150
print "OK\n";
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   151
exit 0;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   152
1119
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   153
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
   154
    # 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
   155
	/.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
   156
    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
   157
}
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   158
8f963b9f9cb4 Replaced hlm_fix_pkg_files with hlm_prep_package to automatically update .ini files
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   159
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
   160
    # 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
   161
	/\.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
   162
    push (@ini_files, $File::Find::name);
1188
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   163
}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   164
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   165
sub usage($)
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   166
{
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   167
    my $error = shift;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   168
    my $fh = $error == 0 ? *STDOUT : *STDERR;
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   169
    print $fh "hlm_prep_package.pl\n" .
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   170
            "Specify package path or csv file\n" .
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   171
            "synopsis:\n" .
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   172
            "  hlm_prep_package.pl --help\n" .
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   173
            "  hlm_prep_package.pl [--package-path=DIR] [--csv-file=FILE] [--bld-drive=DRIVE] \n" .
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   174
            "options:\n" .
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   175
            "  --help                        Display this help and exit.\n" .
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   176
            "  --package-path=DIR            DIR is the package location, e.g. H:\\sf\\app\\musicplayer.\n" .
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   177
            "  --csv-file=FILE               FILE is the full path to the csv file.\n" .
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   178
            "  --bld-drive=DRIVE             DRIVE is the subst'd drive on which the build is stored.\n";
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   179
    exit $error;            
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   180
}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   181
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   182
sub help()
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   183
{
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   184
    usage(0);
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   185
}
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   186
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   187
sub usage_error()
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   188
{
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   189
    usage(1);
10d9bc494ce9 Modified hlm_prep_package to accept sources.csv file as parameter
Maciej Seroka <maciejs@symbian.org>
parents: 1143
diff changeset
   190
}