releasing/cbrtools/perl/envmembership
author jjkang
Fri, 25 Jun 2010 18:37:20 +0800
changeset 602 3145852acc89
permissions -rw-r--r--
add releasing to new structure
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) 2001-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 RelData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use Utils;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use CommandController;
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
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
# Globals.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
my $verbose = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
my $iniData = IniData->New();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
my $force;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
my $commandController = CommandController->New($iniData, 'EnvMembership');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
# Main.
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
ProcessCommandLine();
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
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
# Subs.
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
sub ProcessCommandLine {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
  Getopt::Long::Configure ("bundling");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
  my $help;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
  GetOptions("h" => \$help, "v+" => \$verbose, "f" => \$force);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
  if ($help) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
    Usage(0);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
  # Functional description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
  # create reldata objects for each release of <environment>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  # for each release find if <component> is present in the environment
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
  # and if so if <version> matches the version in the environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
  # if these conditions are met, place the current <environment> release id in 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
  # an array and print the contents of the array at the end of the script
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
  #
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
  #
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
  if ($#ARGV == 2) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
    # Extract the command line arguments (Note: GetOptions() will have already
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
    # stripped out the options part of the command line
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
    my $component_name = shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
    my $component_version= shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
    my $env_name= shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
		
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
    # Scalar variable $envRelDatas will contain a reference to an array of reldata
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
    # objects following this call.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
    my $envRelDatas = RelData->OpenSet($iniData, $env_name, $verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
    my @outputTable;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
    my @tableHeader = ("Component", "Version");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
    push (@outputTable, \@tableHeader);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
    foreach my $currentEnvRelData (@$envRelDatas) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
      my $currentEnv = $currentEnvRelData->Environment();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
      # $currentEnv now contains a reference to a hash containing 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
      # component name / version pairs for all the components that were
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
      # present in the current release of the environment component
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
      if ($currentEnv->{$component_name}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
	# component is present in the current environment
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
	if ($currentEnv->{$component_name} eq $component_version) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
	  # component version of interest is present in the current environment
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
	  my @tableRow = ($currentEnvRelData->Component(),$currentEnvRelData->Version());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
	  push (@outputTable, \@tableRow);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
    # print the environment versions in which componet version is present
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
    my $tableLength = @outputTable;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
    if ($tableLength > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
      $iniData->TableFormatter->PrintTable(\@outputTable);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
  } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
    print "Error: Invalid number of arguments\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
    Usage(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
sub Usage {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
  my $exitCode = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
  Utils::PrintDeathMessage($exitCode, "\nUsage: envmembership [options] <component> <version> <environment>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
-h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
-f  (deprecated)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
-v  verbose output (-vv very verbose)\n");
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
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
EnvMembership - Returns the environments to which a particular component belongs
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
  envmembership [options] <component> <version> <environment>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
  -h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
  -f  (deprecated)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
  -v  verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
Returns all the versions of a specified component for which a particular version of another specified component is present in its release environment. For example, to discover which release of a component called C<my_product> contains the component C<my_comp> at version C<my_ver>, type:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
  envmembership my_comp my_ver my_product 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
=head1 STATUS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
Supported. If you find a problem, please report it to us.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
 Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
=cut