|
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 |
|
90 # stub_nokia_vpn_vpnpolins_armv5.pkg |
|
91 replace_line_and_create_temp( |
|
92 '^#{"Nokia VPN Policy Installer Stub"},\(0xA0000131\),.*?,.*?,.*?', |
|
93 "#{\"Nokia VPN Policy Installer Stub\"},(0xA0000131),$pkgtime", |
|
94 'stub_vpnpolins_armv5.pkg'); |
|
95 |
|
96 # stub_nokia_vpn_client_localised_armv5.pkg |
|
97 replace_line_and_create_temp( |
|
98 '^\(0x101F5147\),.*?,.*?,.*?$', |
|
99 "(0x101F5147),$pkgtime", |
|
100 'stub_nokia_vpn_client_armv5.pkg'); |
|
101 |
|
102 print "Processing stub_vpnpolins_armv5.pkg\n"; |
|
103 system("makesis -v -s stub_vpnpolins_armv5.pkg ipsecvpn_vpnpolins.SIS") == 0 or |
|
104 die "ipsecvpn_vpnpolins.SIS creation failed"; |
|
105 |
|
106 |
|
107 print "Processing stub_nokia_vpn_client_armv5.pkg\n"; |
|
108 system("makesis -v -s stub_nokia_vpn_client_armv5.pkg ipsecvpn.SIS") == 0 or |
|
109 die "ipsecvpn.SIS creation failed"; |
|
110 |
|
111 print "Export stub sis files to " . $epocroot . "epoc32/data/z/system/install\n"; |
|
112 copy("ipsecvpn_vpnpolins.SIS", $epocroot . "epoc32/data/z/system/install") or die "ipsecvpn_vpnpolins.SIS cannot be copied."; |
|
113 copy("ipsecvpn.SIS", $epocroot . "epoc32/data/z/system/install") or die "ipsecvpn_vpnpolins.SIS cannot be copied."; |
|
114 |
|
115 # remove temp files |
|
116 unlink <temp_*.pkg>; |
|
117 |
|
118 } |
|
119 elsif ($config eq "UDEB") |
|
120 { |
|
121 #do nothing |
|
122 } |
|
123 else |
|
124 { |
|
125 die "Unknown config " . $config . "\n"; |
|
126 } |
|
127 |