releasing/cbrtools/perl/ValidateEnv
changeset 602 3145852acc89
equal deleted inserted replaced
600:6d08f4a05d93 602:3145852acc89
       
     1 #!perl
       
     2 # Copyright (c) 2000-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 # 
       
    16 #
       
    17 
       
    18 use strict;
       
    19 use FindBin;
       
    20 use lib "$FindBin::Bin";
       
    21 use Getopt::Long;
       
    22 use IniData;
       
    23 use EnvDb;
       
    24 use CommandController;
       
    25 
       
    26 
       
    27 #
       
    28 # Globals.
       
    29 #
       
    30 
       
    31 my $iniData = IniData->New();
       
    32 my $commandController = CommandController->New($iniData, 'ValidateEnv');
       
    33 my $verbose = 0;
       
    34 my $validatesource = 0;
       
    35 my $fullbincheck = 0;
       
    36 my $comp;
       
    37 my $ver;
       
    38 
       
    39 
       
    40 #
       
    41 # Main.
       
    42 #
       
    43 
       
    44 ProcessCommandLine();
       
    45 ValidateEnv();
       
    46 
       
    47 
       
    48 #
       
    49 # Subs.
       
    50 #
       
    51 
       
    52 sub ProcessCommandLine {
       
    53   Getopt::Long::Configure ("bundling");  my $help;
       
    54   GetOptions("h" => \$help, "v+" => \$verbose, "s" => \$validatesource, "f" => \$fullbincheck);
       
    55 
       
    56   if ($help) {
       
    57     Usage(0);
       
    58   }
       
    59 
       
    60   $comp = shift @ARGV;
       
    61   $ver = shift @ARGV;
       
    62 
       
    63   unless ($#ARGV == -1) {
       
    64     print "Error: Invalid number of arguments\n";
       
    65     Usage(1);
       
    66   }
       
    67 }
       
    68 
       
    69 sub Usage {
       
    70   my $exitCode = shift;
       
    71 
       
    72   Utils::PrintDeathMessage($exitCode, "\nUsage: validateenv [options] [<component> <version>]
       
    73 
       
    74 options:
       
    75 
       
    76 -h  help
       
    77 -v  verbose output (-vv very verbose)
       
    78 -s  validate source code too
       
    79 -f  fully check for added binaries (can be very slow)\n");
       
    80 }
       
    81 
       
    82 sub ValidateEnv {
       
    83   my $iniData = IniData->New();
       
    84   my $envDb = EnvDb->Open($iniData, $verbose);
       
    85   my $failedMrps = $envDb->ValidateEnv($comp, $ver, $validatesource, $fullbincheck);
       
    86   my $numFailedMrps = scalar(@$failedMrps);
       
    87   unless ($numFailedMrps == 0) {
       
    88     print "\nThe following component(s) failed their validation:\n\n";
       
    89     foreach my $mrp (@$failedMrps) {
       
    90       print "$mrp\n";
       
    91     }
       
    92     print "\n";
       
    93   }
       
    94 }
       
    95 
       
    96 __END__
       
    97 
       
    98 =head1 NAME
       
    99 
       
   100 ValidateEnv - Validates the integrity of all the binaries in the current environment.
       
   101 
       
   102 =head1 SYNOPSIS
       
   103 
       
   104   validateenv [options] [<component> <version>]
       
   105 
       
   106 options:
       
   107 
       
   108   -h  help
       
   109   -v  verbose output (-vv very verbose)
       
   110   -s  also validate source code
       
   111   -f  fully check for added binaries
       
   112 
       
   113 =head1 DESCRIPTION
       
   114 
       
   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>.
       
   116 
       
   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.
       
   118 
       
   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.
       
   120 
       
   121 
       
   122 =head1 KNOWN BUGS
       
   123 
       
   124 None.
       
   125 
       
   126 =head1 COPYRIGHT
       
   127 
       
   128  Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
       
   129  All rights reserved.
       
   130  This component and the accompanying materials are made available
       
   131  under the terms of the License "Eclipse Public License v1.0"
       
   132  which accompanies this distribution, and is available
       
   133  at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
   134  
       
   135  Initial Contributors:
       
   136  Nokia Corporation - initial contribution.
       
   137  
       
   138  Contributors:
       
   139  
       
   140  Description:
       
   141  
       
   142 
       
   143 =cut