imgtools/imaker/buildrom_plugins/stubsischeck.pm
changeset 607 378360dbbdba
parent 596 9f25be3da657
equal deleted inserted replaced
591:22486c9c7b15 607:378360dbbdba
       
     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 the License "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 # Check included sis/sisx file validity.
       
    16 #
       
    17 
       
    18 
       
    19 
       
    20 package stubsischeck;
       
    21 
       
    22 use strict;
       
    23 use warnings;
       
    24 use File::Basename;
       
    25 use plugincommon;
       
    26 
       
    27 BEGIN
       
    28 {
       
    29     use Exporter();
       
    30     our($VERSION, @ISA, @EXPORT);
       
    31     $VERSION = 1.00;
       
    32     @ISA     = qw(Exporter);
       
    33     @EXPORT  = qw(&stubsischeck_info &stubsischeck_init &stubsischeck_process);
       
    34 }
       
    35 
       
    36 my $conf;
       
    37 
       
    38 sub stubsischeck_info()
       
    39 {
       
    40     return({
       
    41         name       => "stubsischeck",
       
    42         invocation => "InvocationPoint3",  # tmp9.oby
       
    43         initialize => "stubsischeck::stubsischeck_init",
       
    44         single     => "stubsischeck::stubsischeck_process"});
       
    45 }
       
    46 
       
    47 sub stubsischeck_init($)
       
    48 {
       
    49     plugin_init(&stubsischeck_info, $conf = shift(), 0);
       
    50 }
       
    51 
       
    52 sub stubsischeck_process($)
       
    53 {
       
    54     plugin_start(&stubsischeck_info, $conf);
       
    55     my $obydata = shift();
       
    56     my %uids = ();
       
    57 
       
    58     dprint(3, "Finding and checking stub sis files...");
       
    59 
       
    60     foreach (@{$obydata}) {
       
    61         next if (parse_obyline($_) != 2)   || ($gImgid != $gRomidCmp)  ||
       
    62             ($gKeyword !~ FILESPECKEYWORD) || ($gSrcCmp !~ /\.sisx?$/) || !-e($gSource);
       
    63 
       
    64         my ($basename, $uiddata) = (File::Basename::basename($gSrcCmp), "");
       
    65         dprint(2, "Checking `$gSource'", 1);
       
    66 
       
    67         # Find out whether or not this is stub sis file
       
    68         open(FILE, $gSource) or
       
    69             dprint(2, ""), dprint(-3, "$gPluginname can't open `$gSource'"), next;
       
    70         binmode(FILE);
       
    71         sysread(FILE, $uiddata, 0x1C);
       
    72         close(FILE);
       
    73 
       
    74         my $uid = unpack("V", substr($uiddata, 0x00, 4));
       
    75         if ($uid == 0x0000000D) {
       
    76             my $puid = sprintf("0x%08X", unpack("V", substr($uiddata, 0x18, 4)));
       
    77             dprint(2, ", pUID: $puid");
       
    78 
       
    79             # Quick-and-dirty way to check duplicate UIDs
       
    80             if (exists($uids{$puid}) && ($basename ne $uids{$puid})) {
       
    81                 dprint(3, "Error: `$gSource': Duplicate pUID $puid, see `$uids{$puid}'");
       
    82             } else {
       
    83                 $uids{$puid} = $basename;
       
    84             }
       
    85         } elsif ($uid == 0x10201A7A) {
       
    86             dprint(2, ": Normal (non-stub) sis file");
       
    87         } else {
       
    88             dprint(2, "");
       
    89             if (unpack("V", substr($uiddata, 0x08, 4)) == 0x10000419) { # UID3
       
    90                 dprint(-3, "`$gSource': Legacy (pre Symbian 9.x) sis file");
       
    91             } else {
       
    92                 dprint(3, "Error: `$gSource': Sis file with unknown UID ($uid)");
       
    93             }
       
    94         }
       
    95     }
       
    96     plugin_end();
       
    97 }
       
    98 
       
    99 1;
       
   100 
       
   101 __END__ # OF STUBSISCHECK.PM