bin/createpackage.pl
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    76                                separate line. The certificate, key and passphrase in line
    76                                separate line. The certificate, key and passphrase in line
    77                                must be ';' separated. Lines starting with '#' are treated
    77                                must be ';' separated. Lines starting with '#' are treated
    78                                as a comments. Also empty lines are ignored. The paths in
    78                                as a comments. Also empty lines are ignored. The paths in
    79                                <file> can be absolute or relative to <file>.
    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.
    81      [-s|stub]               = Generates stub sis for ROM.
    82      [-s|stub]               = Generates stub sis for ROM.
    82      [-n|sisname <name>]     = Specifies the final sis name.
    83      [-n|sisname <name>]     = Specifies the final sis name.
    83 Where parameters are as follows:
    84 Where parameters are as follows:
    84      templatepkg             = Name of .pkg file template
    85      templatepkg             = Name of .pkg file template
    85      target                  = Either debug or release
    86      target                  = Either debug or release
   119 my $preprocessonly = "";
   120 my $preprocessonly = "";
   120 my $certfile = "";
   121 my $certfile = "";
   121 my $preserveUnsigned = "";
   122 my $preserveUnsigned = "";
   122 my $stub = "";
   123 my $stub = "";
   123 my $signed_sis_name = "";
   124 my $signed_sis_name = "";
       
   125 my $onlyUnsigned = "";
   124 
   126 
   125 unless (GetOptions('i|install' => \$install,
   127 unless (GetOptions('i|install' => \$install,
   126                    'p|preprocess' => \$preprocessonly,
   128                    'p|preprocess' => \$preprocessonly,
   127                    'c|certfile=s' => \$certfile,
   129                    'c|certfile=s' => \$certfile,
   128                    'u|unsigned' => \$preserveUnsigned,
   130                    'u|unsigned' => \$preserveUnsigned,
       
   131                    'o|only-unsigned' => \$onlyUnsigned,
   129                    's|stub' => \$stub,
   132                    's|stub' => \$stub,
   130                    'n|sisname=s' => \$signed_sis_name,)) {
   133                    'n|sisname=s' => \$signed_sis_name,)) {
   131     Usage();
   134     Usage();
   132 }
   135 }
   133 
   136 
   290     mkpath($systeminstall);
   293     mkpath($systeminstall);
   291     my $stub_sis_name = $systeminstall."/".$stub_sis_name;
   294     my $stub_sis_name = $systeminstall."/".$stub_sis_name;
   292     # Create stub SIS.
   295     # Create stub SIS.
   293     system ("makesis -s $pkgoutput $stub_sis_name");
   296     system ("makesis -s $pkgoutput $stub_sis_name");
   294 } else {
   297 } else {
   295     if ($certtext eq "Self Signed" && !@certificates && $templatepkg !~ m/_installer\.pkg$/i) {
   298     if ($certtext eq "Self Signed"
       
   299         && !@certificates
       
   300         && $templatepkg !~ m/_installer\.pkg$/i
       
   301         && !$onlyUnsigned) {
   296         print("Auto-patching capabilities for self signed package.\n");
   302         print("Auto-patching capabilities for self signed package.\n");
   297         system ("patch_capabilities $pkgoutput");
   303         system ("patch_capabilities $pkgoutput");
   298     }
   304     }
   299 
   305 
   300     # Create SIS.
   306     # Create SIS.
   301     # The 'and' is because system uses 0 to indicate success.
   307     # The 'and' is because system uses 0 to indicate success.
   302     system ("makesis $pkgoutput $unsigned_sis_name") and die ("makesis failed");
   308     system ("makesis $pkgoutput $unsigned_sis_name") and die ("makesis failed");
   303     print("\n");
   309     print("\n");
       
   310 
       
   311     my $targetInsert = "";
       
   312     if ($targetplatform ne "-") {
       
   313         $targetInsert = " for $targetplatform";
       
   314     }
       
   315 
       
   316     if ($onlyUnsigned) {
       
   317         stat($unsigned_sis_name);
       
   318         if( -e _ ) {
       
   319             print ("Successfully created unsigned package ${unsigned_sis_name}${targetInsert}!\n");
       
   320         } else {
       
   321             print ("\nUnsigned package creation failed!\n");
       
   322         }
       
   323 
       
   324         if (!$preservePkgOutput) {
       
   325             unlink $pkgoutput;
       
   326         }
       
   327         exit;
       
   328     }
   304 
   329 
   305     # Sign SIS with certificate info given as an argument.
   330     # Sign SIS with certificate info given as an argument.
   306     my $relcert = File::Spec->abs2rel($certificate);
   331     my $relcert = File::Spec->abs2rel($certificate);
   307     my $relkey = File::Spec->abs2rel($key);
   332     my $relkey = File::Spec->abs2rel($key);
   308     # The 'and' is because system uses 0 to indicate success.
   333     # The 'and' is because system uses 0 to indicate success.
   309     system ("signsis $unsigned_sis_name $signed_sis_name $relcert $relkey $passphrase") and die ("signsis failed");
   334     system ("signsis $unsigned_sis_name $signed_sis_name $relcert $relkey $passphrase") and die ("signsis failed");
   310 
   335 
   311     # Check if creating signed SIS Succeeded
   336     # Check if creating signed SIS Succeeded
   312     stat($signed_sis_name);
   337     stat($signed_sis_name);
   313     if( -e _ ) {
   338     if( -e _ ) {
   314         my $targetInsert = "";
   339         print ("Successfully created signed package ${signed_sis_name}${targetInsert} using certificate: $certtext!\n");
   315         if ($targetplatform ne "-") {
       
   316             $targetInsert = "for $targetplatform ";
       
   317         }
       
   318         print ("Successfully created $signed_sis_name ${targetInsert}using certificate: $certtext!\n");
       
   319 
   340 
   320         # Sign with additional certificates & keys
   341         # Sign with additional certificates & keys
   321         for my $row ( @certificates ) {
   342         for my $row ( @certificates ) {
   322             # Get certificate absolute file names, relative paths are relative to certfilepath
   343             # Get certificate absolute file names, relative paths are relative to certfilepath
   323             my $relcert = File::Spec->abs2rel(File::Spec->rel2abs( $row->[0], $certfilepath));
   344             my $relcert = File::Spec->abs2rel(File::Spec->rel2abs( $row->[0], $certfilepath));