|
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 #Options: |
|
17 # -version -adds Qt version (4,6,0) intp pkg files |
|
18 # -target -replaces $(PLATFORM)/$(TARGET) into armv5/urel |
|
19 # -module -creates script for module tests sis |
|
20 # -module -delete module tests pkg |
|
21 # default -version |
|
22 |
|
23 use strict; |
|
24 use File::Find; |
|
25 my $base = `cd`; |
|
26 $base =~ s/\\\w+\s+$//; #move one dir upper |
|
27 my $modulebase = `cd`; |
|
28 $modulebase =~s/(\s+)$//; #remove linefeed from end |
|
29 print $base;; |
|
30 my $qtversion = "\, 4\, 6\, 0\,"; |
|
31 my $target = "armv5\/urel"; |
|
32 |
|
33 my $qtversionchnage = 0; |
|
34 my $qtversionarg = "-version"; |
|
35 my $targetchnage = 0; |
|
36 my $targetarg = "-target"; |
|
37 my $module = 0; |
|
38 my $modulearg = "-module"; |
|
39 my $delmodule = 0; |
|
40 my $delmodulearg = "-delmodule"; |
|
41 my $moduledir = "modulesis"; |
|
42 my $modulepath = $base."\\".$moduledir; |
|
43 my $ccert = $modulebase."\\"."cert.cer"; |
|
44 my $ckey = $modulebase."\\"."key.pem"; |
|
45 my $modulebatpath = $modulebase."\\".$moduledir."\\createmodulesis.bat"; |
|
46 |
|
47 checkCmdLine(); |
|
48 |
|
49 if ( $qtversionchnage == 1 || $targetchnage == 1 ) |
|
50 { |
|
51 find( \&edits, $base ); |
|
52 } |
|
53 if ( $module == 1 ) |
|
54 { |
|
55 system "mkdir $moduledir"; |
|
56 if ( not ( open (FWM, ">$modulebatpath") ) ) |
|
57 { |
|
58 print "\n***Error: Couldn't open $modulebatpath file to write\n"; |
|
59 return; |
|
60 } |
|
61 binmode FWM; |
|
62 print FWM "del /S/Q *.SIS\r\n"; |
|
63 print FWM "del /S/Q *.SISX\r\n"; |
|
64 close FWM; |
|
65 find( \&moduleSis, $base ); |
|
66 } |
|
67 if ( $delmodule == 1 ) |
|
68 { |
|
69 find( \&delModuleSis, $base ); |
|
70 } |
|
71 |
|
72 sub edits() |
|
73 { |
|
74 my $file=$_; |
|
75 my $winpath=$File::Find::name; |
|
76 $winpath=~s/\//\\/g; |
|
77 if( -f $file && $file=~/(_template\.pkg)$/i ) |
|
78 { |
|
79 print "$winpath "; |
|
80 system "attrib -R $winpath"; |
|
81 if ( not ( open (FR, $winpath) ) ) |
|
82 { |
|
83 print "Error: Couldn't open $winpath file to read\n"; |
|
84 return; |
|
85 } |
|
86 binmode FR; |
|
87 my $buf=""; |
|
88 my $length = 0; |
|
89 $length = -s $winpath; |
|
90 read( FR, $buf, $length ); |
|
91 close FR; |
|
92 if ( $qtversionchnage == 1 ) |
|
93 { |
|
94 $buf =~s/\,\s*\,\s*\,\s*\,\s*\{\"Qt\"\}/$qtversion \{\"Qt\"\}/si; |
|
95 } |
|
96 if ( $targetchnage == 1 ) |
|
97 { |
|
98 $buf =~s/\$\(PLATFORM\)\/\$\(TARGET\)/$target/si; |
|
99 } |
|
100 |
|
101 if ( not ( open (FW, ">$winpath") ) ) |
|
102 { |
|
103 print "\n***Error: Couldn't open $winpath file to write\n"; |
|
104 return; |
|
105 } |
|
106 binmode FW; |
|
107 print FW $buf; |
|
108 close FW; |
|
109 |
|
110 print "\r\n"; |
|
111 } |
|
112 } |
|
113 |
|
114 sub checkCmdLine() |
|
115 { |
|
116 my $numArgs = $#ARGV + 1; |
|
117 if ( $numArgs == 0 ) |
|
118 { |
|
119 $qtversionchnage = 1; |
|
120 } |
|
121 else |
|
122 { |
|
123 foreach my $argnum ( 0 .. $#ARGV ) |
|
124 { |
|
125 my $argName = lc $ARGV[$argnum]; |
|
126 if ( $argName eq $qtversionarg ) |
|
127 { |
|
128 $qtversionchnage = 1; |
|
129 } |
|
130 elsif ( $argName eq $targetarg ) |
|
131 { |
|
132 $targetchnage = 1; |
|
133 } |
|
134 elsif ( $argName eq $modulearg ) |
|
135 { |
|
136 $module = 1; |
|
137 } |
|
138 elsif ( $argName eq $delmodulearg ) |
|
139 { |
|
140 $delmodule = 1; |
|
141 } |
|
142 else |
|
143 { |
|
144 die "\n***Error: Bad arguments\n"; |
|
145 } |
|
146 } |
|
147 } |
|
148 } |
|
149 |
|
150 sub moduleSis() |
|
151 { |
|
152 my $file=$_; |
|
153 my $winpath=$File::Find::name; |
|
154 $winpath=~s/\//\\/g; |
|
155 |
|
156 |
|
157 if( -f $file && $file=~/(_template\.pkg)$/i && ( $file=~/^(t_)/i || $file=~/test/i ) ) |
|
158 { |
|
159 print "$winpath "; |
|
160 system "attrib -R $winpath"; |
|
161 if ( not ( open (FR, $winpath) ) ) |
|
162 { |
|
163 print "Error: Couldn't open $winpath file to read\n"; |
|
164 return; |
|
165 } |
|
166 binmode FR; |
|
167 my $buf=""; |
|
168 my $length = 0; |
|
169 $length = -s $winpath; |
|
170 read( FR, $buf, $length ); |
|
171 close FR; |
|
172 $buf =~s/\,\s*\,\s*\,\s*\,\s*\{\"Qt\"\}/$qtversion \{\"Qt\"\}/si; |
|
173 $buf =~s/\$\(PLATFORM\)\/\$\(TARGET\)/$target/si; |
|
174 |
|
175 if ( not ( open (FW, ">$winpath") ) ) |
|
176 { |
|
177 print "Error: Couldn't open $winpath file to write\n"; |
|
178 return; |
|
179 } |
|
180 binmode FW; |
|
181 print FW $buf; |
|
182 close FW; |
|
183 print "\r\n"; |
|
184 |
|
185 my $pkgname = sisName( $winpath ); |
|
186 |
|
187 if ( not ( open (FWM2, ">>$modulebatpath") ) ) |
|
188 { |
|
189 print "Error: Couldn't open $modulebatpath file to append\n"; |
|
190 return; |
|
191 } |
|
192 binmode FWM2; |
|
193 print FWM2 "makesis $winpath $pkgname\.SIS\r\n"; |
|
194 print FWM2 "signsis $pkgname\.SIS $pkgname\.SISX $ccert $ckey\r\n"; |
|
195 close FWM2; |
|
196 } |
|
197 } |
|
198 |
|
199 sub sisName() |
|
200 { |
|
201 my $path = shift; |
|
202 my $name = ""; |
|
203 if ( $path =~ /\\(\w+)\.pkg/i ) |
|
204 { |
|
205 $name = $1; |
|
206 } |
|
207 return $name; |
|
208 } |
|
209 |
|
210 sub delModuleSis() |
|
211 { |
|
212 my $file=$_; |
|
213 my $winpath=$File::Find::name; |
|
214 $winpath=~s/\//\\/g; |
|
215 |
|
216 |
|
217 if( -f $file && $file=~/(_template\.pkg)$/i && ( $file=~/^(t_)/i || $file=~/test/i ) ) |
|
218 { |
|
219 print "Deleting: "; |
|
220 print "$winpath "; |
|
221 system "attrib -R $winpath"; |
|
222 system "del /S/Q $winpath"; |
|
223 print "\r\n"; |
|
224 } |
|
225 } |