phoneuis/bubblemanager2/tsrc/bubbletest2/sis/sisTool.pl
branchRCL_3
changeset 61 41a7f70b3818
equal deleted inserted replaced
58:40a3f856b14d 61:41a7f70b3818
       
     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 "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 #! /usr/local/bin/perl -w
       
    17 #
       
    18 #  Change history:
       
    19 #
       
    20 # 06-Aug-2006 : DLL versioning support added (Elftran tool)
       
    21 # 02-Aug-2007 : Updated for changed RnD certificate path
       
    22 #
       
    23 #
       
    24 #
       
    25 
       
    26 sub updateVersion ;
       
    27 sub signSis ;
       
    28 
       
    29 my @args = @ARGV;
       
    30 # signing related variables
       
    31 my $certPath = "\\s60_RnD\\RD_RootCA";
       
    32 my $certificate = "rd.cer";
       
    33 my $key = "rd-key.pem";
       
    34 my $version = "10.1";
       
    35 my $packageFile = undef;
       
    36 my $sisFile = undef;
       
    37 
       
    38 # path to copy signed sis (if optional -c argument used)
       
    39 my $copyPath = undef;
       
    40 
       
    41 # 
       
    42 my $updateDllVersion = 0;
       
    43     
       
    44 # print help if needed
       
    45 if ( scalar(@args) == 0 || 
       
    46      $args[0] =~ /-[h,\?]/i )
       
    47     {
       
    48 print <<HELP;
       
    49 
       
    50 -------------------------------------------------------------------------
       
    51 ======= Script for making and signing an installation (.sis) file =======
       
    52 
       
    53 Usage: sisTool <package-file-w/o-ext> [-d<version>] [-c<destination-path>] 
       
    54                [-s<stub-package-file-w/o-ext>]
       
    55 
       
    56  -d changes minor DLL version number - needed when eclipsing DLLs in ROM.
       
    57  -c copies target file to specific destination
       
    58  -s also creates stub SIS. File name is not needed if it same as base file
       
    59     name followed by "_stub" (e.g. pkg files for eclipsing SIS and stub SIS
       
    60     are component.pkg and component_stub.pkg respectively).
       
    61 
       
    62 Examples:
       
    63 =========
       
    64 sisTool myPackage -d2
       
    65 
       
    66   Creates and signs(* 'myPackage.sis' from 'myPackage.pkg'.
       
    67   Before creating sis file myPackage.pkg is searched for DLLs
       
    68   and their version numbers are changed to 10.2 (i.e. minor
       
    69   version is changed - default major version number is 10).
       
    70 
       
    71 sisTool myPackage -d -s
       
    72   
       
    73   Same as first example but uses default minor version number (=1)
       
    74   for DLLs, and creates stub sis with name myPackage_stub.sis.
       
    75 
       
    76                                                      
       
    77 (* Uses R&D certificate 'rd.cer' from \\S60\\s60_RnD\\RD_RootCA
       
    78 HELP
       
    79     exit;
       
    80     }
       
    81 $packageFile = shift;
       
    82 
       
    83 foreach ( @args ) {
       
    84     # check if dll version number should be updated
       
    85     if ( /-d(\d+)?\b/ ) {
       
    86         $version = $1 ;
       
    87         $version = 1 if ( not defined $version );            
       
    88         $updateDllVersion = 1;
       
    89         }
       
    90     # check if stub SIS should be created
       
    91     elsif ( /-s((\w|\.|\\|_|:|-)+)?/ )
       
    92         {
       
    93         my $stubPkgFile = "${packageFile}_stub.pkg";
       
    94         if ( defined $1 ) {
       
    95             # user defined stub
       
    96             $stubPkgFile = $1; 
       
    97             $stubPkgFile = $stubPkgFile . ".pkg" if $stubPkgFile !~ /\.pkg$/; 
       
    98             }        
       
    99         my $cmd = "makesis -s $stubPkgFile";
       
   100         print "\n";
       
   101         system "$cmd";
       
   102         print "\n";
       
   103         }
       
   104     $copyPath = $1 if /-c(\S+)/;
       
   105     }
       
   106 
       
   107 if ( defined($packageFile) ) {
       
   108     ( -e "$packageFile.pkg" ) or die "package file '$packageFile' not found.\n";
       
   109     
       
   110     # Update version number of DLLs listed in pkg-file.
       
   111     updateVersion if $updateDllVersion;
       
   112 
       
   113     my $cmd = "makesis $packageFile\.pkg\n";
       
   114    
       
   115     if ( !defined( $sisFile ) ) {
       
   116         $sisFile = "$packageFile.sis";
       
   117         }
       
   118     #################
       
   119     # Do create sis #
       
   120     #################
       
   121     
       
   122     my $err = system "$cmd";
       
   123     die "\nFailed making sis file $!" if $err;
       
   124     signSis;
       
   125     if ( defined( $copyPath ) )
       
   126         {
       
   127         system "xcopy $sisFile $copyPath 2>&1";
       
   128         }
       
   129     }
       
   130 
       
   131 sub signSis {
       
   132     # sign a sis file
       
   133     my $signedFile = "${sisFile}S\.sis";
       
   134     ( -e "$certPath\\$certificate" ) or die <<NOCERT;
       
   135     
       
   136     
       
   137 Certificate could not be found from $certPath\\$certificate
       
   138 Check and modifiy the path in line ~17 in the script if needed.
       
   139 NOCERT
       
   140 
       
   141     my $cmd = "signsis -s $packageFile.sis $signedFile $certPath\\$certificate $certPath\\$key";        
       
   142     if ( system ( "$cmd" ) == 0 )
       
   143         {        
       
   144         # delete original unsigned sis file
       
   145         system "del $sisFile";
       
   146         system "ren $signedFile $sisFile";
       
   147         print "\nSigned with R&D certificate\n";
       
   148         if ( defined ( $copyPath ) ) {
       
   149             # copy signed sis to specified directory
       
   150             system "xcopy $sisFile $copyPath";
       
   151             }
       
   152         }        
       
   153     }
       
   154     
       
   155 
       
   156 sub updateVersion {
       
   157     open PACKAGE, "<$packageFile.pkg";    
       
   158     foreach ( <PACKAGE> )
       
   159         {
       
   160         if ( /\"(.*?\.dll)\"/i ) 
       
   161             {                        
       
   162             system "elftran -version 10\.$version $1";
       
   163             system "elftran -compressionmethod bytepair $1";
       
   164             print STDOUT "\nUpdated version number of\n$1 to 10.$version\n";
       
   165             }
       
   166         }
       
   167     close PACKAGE;  
       
   168     }