vpnclient_sis/stub_sis/group/update_versions.pl
branchRCL_3
changeset 13 9fc0ed567871
parent 12 a15e6baef510
child 14 5db1ac3b4374
equal deleted inserted replaced
12:a15e6baef510 13:9fc0ed567871
     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 #
       
    17 # update_versions.pl
       
    18 #
       
    19 # Updates pkg-files' and vpnclient_sis.mk's version information with current date.
       
    20 # Creates temporary pkg-files with updated version.
       
    21 #
       
    22 
       
    23 use strict;
       
    24 use POSIX qw(strftime);
       
    25 use File::Copy;
       
    26 
       
    27 
       
    28 my $PLATFORM = "41";
       
    29 
       
    30 #
       
    31 # Creates a temp file and replaces line
       
    32 #
       
    33 sub replace_line_and_create_temp
       
    34 {
       
    35 	# arguments
       
    36 	my ($pattern, $replacement, $path) = @_;
       
    37 		
       
    38 	# create temp file
       
    39 	my $temp_path = "temp_".$path;
       
    40 	if (-e $temp_path)
       
    41 	{
       
    42 		chmod 0666, $temp_path;
       
    43 		unlink $temp_path;
       
    44 	}
       
    45 	copy($path, $temp_path);
       
    46 	chmod 0666, $temp_path;
       
    47 	
       
    48 	# update version information
       
    49 	my ($infile, $outfile);
       
    50 	open $infile, "<".$path or die "Can't open $path : $!";
       
    51 	open $outfile, ">".$temp_path or die "Can't open $temp_path : $!";
       
    52 	while (<$infile>)
       
    53 	{
       
    54 		my $line = $_;
       
    55 		if ($line =~ s/$pattern/$replacement/g)
       
    56 		{
       
    57 			print "Replaced line in $temp_path\n";
       
    58 		}
       
    59 		print $outfile $line;
       
    60 	}
       
    61 	close $infile;
       
    62 	close $outfile;
       
    63 }
       
    64 
       
    65 my $pkgtime = strftime($PLATFORM.",%y,%m%d", localtime());
       
    66 my $mktime = strftime("%y%m%d", localtime());
       
    67 
       
    68 # stub_nokia_vpn_vpnpolins_armv5.pkg
       
    69 replace_line_and_create_temp(
       
    70     '^#{"Nokia VPN Policy Installer Stub"},\(0xA0000131\),.*?,.*?,.*?',
       
    71     "#{\"Nokia VPN Policy Installer Stub\"},(0xA0000131),$pkgtime",
       
    72     'stub_vpnpolins_armv5.pkg');
       
    73     
       
    74 # stub_nokia_vpn_client_localised_armv5.pkg
       
    75 replace_line_and_create_temp(
       
    76     '^\(0x101F5147\),.*?,.*?,.*?$',
       
    77     "(0x101F5147),$pkgtime",
       
    78     'stub_nokia_vpn_client_armv5.pkg');