common/sysdefdowngrade/sysdefdowngrade.pl
author MattD <mattd@symbian.org>
Fri, 16 Oct 2009 14:57:32 +0100
changeset 684 6d65abb8bba1
parent 319 257557b39754
permissions -rw-r--r--
sf-run-evalid - minor change to make sure that evalid is run at the root of the build drive, which can stop the MD5s from being generated. (evalid requires dirs to be relative and not absolute)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
319
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     6
#
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     9
#
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    10
# Contributors:
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    11
#
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    12
# Description:
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    13
# Extracts output text in <buildlog> context which doesn't belong to <recipe>'s
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    14
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    15
use strict;
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    16
use Getopt::Long;
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    17
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    18
my $XALAN_PATH = "xalan-j_2_7_1";
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    19
my $XSLT_FILE = "sysdefdowngrade.xsl";
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    20
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    21
my $modelfile = '';
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    22
my $csvsourcesfile = '';
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    23
my $help = 0;
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    24
GetOptions((
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    25
	'model=s' => \$modelfile,
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    26
	'sources=s' => \$csvsourcesfile,
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    27
	'help!' => \$help
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    28
));
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    29
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    30
$help = 1 if (!$modelfile or !$csvsourcesfile);
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    31
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
if ($help)
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
{
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
	print "Checks that a model file is not in version 3.0.0. If it is transforms it to a version usable by Raptor\n";
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
	print "Usage: perl sysdefdowngrade.pl --model=MODELFILE --sources=SOURCESFILE\n\n";
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
	exit(0);
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    37
}
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    38
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    39
my $isversion3 = 0;
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
open(MODELFILE, "$modelfile") or die("Can't open model file $modelfile");
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    41
while(<MODELFILE>)
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    42
{
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
	if ($_ =~ /<SystemDefinition schema="3\.0\.0"/)
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
	{
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    45
		$isversion3 = 1;
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    46
		last;
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    47
	}
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    48
}
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    49
close(MODELFILE);
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    50
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    51
if (!$isversion3)
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    52
{
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    53
	print "Model file is not version 3.0.0. Nothing to do.";
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    54
	exit(0);
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    55
}
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    56
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    57
my $param_path = '';
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    58
open(SOURCESFILE, "$csvsourcesfile") or die("Can't open sources file $csvsourcesfile");
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    59
while(<SOURCESFILE>)
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    60
{
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    61
	if ($_ =~ m{[^,]*,([\\/]sf[\\/][^,]*),[^,]*,[^,]*,[^,]*})
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    62
	{
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    63
		$param_path = $1;
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    64
		#print "param_path= $param_path\n";
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    65
		last;
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    66
	}
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    67
}
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    68
close(SOURCESFILE);
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    69
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    70
if (!$param_path)
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    71
{
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    72
	print "Error: could not determine path parameter from sources file. Quitting.\n";
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    73
	exit(0);
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    74
}
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    75
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    76
$param_path =~ s,\\,/,g;
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    77
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    78
my $transformcmd = "java -jar $XALAN_PATH\\xalan.jar -xsl $XSLT_FILE -in $modelfile -out $modelfile.transformed";
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
$transformcmd .= " -param Path $param_path";
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    80
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    81
print "Executing: $transformcmd\n";
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    82
system("$transformcmd");
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    83
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    84
# ren doesn't work with forward slashes
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    85
$modelfile =~ s,/,\\,g;
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    86
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    87
$modelfile =~ m,.*[\\/](.*),;
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    88
my $modelfile_name = $1;
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    89
print "Executing: ren $modelfile $modelfile_name.orig\n";
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    90
system("ren $modelfile $modelfile_name.orig");
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    91
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    92
print "Executing: ren $modelfile.transformed $modelfile_name\n";
257557b39754 Added transformation of model file from version 3.0.0 to a version usable by Raptor
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    93
system("ren $modelfile.transformed $modelfile_name");