Changeset 846 for trunk/bin/createpackage.pl
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/bin/createpackage.pl
r769 r846 2 2 ############################################################################# 3 3 ## 4 ## Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).4 ## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 5 5 ## All rights reserved. 6 6 ## Contact: Nokia Corporation (qt-info@nokia.com) … … 69 69 Usage: createpackage.pl [options] templatepkg [target]-[platform] [certificate key [passphrase]] 70 70 71 Where supported optio bns are as follows:72 [-i|install] = Install the package right away using PC suite 71 Where supported options are as follows: 72 [-i|install] = Install the package right away using PC suite. 73 73 [-p|preprocess] = Only preprocess the template .pkg file. 74 [-c|certfile =<file>] = The file containing certificate information for signing.74 [-c|certfile <file>] = The file containing certificate information for signing. 75 75 The file can have several certificates, each specified in 76 76 separate line. The certificate, key and passphrase in line … … 78 78 as a comments. Also empty lines are ignored. The paths in 79 79 <file> can be absolute or relative to <file>. 80 [-u|unsigned] = Preserves the unsigned package 80 [-u|unsigned] = Preserves the unsigned package. 81 [-o|only-unsigned] = Creates only unsigned package. 82 [-s|stub] = Generates stub sis for ROM. 83 [-n|sisname <name>] = Specifies the final sis name. 84 [-g|gcce-is-armv5] = Convert gcce platform to armv5. 85 [-d|dont-patch] = Skip automatic patching of capabilities and pkg file if default certificate 86 is used. Instead non-self-signable capabilities just cause warnings. 81 87 Where parameters are as follows: 82 88 templatepkg = Name of .pkg file template … … 84 90 platform = One of the supported platform 85 91 winscw | gcce | armv5 | armv6 | armv7 92 Note that when packaging binaries built using gcce and symbian-sbsv2 93 mkspec, armv5 must be used for platform instead of gcce. 86 94 certificate = The certificate file used for signing 87 95 key = The certificate's private key file 88 passphrase = The certificate's private key file's passphrase96 passphrase = The passphrase of the certificate's private key file 89 97 90 98 Example: … … 102 110 If no certificate and key files are provided, either a RnD certificate or 103 111 a self-signed certificate from QtDir\\src\\s60installs directory is used. 112 In the latter case the resulting package will also be automatically patched 113 using patch_capabilities.pl script, which makes it unsuitable for distribution. 114 Always specify certificates explicitly if you wish to distribute your package. 115 104 116 ============================================================================================== 105 117 … … 115 127 my $preserveUnsigned = ""; 116 128 my $stub = ""; 129 my $signed_sis_name = ""; 130 my $onlyUnsigned = ""; 131 my $convertGcce = ""; 132 my $dontPatchCaps = ""; 117 133 118 134 unless (GetOptions('i|install' => \$install, … … 120 136 'c|certfile=s' => \$certfile, 121 137 'u|unsigned' => \$preserveUnsigned, 122 's|stub' => \$stub,)){ 138 'o|only-unsigned' => \$onlyUnsigned, 139 's|stub' => \$stub, 140 'n|sisname=s' => \$signed_sis_name, 141 'g|gcce-is-armv5' => \$convertGcce, 142 'd|dont-patch' => \$dontPatchCaps,)) { 123 143 Usage(); 144 } 145 146 my $epocroot = $ENV{EPOCROOT}; 147 my $epocToolsDir = ""; 148 if ($epocroot ne "") { 149 $epocroot =~ s,\\,/,g; 150 if ($epocroot =~ m,[^/]$,) { 151 $epocroot = $epocroot."/"; 152 } 153 $epocToolsDir = "${epocroot}epoc32/tools/"; 124 154 } 125 155 … … 130 160 my $targetplatform = lc $ARGV[1]; 131 161 162 if ($targetplatform eq "") { 163 $targetplatform = "-"; 164 } 165 132 166 my @tmpvalues = split('-', $targetplatform); 133 my $target = $tmpvalues[0]; 134 my $platform = $tmpvalues[1];; 167 my $target; 168 $target = $tmpvalues[0] or $target = ""; 169 my $platform; 170 $platform = $tmpvalues[1] or $platform = ""; 171 172 if ($platform =~ m/^gcce$/i) { 173 if (($convertGcce ne "")) { 174 $platform = "armv5"; 175 } elsif ($ENV{SBS_HOME}) { 176 # Print a informative note in case suspected misuse is detected. 177 print "\nNote: You should use armv5 as platform or specify -g parameter to convert platform\n"; 178 print " when packaging gcce binaries built using symbian-sbsv2 mkspec.\n\n"; 179 } 180 } 135 181 136 182 # Convert visual target to real target (debug->udeb and release->urel) … … 138 184 $target =~ s/release/urel/i; 139 185 140 my $certificate = $ARGV[2]; 141 my $key = $ARGV[3]; 142 my $passphrase = $ARGV[4]; 186 my $certificate; 187 $certificate = $ARGV[2] or $certificate = ""; 188 my $key; 189 $key = $ARGV[3] or $key = ""; 190 my $passphrase; 191 $passphrase = $ARGV[4] or $passphrase = ""; 143 192 144 193 # Generate output pkg basename (i.e. file name without extension) … … 146 195 my $preservePkgOutput = ""; 147 196 $pkgoutputbasename =~ s/_template/_$targetplatform/g; 197 $pkgoutputbasename =~ s/_installer\.pkg/_installer___temp\.pkg/g; 148 198 if ($pkgoutputbasename eq $templatepkg) { 149 199 $preservePkgOutput = "1"; 150 200 } 151 201 $pkgoutputbasename =~ s/\.pkg//g; 152 $pkgoutputbasename = lc($pkgoutputbasename);153 202 154 203 # Store output file names to variables 155 my $pkgoutput = lc($pkgoutputbasename.".pkg"); 156 my $sisoutputbasename = lc($pkgoutputbasename); 157 $sisoutputbasename =~ s/_$targetplatform//g; 204 my $pkgoutput = $pkgoutputbasename.".pkg"; 205 my $sisoutputbasename; 206 if ($signed_sis_name eq "") { 207 $sisoutputbasename = $pkgoutputbasename; 208 $sisoutputbasename =~ s/_$targetplatform//g; 209 $sisoutputbasename =~ s/_installer___temp/_installer/g; 210 $signed_sis_name = $sisoutputbasename.".sis"; 211 } else { 212 $sisoutputbasename = $signed_sis_name; 213 if ($sisoutputbasename =~ m/(\.sis$|\.sisx$)/i) { 214 $sisoutputbasename =~ s/$1//i; 215 } else { 216 $signed_sis_name = $signed_sis_name.".sis"; 217 } 218 } 219 220 my $installer_unsigned_app_sis_name = ""; 221 my $installer_app_sis_name = ""; 222 223 if ($templatepkg =~ m/_installer\.pkg$/i && $onlyUnsigned) { 224 $installer_unsigned_app_sis_name = $templatepkg; 225 $installer_unsigned_app_sis_name =~ s/_installer.pkg$/_unsigned.sis/i; 226 $installer_app_sis_name = $installer_unsigned_app_sis_name; 227 $installer_app_sis_name =~ s/_unsigned.sis$/.sis/; 228 } 229 158 230 my $unsigned_sis_name = $sisoutputbasename."_unsigned.sis"; 159 my $signed_sis_name = $sisoutputbasename.".sis"; 160 my $stub_sis_name = $sisoutputbasename."_stub.sis"; 231 my $stub_sis_name = $sisoutputbasename.".sis"; 161 232 162 233 # Store some utility variables 163 234 my $scriptpath = dirname(__FILE__); 164 235 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 236 # certificates are one step up in hierarchy 237 my $certpath = File::Spec->catdir($scriptpath, File::Spec->updir(), "src/s60installs/"); 169 238 170 239 # Check some pre-conditions and print error messages if needed. 171 240 unless (length($templatepkg)) { 172 print "\nE rror: Template PKG filename is not defined!\n";241 print "\nERROR: Template PKG filename is not defined!\n"; 173 242 Usage(); 174 }175 176 # If the pkg file is not actually a template, there is no need for plaform or target.177 if ($templatepkg =~ m/_template\.pkg/i) {178 unless (length($platform) && length($target)) {179 print "\nError: Platform or target is not defined!\n";180 Usage();181 }182 243 } 183 244 … … 185 246 stat($templatepkg); 186 247 unless( -e _ ) { 187 print "\nE rror: Package description file '$templatepkg' does not exist!\n";248 print "\nERROR: Package description file '$templatepkg' does not exist!\n"; 188 249 Usage(); 189 250 } … … 192 253 if (length($certificate)) { 193 254 unless(length($key)) { 194 print "\nE rror: Custom certificate key file parameter missing.!\n";255 print "\nERROR: Custom certificate key file parameter missing.!\n"; 195 256 Usage(); 196 257 } … … 198 259 #If no certificate is given, check default options 199 260 $certtext = "RnD"; 200 $certificate = $certpath."rd.cer";201 $key = $certpath."rd-key.pem";261 $certificate = File::Spec->catfile($certpath, "rd.cer"); 262 $key = File::Spec->catfile($certpath, "rd-key.pem"); 202 263 203 264 stat($certificate); 204 265 unless( -e _ ) { 205 266 $certtext = "Self Signed"; 206 $certificate = $certpath."selfsigned.cer";207 $key = $certpath."selfsigned.key";267 $certificate = File::Spec->catfile($certpath, "selfsigned.cer"); 268 $key = File::Spec->catfile($certpath, "selfsigned.key"); 208 269 } 209 270 } … … 227 288 # Do some validation 228 289 unless(scalar(@certinfo) >= 2 && scalar(@certinfo) <= 3 && length($certinfo[0]) && length($certinfo[1]) ) { 229 print "\nE rror: $certfile line '$_' does not contain valid information!\n";290 print "\nERROR: $certfile line '$_' does not contain valid information!\n"; 230 291 Usage(); 231 292 } … … 237 298 # Remove any existing .sis packages 238 299 unlink $unsigned_sis_name; 239 unlink $signed_sis_name; 300 if (!$onlyUnsigned) { 301 unlink $signed_sis_name; 302 } 240 303 if (!$preservePkgOutput) { 241 304 unlink $pkgoutput; … … 243 306 244 307 # Preprocess PKG 308 245 309 local $/; 246 310 # read template file 247 open( TEMPLATE, $templatepkg) or die "E rror '$templatepkg': $!\n";311 open( TEMPLATE, $templatepkg) or die "ERROR: '$templatepkg': $!"; 248 312 $_=<TEMPLATE>; 249 313 close (TEMPLATE); 314 315 # If the pkg file does not contain macros, there is no need for platform or target. 316 if (m/\$\(PLATFORM\)/) { 317 unless (length($platform) && length($target)) { 318 print "\nERROR: Platform or target is not defined!\n"; 319 Usage(); 320 } 321 } 250 322 251 323 # replace the PKG variables … … 253 325 s/\$\(TARGET\)/$target/gm; 254 326 327 if ($installer_unsigned_app_sis_name ne "") { 328 s/$installer_app_sis_name\"/$installer_unsigned_app_sis_name\"/; 329 } 330 255 331 #write the output 256 open( OUTPUT, ">$pkgoutput" ) or die "E rror '$pkgoutput' $!\n";332 open( OUTPUT, ">$pkgoutput" ) or die "ERROR: '$pkgoutput' $!"; 257 333 print OUTPUT $_; 258 334 close OUTPUT; … … 263 339 264 340 if($stub) { 265 if(!($ ENV{EPOCROOT})) { die("EPOCROOT must be set to create stub sis files"); }266 my $systeminstall = "$ ENV{EPOCROOT}epoc32/data/z/system/install";341 if(!($epocroot)) { die("ERROR: EPOCROOT must be set to create stub sis files"); } 342 my $systeminstall = "${epocroot}epoc32/data/z/system/install"; 267 343 mkpath($systeminstall); 268 344 my $stub_sis_name = $systeminstall."/".$stub_sis_name; 269 345 # Create stub SIS. 270 system (" makesis -s $pkgoutput $stub_sis_name");346 system ("${epocToolsDir}makesis -s $pkgoutput $stub_sis_name"); 271 347 } else { 348 if ($certtext eq "Self Signed" 349 && !@certificates 350 && $templatepkg !~ m/_installer\.pkg$/i 351 && !$onlyUnsigned) { 352 my $patch_capabilities = File::Spec->catfile(dirname($0), "patch_capabilities"); 353 if ($dontPatchCaps) { 354 system ("$patch_capabilities -c $pkgoutput") and print ("Warning: Package check for self-signing viability failed. Installing the package on a device will most likely fail!\n\n"); 355 } else { 356 print("Auto-patching self-signed package.\n"); 357 system ("$patch_capabilities $pkgoutput") and die ("ERROR: Automatic patching failed"); 358 } 359 } 360 272 361 # Create SIS. 273 system ("makesis $pkgoutput $unsigned_sis_name"); 362 # The 'and' is because system uses 0 to indicate success. 363 system ("${epocToolsDir}makesis $pkgoutput $unsigned_sis_name") and die ("ERROR: makesis failed"); 364 274 365 print("\n"); 275 366 367 my $targetInsert = ""; 368 if ($targetplatform ne "-") { 369 $targetInsert = " for $targetplatform"; 370 } 371 372 if ($onlyUnsigned) { 373 stat($unsigned_sis_name); 374 if( -e _ ) { 375 print ("Successfully created unsigned package ${unsigned_sis_name}${targetInsert}!\n"); 376 } else { 377 print ("\nUnsigned package creation failed!\n"); 378 } 379 380 if (!$preservePkgOutput) { 381 unlink $pkgoutput; 382 } 383 print ("\n"); 384 exit; 385 } 386 276 387 # Sign SIS with certificate info given as an argument. 277 system ("signsis $unsigned_sis_name $signed_sis_name $certificate $key $passphrase"); 388 my $relcert = File::Spec->abs2rel($certificate); 389 my $relkey = File::Spec->abs2rel($key); 390 # The 'and' is because system uses 0 to indicate success. 391 system ("${epocToolsDir}signsis $unsigned_sis_name $signed_sis_name $relcert $relkey $passphrase") and die ("ERROR: signsis failed"); 278 392 279 393 # Check if creating signed SIS Succeeded 280 394 stat($signed_sis_name); 281 395 if( -e _ ) { 282 my $targetInsert = ""; 283 if ($targetplatform ne "-") { 284 $targetInsert = "for $targetplatform "; 285 } 286 print ("Successfully created $signed_sis_name ${targetInsert}using certificate: $certtext!\n"); 396 print ("Successfully created signed package ${signed_sis_name}${targetInsert} using certificate: $certtext!\n"); 287 397 288 398 # Sign with additional certificates & keys 289 399 for my $row ( @certificates ) { 290 400 # Get certificate absolute file names, relative paths are relative to certfilepath 291 my $ abscert = File::Spec->rel2abs( $row->[0], $certfilepath);292 my $ abskey = File::Spec->rel2abs( $row->[1], $certfilepath);293 294 system (" signsis $signed_sis_name $signed_sis_name $abscert $abskey $row->[2]");401 my $relcert = File::Spec->abs2rel(File::Spec->rel2abs( $row->[0], $certfilepath)); 402 my $relkey = File::Spec->abs2rel(File::Spec->rel2abs( $row->[1], $certfilepath)); 403 404 system ("${epocToolsDir}signsis $signed_sis_name $signed_sis_name $relcert $relkey $row->[2]"); 295 405 print ("\tAdditionally signed the SIS with certificate: $row->[0]!\n"); 296 406 } … … 313 423 print ("\nSIS creation failed!\n"); 314 424 } 425 print ("\n"); 315 426 } 316 427
Note:
See TracChangeset
for help on using the changeset viewer.