Ignore:
Timestamp:
May 3, 2011, 4:49:08 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

vendor: Imported qt-everywhere-opensource-src-4.7.2 from Nokia (excluding doc/html and doc/qch dirs generated from doc/src, and imports and templates dirs which are emtpy).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/vendor/nokia/qt/current/bin/createpackage.pl

    r767 r844  
    22#############################################################################
    33##
    4 ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4## Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    55## All rights reserved.
    66## Contact: Nokia Corporation ([email protected])
     
    6969Usage: createpackage.pl [options] templatepkg [target]-[platform] [certificate key [passphrase]]
    7070
    71 Where supported optiobns are as follows:
    72      [-i|install]            = Install the package right away using PC suite
     71Where supported options are as follows:
     72     [-i|install]            = Install the package right away using PC suite
    7373     [-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.
    7575                               The file can have several certificates, each specified in
    7676                               separate line. The certificate, key and passphrase in line
     
    7878                               as a comments. Also empty lines are ignored. The paths in
    7979                               <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.
    8187Where parameters are as follows:
    8288     templatepkg             = Name of .pkg file template
     
    8490     platform                = One of the supported platform
    8591                               winscw | gcce | armv5 | armv6 | armv7
     92
     93
    8694     certificate             = The certificate file used for signing
    8795     key                     = The certificate's private key file
    88      passphrase              = The certificate's private key file's passphrase
     96     passphrase              = The e
    8997
    9098Example:
     
    102110If no certificate and key files are provided, either a RnD certificate or
    103111a self-signed certificate from QtDir\\src\\s60installs directory is used.
     112
     113
     114
     115
    104116==============================================================================================
    105117
     
    115127my $preserveUnsigned = "";
    116128my $stub = "";
     129
     130
     131
     132
    117133
    118134unless (GetOptions('i|install' => \$install,
     
    120136                   'c|certfile=s' => \$certfile,
    121137                   '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,)) {
    123143    Usage();
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
    124154}
    125155
     
    130160my $targetplatform = lc $ARGV[1];
    131161
     162
     163
     164
     165
    132166my @tmpvalues = split('-', $targetplatform);
    133 my $target = $tmpvalues[0];
    134 my $platform = $tmpvalues[1];;
     167my $target;
     168$target = $tmpvalues[0] or $target = "";
     169my $platform;
     170$platform = $tmpvalues[1] or $platform = "";
     171
     172if ($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}
    135181
    136182# Convert visual target to real target (debug->udeb and release->urel)
     
    138184$target =~ s/release/urel/i;
    139185
    140 my $certificate = $ARGV[2];
    141 my $key = $ARGV[3];
    142 my $passphrase = $ARGV[4];
     186my $certificate;
     187$certificate = $ARGV[2] or $certificate = "";
     188my $key;
     189$key = $ARGV[3] or $key = "";
     190my $passphrase;
     191$passphrase = $ARGV[4] or $passphrase = "";
    143192
    144193# Generate output pkg basename (i.e. file name without extension)
     
    146195my $preservePkgOutput = "";
    147196$pkgoutputbasename =~ s/_template/_$targetplatform/g;
     197
    148198if ($pkgoutputbasename eq $templatepkg) {
    149199    $preservePkgOutput = "1";
    150200}
    151201$pkgoutputbasename =~ s/\.pkg//g;
    152 $pkgoutputbasename = lc($pkgoutputbasename);
    153202
    154203# Store output file names to variables
    155 my $pkgoutput = lc($pkgoutputbasename.".pkg");
    156 my $sisoutputbasename = lc($pkgoutputbasename);
    157 $sisoutputbasename =~ s/_$targetplatform//g;
     204my $pkgoutput = $pkgoutputbasename.".pkg";
     205my $sisoutputbasename;
     206if ($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
     220my $installer_unsigned_app_sis_name = "";
     221my $installer_app_sis_name = "";
     222
     223if ($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
    158230my $unsigned_sis_name = $sisoutputbasename."_unsigned.sis";
    159 my $signed_sis_name = $sisoutputbasename.".sis";
    160 my $stub_sis_name = $sisoutputbasename."_stub.sis";
     231my $stub_sis_name = $sisoutputbasename.".sis";
    161232
    162233# Store some utility variables
    163234my $scriptpath = dirname(__FILE__);
    164235my $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
     237my $certpath = File::Spec->catdir($scriptpath, File::Spec->updir(), "src/s60installs/");
    169238
    170239# Check some pre-conditions and print error messages if needed.
    171240unless (length($templatepkg)) {
    172     print "\nError: Template PKG filename is not defined!\n";
     241    print "\nE: Template PKG filename is not defined!\n";
    173242    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     }
    182243}
    183244
     
    185246stat($templatepkg);
    186247unless( -e _ ) {
    187     print "\nError: Package description file '$templatepkg' does not exist!\n";
     248    print "\nE: Package description file '$templatepkg' does not exist!\n";
    188249    Usage();
    189250}
     
    192253if (length($certificate)) {
    193254    unless(length($key)) {
    194         print "\nError: Custom certificate key file parameter missing.!\n";
     255        print "\nE: Custom certificate key file parameter missing.!\n";
    195256        Usage();
    196257    }
     
    198259    #If no certificate is given, check default options
    199260    $certtext = "RnD";
    200     $certificate = $certpath."rd.cer";
    201     $key = $certpath."rd-key.pem";
     261    $certificate = ;
     262    $key = ;
    202263
    203264    stat($certificate);
    204265    unless( -e _ ) {
    205266        $certtext = "Self Signed";
    206         $certificate = $certpath."selfsigned.cer";
    207         $key = $certpath."selfsigned.key";
     267        $certificate = ;
     268        $key = ;
    208269    }
    209270}
     
    227288        # Do some validation
    228289        unless(scalar(@certinfo) >= 2 && scalar(@certinfo) <= 3 && length($certinfo[0]) && length($certinfo[1]) ) {
    229             print "\nError: $certfile line '$_' does not contain valid information!\n";
     290            print "\nE: $certfile line '$_' does not contain valid information!\n";
    230291            Usage();
    231292        }
     
    237298# Remove any existing .sis packages
    238299unlink $unsigned_sis_name;
    239 unlink $signed_sis_name;
     300if (!$onlyUnsigned) {
     301    unlink $signed_sis_name;
     302}
    240303if (!$preservePkgOutput) {
    241304    unlink $pkgoutput;
     
    243306
    244307# Preprocess PKG
     308
    245309local $/;
    246310# read template file
    247 open( TEMPLATE, $templatepkg) or die "Error '$templatepkg': $!\n";
     311open( TEMPLATE, $templatepkg) or die "E";
    248312$_=<TEMPLATE>;
    249313close (TEMPLATE);
     314
     315
     316
     317
     318
     319
     320
     321
    250322
    251323# replace the PKG variables
     
    253325s/\$\(TARGET\)/$target/gm;
    254326
     327
     328
     329
     330
    255331#write the output
    256 open( OUTPUT, ">$pkgoutput" ) or die "Error '$pkgoutput' $!\n";
     332open( OUTPUT, ">$pkgoutput" ) or die "E";
    257333print OUTPUT $_;
    258334close OUTPUT;
     
    263339
    264340if($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 must be set to create stub sis files"); }
     342    my $systeminstall = "$}epoc32/data/z/system/install";
    267343    mkpath($systeminstall);
    268344    my $stub_sis_name = $systeminstall."/".$stub_sis_name;
    269345    # Create stub SIS.
    270     system ("makesis -s $pkgoutput $stub_sis_name");
     346    system ("makesis -s $pkgoutput $stub_sis_name");
    271347} else {
     348
     349
     350
     351
     352
     353
     354
     355
     356
     357
     358
     359
     360
    272361    # 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
    274365    print("\n");
    275366
     367
     368
     369
     370
     371
     372
     373
     374
     375
     376
     377
     378
     379
     380
     381
     382
     383
     384
     385
     386
    276387    # 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");
    278392
    279393    # Check if creating signed SIS Succeeded
    280394    stat($signed_sis_name);
    281395    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");
    287397
    288398        # Sign with additional certificates & keys
    289399        for my $row ( @certificates ) {
    290400            # 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 $);
     402            my $);
     403
     404            system ("key $row->[2]");
    295405            print ("\tAdditionally signed the SIS with certificate: $row->[0]!\n");
    296406        }
     
    313423        print ("\nSIS creation failed!\n");
    314424    }
     425
    315426}
    316427
Note: See TracChangeset for help on using the changeset viewer.