imgtools/imaker/buildrom_plugins/stubsischeck.pm
author jjkang
Fri, 25 Jun 2010 18:11:34 +0800
changeset 600 6d08f4a05d93
parent 596 9f25be3da657
permissions -rw-r--r--
add deprecated files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
596
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
     1
#
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
     2
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
     3
# All rights reserved.
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
     8
#
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
     9
# Initial Contributors:
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    11
#
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    12
# Contributors:
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    13
#
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    14
# Description:
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    15
# Check included sis/sisx file validity.
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    16
#
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    17
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    18
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    19
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    20
package stubsischeck;
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    21
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    22
use strict;
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    23
use warnings;
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    24
use File::Basename;
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    25
use plugincommon;
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    26
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    27
BEGIN
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    28
{
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    29
    use Exporter();
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    30
    our($VERSION, @ISA, @EXPORT);
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    31
    $VERSION = 1.00;
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    32
    @ISA     = qw(Exporter);
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    33
    @EXPORT  = qw(&stubsischeck_info &stubsischeck_init &stubsischeck_process);
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    34
}
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    35
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    36
my $conf;
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    37
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    38
sub stubsischeck_info()
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    39
{
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    40
    return({
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    41
        name       => "stubsischeck",
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    42
        invocation => "InvocationPoint3",  # tmp9.oby
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    43
        initialize => "stubsischeck::stubsischeck_init",
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    44
        single     => "stubsischeck::stubsischeck_process"});
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    45
}
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    46
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    47
sub stubsischeck_init($)
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    48
{
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    49
    plugin_init(&stubsischeck_info, $conf = shift(), 0);
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    50
}
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    51
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    52
sub stubsischeck_process($)
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    53
{
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    54
    plugin_start(&stubsischeck_info, $conf);
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    55
    my $obydata = shift();
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    56
    my %uids = ();
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    57
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    58
    dprint(3, "Finding and checking stub sis files...");
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    59
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    60
    foreach (@{$obydata}) {
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    61
        next if (parse_obyline($_) != 2)   || ($gImgid != $gRomidCmp)  ||
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    62
            ($gKeyword !~ FILESPECKEYWORD) || ($gSrcCmp !~ /\.sisx?$/) || !-e($gSource);
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    63
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    64
        my ($basename, $uiddata) = (File::Basename::basename($gSrcCmp), "");
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    65
        dprint(2, "Checking `$gSource'", 1);
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    66
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    67
        # Find out whether or not this is stub sis file
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    68
        open(FILE, $gSource) or
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    69
            dprint(2, ""), dprint(-3, "$gPluginname can't open `$gSource'"), next;
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    70
        binmode(FILE);
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    71
        sysread(FILE, $uiddata, 0x1C);
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    72
        close(FILE);
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    73
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    74
        my $uid = unpack("V", substr($uiddata, 0x00, 4));
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    75
        if ($uid == 0x0000000D) {
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    76
            my $puid = sprintf("0x%08X", unpack("V", substr($uiddata, 0x18, 4)));
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    77
            dprint(2, ", pUID: $puid");
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    78
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    79
            # Quick-and-dirty way to check duplicate UIDs
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    80
            if (exists($uids{$puid}) && ($basename ne $uids{$puid})) {
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    81
                dprint(3, "Error: `$gSource': Duplicate pUID $puid, see `$uids{$puid}'");
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    82
            } else {
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    83
                $uids{$puid} = $basename;
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    84
            }
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    85
        } elsif ($uid == 0x10201A7A) {
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    86
            dprint(2, ": Normal (non-stub) sis file");
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    87
        } else {
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    88
            dprint(2, "");
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    89
            if (unpack("V", substr($uiddata, 0x08, 4)) == 0x10000419) { # UID3
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    90
                dprint(-3, "`$gSource': Legacy (pre Symbian 9.x) sis file");
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    91
            } else {
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    92
                dprint(3, "Error: `$gSource': Sis file with unknown UID ($uid)");
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    93
            }
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    94
        }
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    95
    }
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    96
    plugin_end();
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    97
}
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    98
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
    99
1;
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
   100
9f25be3da657 Updated to iMaker version 10.24.01, 14-Jun-2010.
m2lahtel <>
parents:
diff changeset
   101
__END__ # OF STUBSISCHECK.PM