installationservices/swinstallationfw/test/tusif/group/createleesisfiles.pl
changeset 24 84a16765cd86
child 25 98b66e4fb0be
equal deleted inserted replaced
6:aba6b8104af3 24:84a16765cd86
       
     1 #
       
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     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 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: 
       
    15 #
       
    16 
       
    17 
       
    18 use Cwd;
       
    19 use File::Copy;
       
    20 use File::Basename;
       
    21 
       
    22 # Helpers
       
    23 sub ReadFile($);
       
    24 sub WriteFile($$);
       
    25 sub EditFile($$$);
       
    26 
       
    27 print "This script creates SIS files containing LEEs for SIF integration tests\n";
       
    28 
       
    29 my $PLATFORM=@ARGV[0];
       
    30 my $CONFIGURATION=@ARGV[1];
       
    31 
       
    32 my $securitySourceDir = $ENV{SECURITYSOURCEDIR};
       
    33 my $CERTPATH = "$securitySourceDir\\installationservices\\switestfw\\testcertificates\\swi\\test\\tsisfile\\data\\signedsis\\Root5CA\\cert_chain_dsa_len1\\first.dsa.cer";
       
    34 my $KEYPATH = "$securitySourceDir\\installationservices\\swi\\test\\tsisfile\\data\\signedsis\\Root5CA\\cert_chain_dsa_len1\\dsa1.key";
       
    35 my $PKGDIR = "$securitySourceDir\\installationservices\\swinstallationfw\\test\\tusif\\scripts\\data";
       
    36 my $BUILDDIR = "\\epoc32\\release\\$PLATFORM\\$CONFIGURATION";
       
    37 my $DATADIR = "$BUILDDIR\\z\\tusif\\tswtype\\data";
       
    38 my $ARMV5DATADIR = "\\epoc32\\data\\z\\tusif\\tswtype\\data";
       
    39 
       
    40 my $BASE = 'sifswtypebase';
       
    41 my $UPGRADE = 'sifswtypeupgrade';
       
    42 my $suffix = '_edited';
       
    43 
       
    44 # Replace <BUILDMIDPATH> and <ZDRIVEMIDPATH> in the PKG files with the current values
       
    45 my $ZDRIVEMIDPATH = 'data';
       
    46 if (lc($PLATFORM) ne "armv5")
       
    47 	{
       
    48 	$ZDRIVEMIDPATH = "release\\$PLATFORM\\$CONFIGURATION";
       
    49 	}
       
    50 my $BUILDMIDPATH = "release\\$PLATFORM\\$CONFIGURATION";
       
    51 EditFile("$PKGDIR\\$BASE.pkg", "$PKGDIR\\$BASE$suffix.pkg" , sub { s/<BUILDMIDPATH>/$BUILDMIDPATH/gm; s/<ZDRIVEMIDPATH>/$ZDRIVEMIDPATH/gm; });
       
    52 EditFile("$PKGDIR\\$UPGRADE.pkg", "$PKGDIR\\$UPGRADE$suffix.pkg" , sub { s/<BUILDMIDPATH>/$BUILDMIDPATH/gm; s/<ZDRIVEMIDPATH>/$ZDRIVEMIDPATH/gm; });
       
    53 
       
    54 my $dir = getcwd;
       
    55 chdir $PKGDIR;
       
    56 
       
    57 # Generate SIS files for SIF integration tests
       
    58 my $CREATESISCMD = "createsis create -cert $CERTPATH -key $KEYPATH";
       
    59 `$CREATESISCMD $PKGDIR\\$BASE$suffix.pkg`;
       
    60 `$CREATESISCMD $PKGDIR\\$UPGRADE$suffix.pkg`;
       
    61 unlink "*.cer"; #delete all certificates to avoid failure on checklocationofcertificates test
       
    62 
       
    63 # Copy generated SIS files onto the Z drive
       
    64 if (lc($PLATFORM) ne "armv5")
       
    65 	{
       
    66 	unlink "$DATADIR\\$BASE.sis";
       
    67 	move("$PKGDIR\\$BASE$suffix.sis", "$DATADIR\\$BASE.sis");
       
    68 	unlink "$DATADIR\\$UPGRADE.sis";
       
    69 	move("$PKGDIR\\$UPGRADE$suffix.sis", "$DATADIR\\$UPGRADE.sis");
       
    70 	}
       
    71 else
       
    72 	{
       
    73 	mkdir "$ARMV5DATADIR" unless -d "$ARMV5DATADIR";
       
    74 	unlink "$DATADIR\\$BASE.sis";
       
    75 	move("$PKGDIR\\$BASE$suffix.sis", "$ARMV5DATADIR\\$BASE.sis");
       
    76 	unlink "$DATADIR\\$UPGRADE.sis";
       
    77 	move("$PKGDIR\\$UPGRADE$suffix.sis", "$ARMV5DATADIR\\$UPGRADE.sis");
       
    78 	}
       
    79 
       
    80 unlink "$PKGDIR\\$BASE$suffix.pkg";
       
    81 unlink "$PKGDIR\\$UPGRADE$suffix.pkg";
       
    82 
       
    83 chdir $dir;
       
    84 
       
    85 
       
    86 # Read the contents of a file into a string and return it
       
    87 sub ReadFile ($) {
       
    88 	my ($file) = @_;
       
    89 	open FILE, "<$file" or die "Can't read from $file: $!";
       
    90 	local $/ = undef;
       
    91 	my $data = <FILE>;
       
    92 	close FILE;
       
    93 	return $data;
       
    94 }
       
    95 
       
    96 # Replace a file with a string
       
    97 sub WriteFile ($$) {
       
    98 	my ($file, $data) = @_;
       
    99 
       
   100 	# Ensure directory exists
       
   101 	if ($file =~ basename($1) && ! -e $1)
       
   102 		{
       
   103 		mkdir($1);
       
   104 		}
       
   105 	
       
   106 	if (-e $file)
       
   107 		{
       
   108 		system("attrib -r $file");
       
   109 		}
       
   110 	
       
   111 	open FILE, ">$file" or die "Can't write to $file: $!";
       
   112 	print FILE $data;
       
   113 	close FILE;
       
   114 }
       
   115 
       
   116 # Edit a file
       
   117 sub EditFile ($$$) {
       
   118 	my ($infile, $outfile, $coderef) = @_;
       
   119 	local $_ = ReadFile($infile);
       
   120 	&$coderef();
       
   121 	WriteFile($outfile, $_);
       
   122 }
       
   123