author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 22 Apr 2010 16:15:11 +0300 | |
branch | RCL_3 |
changeset 14 | 8c4229025c0b |
parent 7 | 3f74d0d4af4c |
permissions | -rwxr-xr-x |
0 | 1 |
#!/usr/bin/perl |
2 |
############################################################################# |
|
3 |
## |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4 |
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 5 |
## All rights reserved. |
6 |
## Contact: Nokia Corporation (qt-info@nokia.com) |
|
7 |
## |
|
8 |
## This file is part of the S60 port of the Qt Toolkit. |
|
9 |
## |
|
10 |
## $QT_BEGIN_LICENSE:LGPL$ |
|
11 |
## No Commercial Usage |
|
12 |
## This file contains pre-release code and may not be distributed. |
|
13 |
## You may use this file in accordance with the terms and conditions |
|
14 |
## contained in the Technology Preview License Agreement accompanying |
|
15 |
## this package. |
|
16 |
## |
|
17 |
## GNU Lesser General Public License Usage |
|
18 |
## Alternatively, this file may be used under the terms of the GNU Lesser |
|
19 |
## General Public License version 2.1 as published by the Free Software |
|
20 |
## Foundation and appearing in the file LICENSE.LGPL included in the |
|
21 |
## packaging of this file. Please review the following information to |
|
22 |
## ensure the GNU Lesser General Public License version 2.1 requirements |
|
23 |
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
24 |
## |
|
25 |
## In addition, as a special exception, Nokia gives you certain additional |
|
26 |
## rights. These rights are described in the Nokia Qt LGPL Exception |
|
27 |
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
28 |
## |
|
29 |
## If you have questions regarding the use of this file, please contact |
|
30 |
## Nokia at qt-info@nokia.com. |
|
31 |
## |
|
32 |
## |
|
33 |
## |
|
34 |
## |
|
35 |
## |
|
36 |
## |
|
37 |
## |
|
38 |
## |
|
39 |
## $QT_END_LICENSE$ |
|
40 |
## |
|
41 |
############################################################################# |
|
42 |
||
43 |
############################################################################################ |
|
44 |
# |
|
45 |
# Convenience script for creating signed packages you can install on your phone. |
|
46 |
# |
|
47 |
############################################################################################ |
|
48 |
||
49 |
use strict; |
|
50 |
||
51 |
# use a command-line parsing module |
|
52 |
use Getopt::Long; |
|
53 |
# Use file name parsing module |
|
54 |
use File::Basename; |
|
55 |
# Use File::Spec services mainly rel2abs |
|
56 |
use File::Spec; |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
57 |
# Use File::Path - to make stub sis target directory |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
58 |
use File::Path; |
0 | 59 |
# use CWD abs_bath, which is exported only on request |
60 |
use Cwd 'abs_path'; |
|
61 |
||
62 |
||
63 |
sub Usage() { |
|
64 |
print <<ENDUSAGESTRING; |
|
65 |
||
66 |
============================================================================================== |
|
67 |
Convenience script for creating signed packages you can install on your phone. |
|
68 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
69 |
Usage: createpackage.pl [options] templatepkg [target]-[platform] [certificate key [passphrase]] |
0 | 70 |
|
71 |
Where supported optiobns are as follows: |
|
72 |
[-i|install] = Install the package right away using PC suite |
|
73 |
[-p|preprocess] = Only preprocess the template .pkg file. |
|
74 |
[-c|certfile=<file>] = The file containing certificate information for signing. |
|
75 |
The file can have several certificates, each specified in |
|
76 |
separate line. The certificate, key and passphrase in line |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
77 |
must be ';' separated. Lines starting with '#' are treated |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
78 |
as a comments. Also empty lines are ignored. The paths in |
0 | 79 |
<file> can be absolute or relative to <file>. |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
80 |
[-u|unsigned] = Preserves the unsigned package |
0 | 81 |
Where parameters are as follows: |
82 |
templatepkg = Name of .pkg file template |
|
83 |
target = Either debug or release |
|
84 |
platform = One of the supported platform |
|
85 |
winscw | gcce | armv5 | armv6 | armv7 |
|
86 |
certificate = The certificate file used for signing |
|
87 |
key = The certificate's private key file |
|
88 |
passphrase = The certificate's private key file's passphrase |
|
89 |
||
90 |
Example: |
|
91 |
createpackage.pl fluidlauncher_template.pkg release-armv5 |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
92 |
|
0 | 93 |
Example with certfile: |
94 |
createpackage.pl -c=mycerts.txt fluidlauncher_template.pkg release-armv5 |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
95 |
|
0 | 96 |
Content of 'mycerts.txt' must be something like this: |
97 |
# This is comment line, also the empty lines are ignored |
|
98 |
rd.cer;rd-key.pem |
|
99 |
.\\cert\\mycert.cer;.\\cert\\mykey.key;yourpassword |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
100 |
X:\\QtS60\\s60installs\\selfsigned.cer;X:\\QtS60\\s60installs\\selfsigned.key |
0 | 101 |
|
102 |
If no certificate and key files are provided, either a RnD certificate or |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
103 |
a self-signed certificate from QtDir\\src\\s60installs directory is used. |
0 | 104 |
============================================================================================== |
105 |
||
106 |
ENDUSAGESTRING |
|
107 |
||
108 |
exit(); |
|
109 |
} |
|
110 |
||
111 |
# Read given options |
|
112 |
my $install = ""; |
|
113 |
my $preprocessonly = ""; |
|
114 |
my $certfile = ""; |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
115 |
my $preserveUnsigned = ""; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
116 |
my $stub = ""; |
0 | 117 |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
118 |
unless (GetOptions('i|install' => \$install, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
119 |
'p|preprocess' => \$preprocessonly, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
120 |
'c|certfile=s' => \$certfile, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
121 |
'u|unsigned' => \$preserveUnsigned, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
122 |
's|stub' => \$stub,)){ |
0 | 123 |
Usage(); |
124 |
} |
|
125 |
||
126 |
my $certfilepath = abs_path(dirname($certfile)); |
|
127 |
||
128 |
# Read params to variables |
|
129 |
my $templatepkg = $ARGV[0]; |
|
130 |
my $targetplatform = lc $ARGV[1]; |
|
131 |
||
132 |
my @tmpvalues = split('-', $targetplatform); |
|
133 |
my $target = $tmpvalues[0]; |
|
134 |
my $platform = $tmpvalues[1];; |
|
135 |
||
136 |
# Convert visual target to real target (debug->udeb and release->urel) |
|
137 |
$target =~ s/debug/udeb/i; |
|
138 |
$target =~ s/release/urel/i; |
|
139 |
||
140 |
my $certificate = $ARGV[2]; |
|
141 |
my $key = $ARGV[3]; |
|
142 |
my $passphrase = $ARGV[4]; |
|
143 |
||
144 |
# Generate output pkg basename (i.e. file name without extension) |
|
145 |
my $pkgoutputbasename = $templatepkg; |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
146 |
my $preservePkgOutput = ""; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
147 |
$pkgoutputbasename =~ s/_template/_$targetplatform/g; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
148 |
if ($pkgoutputbasename eq $templatepkg) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
149 |
$preservePkgOutput = "1"; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
150 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
151 |
$pkgoutputbasename =~ s/\.pkg//g; |
0 | 152 |
$pkgoutputbasename = lc($pkgoutputbasename); |
153 |
||
154 |
# Store output file names to variables |
|
155 |
my $pkgoutput = lc($pkgoutputbasename.".pkg"); |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
156 |
my $sisoutputbasename = lc($pkgoutputbasename); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
157 |
$sisoutputbasename =~ s/_$targetplatform//g; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
158 |
my $unsigned_sis_name = $sisoutputbasename."_unsigned.sis"; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
159 |
my $signed_sis_name = $sisoutputbasename.".sis"; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
160 |
my $stub_sis_name = $sisoutputbasename."_stub.sis"; |
0 | 161 |
|
162 |
# Store some utility variables |
|
163 |
my $scriptpath = dirname(__FILE__); |
|
164 |
my $certtext = $certificate; |
|
165 |
my $certpath = $scriptpath; |
|
166 |
$certpath =~ s-^(.*[^\\])$-$1\\-o; # ensure path ends with a backslash |
|
167 |
$certpath =~ s-/-\\-go; # for those working with UNIX shells |
|
168 |
$certpath =~ s-bin\\$-src\\s60installs\\-; # certificates are one step up in hierarcy |
|
169 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
170 |
# Check some pre-conditions and print error messages if needed. |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
171 |
unless (length($templatepkg)) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
172 |
print "\nError: Template PKG filename is not defined!\n"; |
0 | 173 |
Usage(); |
174 |
} |
|
175 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
176 |
# If the pkg file is not actually a template, there is no need for plaform or target. |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
177 |
if ($templatepkg =~ m/_template\.pkg/i) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
178 |
unless (length($platform) && length($target)) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
179 |
print "\nError: Platform or target is not defined!\n"; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
180 |
Usage(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
181 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
182 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
183 |
|
0 | 184 |
# Check template exist |
185 |
stat($templatepkg); |
|
186 |
unless( -e _ ) { |
|
187 |
print "\nError: Package description file '$templatepkg' does not exist!\n"; |
|
188 |
Usage(); |
|
189 |
} |
|
190 |
||
191 |
# Check certifcate preconditions and set default certificate variables if needed |
|
192 |
if (length($certificate)) { |
|
193 |
unless(length($key)) { |
|
194 |
print "\nError: Custom certificate key file parameter missing.!\n"; |
|
195 |
Usage(); |
|
196 |
} |
|
197 |
} else { |
|
198 |
#If no certificate is given, check default options |
|
199 |
$certtext = "RnD"; |
|
200 |
$certificate = $certpath."rd.cer"; |
|
201 |
$key = $certpath."rd-key.pem"; |
|
202 |
||
203 |
stat($certificate); |
|
204 |
unless( -e _ ) { |
|
205 |
$certtext = "Self Signed"; |
|
206 |
$certificate = $certpath."selfsigned.cer"; |
|
207 |
$key = $certpath."selfsigned.key"; |
|
208 |
} |
|
209 |
} |
|
210 |
||
211 |
# Read the certificates from file to two dimensional array |
|
212 |
my @certificates; |
|
213 |
if (length($certfile)) { |
|
214 |
open CERTFILE, "<$certfile" or die $!; |
|
215 |
while(<CERTFILE>){ |
|
216 |
s/#.*//; # ignore comments by erasing them |
|
217 |
next if /^(\s)*$/; # skip blank lines |
|
218 |
chomp; # remove trailing newline characters |
|
219 |
my @certinfo = split(';', $_); # split row to certinfo |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
220 |
|
0 | 221 |
# Trim spaces |
222 |
for(@certinfo) { |
|
223 |
s/^\s+//; |
|
224 |
s/\s+$//; |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
225 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
226 |
|
0 | 227 |
# Do some validation |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
228 |
unless(scalar(@certinfo) >= 2 && scalar(@certinfo) <= 3 && length($certinfo[0]) && length($certinfo[1]) ) { |
0 | 229 |
print "\nError: $certfile line '$_' does not contain valid information!\n"; |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
230 |
Usage(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
231 |
} |
0 | 232 |
|
233 |
push @certificates, [@certinfo]; # push data to two dimensional array |
|
234 |
} |
|
235 |
} |
|
236 |
||
237 |
# Remove any existing .sis packages |
|
238 |
unlink $unsigned_sis_name; |
|
239 |
unlink $signed_sis_name; |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
240 |
if (!$preservePkgOutput) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
241 |
unlink $pkgoutput; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
242 |
} |
0 | 243 |
|
244 |
# Preprocess PKG |
|
245 |
local $/; |
|
246 |
# read template file |
|
247 |
open( TEMPLATE, $templatepkg) or die "Error '$templatepkg': $!\n"; |
|
248 |
$_=<TEMPLATE>; |
|
249 |
close (TEMPLATE); |
|
250 |
||
251 |
# replace the PKG variables |
|
252 |
s/\$\(PLATFORM\)/$platform/gm; |
|
253 |
s/\$\(TARGET\)/$target/gm; |
|
254 |
||
255 |
#write the output |
|
256 |
open( OUTPUT, ">$pkgoutput" ) or die "Error '$pkgoutput' $!\n"; |
|
257 |
print OUTPUT $_; |
|
258 |
close OUTPUT; |
|
259 |
||
260 |
if ($preprocessonly) { |
|
261 |
exit; |
|
262 |
} |
|
263 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
264 |
if($stub) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
265 |
if(!($ENV{EPOCROOT})) { die("EPOCROOT must be set to create stub sis files"); } |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
266 |
my $systeminstall = "$ENV{EPOCROOT}epoc32/data/z/system/install"; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
267 |
mkpath($systeminstall); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
268 |
my $stub_sis_name = $systeminstall."/".$stub_sis_name; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
269 |
# Create stub SIS. |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
270 |
system ("makesis -s $pkgoutput $stub_sis_name"); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
271 |
} else { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
272 |
# Create SIS. |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
273 |
system ("makesis $pkgoutput $unsigned_sis_name"); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
274 |
print("\n"); |
0 | 275 |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
276 |
# Sign SIS with certificate info given as an argument. |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
277 |
system ("signsis $unsigned_sis_name $signed_sis_name $certificate $key $passphrase"); |
0 | 278 |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
279 |
# Check if creating signed SIS Succeeded |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
280 |
stat($signed_sis_name); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
281 |
if( -e _ ) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
282 |
my $targetInsert = ""; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
283 |
if ($targetplatform ne "-") { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
284 |
$targetInsert = "for $targetplatform "; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
285 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
286 |
print ("Successfully created $signed_sis_name ${targetInsert}using certificate: $certtext!\n"); |
0 | 287 |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
288 |
# Sign with additional certificates & keys |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
289 |
for my $row ( @certificates ) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
290 |
# Get certificate absolute file names, relative paths are relative to certfilepath |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
291 |
my $abscert = File::Spec->rel2abs( $row->[0], $certfilepath); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
292 |
my $abskey = File::Spec->rel2abs( $row->[1], $certfilepath); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
293 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
294 |
system ("signsis $signed_sis_name $signed_sis_name $abscert $abskey $row->[2]"); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
295 |
print ("\tAdditionally signed the SIS with certificate: $row->[0]!\n"); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
296 |
} |
0 | 297 |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
298 |
# remove temporary pkg and unsigned sis |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
299 |
if (!$preservePkgOutput) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
300 |
unlink $pkgoutput; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
301 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
302 |
if (!$preserveUnsigned) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
303 |
unlink $unsigned_sis_name; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
304 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
305 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
306 |
# Install the sis if requested |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
307 |
if ($install) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
308 |
print ("\nInstalling $signed_sis_name...\n"); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
309 |
system ("$signed_sis_name"); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
310 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
311 |
} else { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
312 |
# Lets leave the generated PKG for problem solving purposes |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
313 |
print ("\nSIS creation failed!\n"); |
0 | 314 |
} |
315 |
} |
|
316 |
||
317 |
#end of file |