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