vpnclient_sis/group/create_vpnclient_sis.pl
branchRCL_3
changeset 16 9fc0ed567871
child 32 352850cbed81
equal deleted inserted replaced
15:a15e6baef510 16:9fc0ed567871
       
     1 #
       
     2 # Copyright (c) 2010 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 "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 # Updates pkg-files' and vpnclient_sis.mk's version information with current date.
       
    16 # Creates temporary pkg-files with updated version.
       
    17 #
       
    18 
       
    19 use strict;
       
    20 use POSIX qw(strftime);
       
    21 use File::Copy;
       
    22 
       
    23 
       
    24 #Subroutines to update version information
       
    25 my $PLATFORM = "42";
       
    26 
       
    27 #
       
    28 # Creates a temp file and replaces line
       
    29 #
       
    30 sub replace_line_and_create_temp
       
    31 {
       
    32 	# arguments
       
    33 	my ($pattern, $replacement, $path) = @_;
       
    34 		
       
    35 	# create temp file
       
    36 	my $temp_path = "temp_".$path;
       
    37 	if (-e $temp_path)
       
    38 	{
       
    39 		chmod 0666, $temp_path;
       
    40 		unlink $temp_path;
       
    41 	}
       
    42 	copy($path, $temp_path);
       
    43 	chmod 0666, $temp_path;
       
    44 	
       
    45 	# update version information
       
    46 	my ($infile, $outfile);
       
    47 	open $infile, "<".$path or die "Can't open $path : $!";
       
    48 	open $outfile, ">".$temp_path or die "Can't open $temp_path : $!";
       
    49 	while (<$infile>)
       
    50 	{
       
    51 		my $line = $_;
       
    52 		if ($line =~ s/$pattern/$replacement/g)
       
    53 		{
       
    54 			print "Replaced line in $temp_path\n";
       
    55 		}
       
    56 		print $outfile $line;
       
    57 	}
       
    58 	close $infile;
       
    59 	close $outfile;
       
    60 }
       
    61 
       
    62 
       
    63 # Define variables
       
    64 my $pkgtime = strftime($PLATFORM.",%y,%m%d", localtime());
       
    65 my $mktime = strftime("%y%m%d", localtime());
       
    66 my $epocroot = $ENV{'EPOCROOT'};
       
    67 $epocroot =~ s/\\/\//;
       
    68 
       
    69 my $rdderdir="../data/RDTest_02.der";
       
    70 my $rdkeydir="../data/RDTest_02.key";
       
    71 my $localisation_files = $epocroot . "epoc32/data/Z/resource/vpnecomnotifier.r05";
       
    72 
       
    73 if (!(-e $localisation_files))
       
    74 {
       
    75  	die "Localisation files are not available! Exiting..\n";
       
    76 } 
       
    77 
       
    78 
       
    79 my $numArgs = $#ARGV + 1;
       
    80 if (!($#ARGV + 1 eq 1))
       
    81 {
       
    82 	die "wrong number of command line arguments.";
       
    83 }
       
    84 my $config = @ARGV[0];
       
    85 
       
    86 # Creates temp pkg files with updated version information
       
    87 if ($config eq "UREL")
       
    88 {
       
    89 # nokia_vpn_client_localised_armv5_urel.pkg
       
    90 	replace_line_and_create_temp(
       
    91 	    '^\(0x101F5147\),.*?,.*?,.*?, TYPE=SA, RU$',
       
    92 	    "(0x101F5147),$pkgtime, TYPE=SA, RU",
       
    93 	    'nokia_vpn_client_localised_armv5_urel.pkg');
       
    94 
       
    95 	print "Processing temp_nokia_vpn_client_localised_armv5_urel.pkg\n";
       
    96 	system("makesis -v temp_nokia_vpn_client_localised_armv5_urel.pkg mVPN_RnD_" . $PLATFORM . "_" . $mktime . "_urel.sis") == 0 or 
       
    97 		die "UREL sis creation failed";  		
       
    98 	print "\nSigning created mVPN_RnD_" . $PLATFORM . "_" . $mktime . "_urel.sis\n";
       
    99 	system("signsis mVPN_RnD_" . $PLATFORM . "_" . $mktime . "_urel.sis mVPN_RnD_" . $PLATFORM . "_" . $mktime . "_urel.sis " . $rdderdir . " " . $rdkeydir) == 0 or 
       
   100 		die "UREL sis signing failed";
       
   101 
       
   102 	# remove temp files
       
   103 	unlink <temp_*_urel.pkg>;  
       
   104 		
       
   105 }
       
   106 elsif ($config eq "UDEB")  
       
   107 {
       
   108 	# nokia_vpn_client_localised_armv5_udeb.pkg
       
   109 		replace_line_and_create_temp(
       
   110 		    '^\(0x101F5147\),.*?,.*?,.*?, TYPE=SA, RU$',
       
   111 		    "(0x101F5147),$pkgtime, TYPE=SA, RU",
       
   112 		    'nokia_vpn_client_localised_armv5_udeb.pkg');
       
   113 		
       
   114 		print "Processing temp_nokia_vpn_client_localised_armv5_udeb.pkg\n";
       
   115 		my $udeb_sis_file_name = "mVPN_RnD_" . $PLATFORM . "_" . $mktime . "_udeb.sis";
       
   116 		system("makesis -v temp_nokia_vpn_client_localised_armv5_udeb.pkg " . $udeb_sis_file_name ) == 0 or 
       
   117 			die "UDEB sis creation failed";			
       
   118 		print "\nSigning created mVPN_RnD_" . $PLATFORM . "_" . $mktime . "_udeb.sis\n";
       
   119 		system ("signsis " . $udeb_sis_file_name . " " . $udeb_sis_file_name . " "  . $rdderdir . " " . $rdkeydir)  == 0 or 
       
   120 			die "UDEB sis signing failed";	
       
   121 			
       
   122 	# remove temp files
       
   123 	unlink <temp_*_udeb.pkg>;
       
   124 }
       
   125 else
       
   126 {
       
   127 	die "Unknown config " . $config . "\n";
       
   128 }
       
   129