releasing/cbrtools/perl/ValidateEnv
author Ross Qin <ross.qin@nokia.com>
Tue, 02 Nov 2010 09:31:04 +0800
changeset 671 ff8ff850b0cf
parent 602 3145852acc89
permissions -rw-r--r--
fix the Serious problem with ROFS on-disk format
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, 'ValidateEnv');
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 $comp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
my $ver;
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
ValidateEnv();
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");  my $help;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
  GetOptions("h" => \$help, "v+" => \$verbose, "s" => \$validatesource, "f" => \$fullbincheck);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
  if ($help) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
    Usage(0);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
  $comp = shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
  $ver = shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
  unless ($#ARGV == -1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
    print "Error: Invalid number of arguments\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
sub Usage {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
  my $exitCode = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
  Utils::PrintDeathMessage($exitCode, "\nUsage: validateenv [options] [<component> <version>]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
-h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
-v  verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
-s  validate source code too
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
-f  fully check for added binaries (can be very slow)\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
sub ValidateEnv {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
  my $iniData = IniData->New();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
  my $envDb = EnvDb->Open($iniData, $verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
  my $failedMrps = $envDb->ValidateEnv($comp, $ver, $validatesource, $fullbincheck);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
  my $numFailedMrps = scalar(@$failedMrps);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
  unless ($numFailedMrps == 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
    print "\nThe following component(s) failed their validation:\n\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
    foreach my $mrp (@$failedMrps) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
      print "$mrp\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
    print "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
ValidateEnv - Validates the integrity of all the binaries in the current environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
  validateenv [options] [<component> <version>]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
  -h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
  -v  verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
  -s  also validate source code
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
  -f  fully check for added binaries
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
C<ValidateEnv> is intended to be used on a drive that contains the output of a clean build. It is assumed that the drive has been populated using C<GetRel> or C<GetEnv>. This is important since C<ValidateEnv> needs to know the version of each component installed on the drive - it gets this information from the drive's environment Database. Its role is to establish the status of each component by comparing the released binary files against those present in the current environment. The comparison is done using the tool C<EValid> which ignores irrelevant differences (such as those in header blocks). Components with a status of I<pending release> will be ignored. Components that pass their validation will have their status set to I<clean> and a new signature file written. Components that fail their validation will have their status set to I<dirty>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
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
   118
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
By default C<ValidateEnv> validates against the component version installed in current environment, however instead you can specify a different environment by referring to the component and version of it. This can only be done if the current environment database is empty. This facility was designed to allow builds delivered without using the release tools to be analysed and subsequently delivered using the release tools. It effectively allows you to construct an environment database by comparing the binaries on the current drive with another environment. Components that pass the validation will have their status set to clean and a signature file written. Components that fail their validation will have their status set to dirty and a dummy signature file written. This will contain the name of each binary previously released, with zero time stamp and size. This signature will never match the files on the drive and so will cause C<EnvInfo> to correctly find the component as dirty.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
=cut