vpnclient_sis/group/update_versions.pl
branchRCL_3
changeset 16 9fc0ed567871
parent 15 a15e6baef510
child 18 5db1ac3b4374
equal deleted inserted replaced
15:a15e6baef510 16: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 # 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 my $PLATFORM = "42";
       
    25 
       
    26 #
       
    27 # Creates a temp file and replaces line
       
    28 #
       
    29 sub replace_line_and_create_temp
       
    30 {
       
    31 	# arguments
       
    32 	my ($pattern, $replacement, $path) = @_;
       
    33 		
       
    34 	# create temp file
       
    35 	my $temp_path = "temp_".$path;
       
    36 	if (-e $temp_path)
       
    37 	{
       
    38 		chmod 0666, $temp_path;
       
    39 		unlink $temp_path;
       
    40 	}
       
    41 	copy($path, $temp_path);
       
    42 	chmod 0666, $temp_path;
       
    43 	
       
    44 	# update version information
       
    45 	my ($infile, $outfile);
       
    46 	open $infile, "<".$path or die "Can't open $path : $!";
       
    47 	open $outfile, ">".$temp_path or die "Can't open $temp_path : $!";
       
    48 	while (<$infile>)
       
    49 	{
       
    50 		my $line = $_;
       
    51 		if ($line =~ s/$pattern/$replacement/g)
       
    52 		{
       
    53 			print "Replaced line in $temp_path\n";
       
    54 		}
       
    55 		print $outfile $line;
       
    56 	}
       
    57 	close $infile;
       
    58 	close $outfile;
       
    59 }
       
    60 
       
    61 #
       
    62 # Replaces line
       
    63 #
       
    64 sub replace_line
       
    65 {
       
    66 	# arguments
       
    67 	my ($pattern, $replacement, $path) = @_;
       
    68 		
       
    69 	# Backup
       
    70 	if (-e "$path.BACKUP")
       
    71 	{
       
    72 		chmod 0666, "$path.BACKUP";
       
    73 		unlink "$path.BACKUP";
       
    74 	}
       
    75 	chmod 0666, $path;
       
    76 	rename $path, "$path.BACKUP";
       
    77 	
       
    78 	# update version information
       
    79 	my ($infile, $outfile);
       
    80 	open $infile, "<$path.BACKUP" or die "Can't open $path.BACKUP : $!";
       
    81 	open $outfile, ">$path" or die "Can't open $path : $!";
       
    82 	while (<$infile>)
       
    83 	{
       
    84 		my $line = $_;
       
    85 		if ($line =~ s/$pattern/$replacement/g)
       
    86 		{
       
    87 			print "Replaced line in $path\n";
       
    88 		}
       
    89 		print $outfile $line;
       
    90 	}
       
    91 	close $infile;
       
    92 	close $outfile;
       
    93 }
       
    94 
       
    95 my $pkgtime = strftime($PLATFORM.",%y,%m%d", localtime());
       
    96 my $mktime = strftime("%y%m%d", localtime());
       
    97 
       
    98 # nokia_vpn_vpnpolins_armv5.pkg
       
    99 replace_line_and_create_temp(
       
   100     '^#{"Nokia VPN Policy Installer"},\(0xA0000131\),.*?,.*?,.*?, TYPE=SA, RU$',
       
   101     "#{\"Nokia VPN Policy Installer\"},(0xA0000131),$pkgtime, TYPE=SA, RU",
       
   102     'nokia_vpn_vpnpolins_armv5.pkg');
       
   103     
       
   104 # nokia_vpn_client_localised_armv5_urel.pkg
       
   105 replace_line_and_create_temp(
       
   106     '^\(0x101F5147\),.*?,.*?,.*?, TYPE=SA, RU$',
       
   107     "(0x101F5147),$pkgtime, TYPE=SA, RU",
       
   108     'nokia_vpn_client_localised_armv5_urel.pkg');
       
   109 
       
   110 # nokia_vpn_client_localised_armv5_udeb.pkg
       
   111 replace_line_and_create_temp(
       
   112     '^\(0x101F5147\),.*?,.*?,.*?, TYPE=SA, RU$',
       
   113     "(0x101F5147),$pkgtime, TYPE=SA, RU",
       
   114     'nokia_vpn_client_localised_armv5_udeb.pkg');
       
   115 
       
   116 # vpnclient_sis.mk
       
   117 replace_line(
       
   118     '^VERSION=.*?$',
       
   119     "VERSION=$mktime",
       
   120     'vpnclient_sis.mk');