releasing/cbrtools/perl/ValidateRel
author Zheng Shen <zheng.shen@nokia.com>
Tue, 20 Jul 2010 15:02:28 +0800
changeset 617 3a747a240983
parent 602 3145852acc89
permissions -rw-r--r--
ROM Tools 12.2.0.4 Postlinker 2.2.5 Revert package_definition.xml to changeset 360bd6b35136
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
#!perl
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
use FindBin;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
use lib "$FindBin::Bin";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
use Getopt::Long;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use IniData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use EnvDb;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use CommandController;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
# Globals.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
my $iniData = IniData->New();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
my $commandController = CommandController->New($iniData, 'ValidateRel');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
my $verbose = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
my $validatesource = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
my $fullbincheck = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
my $keeptemp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
my @comps;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
# Main.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
ProcessCommandLine();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
ValidateRel();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
# Subs.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
sub ProcessCommandLine {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
  Getopt::Long::Configure ("bundling");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
  my $help;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
  GetOptions("h" => \$help, "v+" => \$verbose, "s" => \$validatesource, "t" => \$keeptemp, "f" => \$fullbincheck);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
  if ($help) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
    Usage(0);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
  if ($#ARGV == 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
    if (-f $ARGV[0]) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
      open IN, $ARGV[0] or die "Error: Couldn't open $ARGV[0] for reading: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
      while (my $line = <IN>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
        chomp $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
        $line =~ s/^\s*$//; #remove lines entirely filled with white space
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
        $line =~ s/#.*//; #remove comments from lines
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
		$line =~ s/^\s*//; #remove whitespace from the start of lines
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
        if ($line eq '') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
          next; #Nothing left
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
		my @cmdLine = split(/\s+/,$line);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
		my $cmdLineCount = @cmdLine;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
		my %relStruct;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
		if($cmdLineCount > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
			$relStruct{name} = $cmdLine[0];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
			if($cmdLineCount > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
				$relStruct{ver} = $cmdLine[1];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
			}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
			push @comps, \%relStruct;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
    close IN;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
      push @comps, {name => $ARGV[0]};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
  elsif ($#ARGV == 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
    # Both component and version are specified
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
    push @comps, {name => $ARGV[0],
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
                  ver  => $ARGV[1]};    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
    print "Error: Invalid number of arguments\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
sub Usage {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
  my $exitCode = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
  Utils::PrintDeathMessage($exitCode, "\nUsage: validaterel [options] (<component> [<version>]) | <component_list_file>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
-h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
-v  verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
-s  validate source code too
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
-f  fully check for added binaries (can be very slow)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
-t  don't delete the temporary directory
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
sub ValidateRel {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
  my $iniData = IniData->New();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
  my $envDb = EnvDb->Open($iniData, $verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
  foreach my $comp (@comps) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
	my $version;	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
	if(exists($comp->{ver})) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
		$version = $comp->{ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
	else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
		$version = $envDb->Version($comp->{name});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
	if(defined $version) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
		$envDb->ValidateComp($comp->{name}, $version, undef, $validatesource, $keeptemp, $fullbincheck);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
      print $comp->{name}." not installed\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
ValidateRel - Validates the integrity of the installed binaries of a given component.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
  validaterel [options] (<component> [<version>]) | <component_list_file>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
  -h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
  -v  verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
  -s  validate source code too
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
  -f  fully check for added binaries
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
  -t  keep temporary directory
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
Unpacks the binaries of the specified version of the component to a temporary directory (if a version is not specified, the version of the component that was originally installed in the environment is retrieved from the environment database). It then compares them with the binaries in the current drive's F<\epoc32> tree using the standard EPOC tool C<EValid>. Reports the status of the component as a result of the validation. This will be I<clean> if the validation passed, I<dirty> if the validation failed, or I<pending release> if the component was already pending release. If the component passes its validation and the version is the same as the one present in the environment database, its signature file in F<\epoc32\relinfo> will be updated.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
You may also give a -s flag to indicate that you want to validate the source code. This is useful because in some cases the source code may change, without the binary files changing. (For example, a change of distrubution.policy). If this validation fails, but the binary validation succeeds, the status will be set to I<binaries clean, source dirty>. Only source code in the release packet will be validated - source files missing from the release packets will not be detected.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
A list of component names stored in a text file may be passed to validaterel to validate multiple components.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
With the -t flag, you will be told where the temporary directory was. You
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
can then use that to investigate validation failures with evalid.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
=cut