releasing/cbrtools/perl/GetEnv.pm
author jjkang
Wed, 30 Jun 2010 11:35:58 +0800
changeset 607 378360dbbdba
parent 602 3145852acc89
permissions -rw-r--r--
Merge missed changeset 11 (raptor v2.14 and helium 10.0)
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) 2003-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
package GetEnv;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
# Public.
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
sub GetEnvFromRelData {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
  my $iniData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
  my $installSource = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
  my $sourceInstallPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
  my $overwriteSource = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
  my $removeSource = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
  my $verbose = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
  my $excludeComponents = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
  my $forceExclusion = shift;
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
  my $envDb = EnvDb->Open($iniData, $verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
  $iniData->PathData()->CheckReleaseExists($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
  print "Gathering environment information...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
  my $relData = RelData->Open($iniData, $comp, $ver, $verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
  my $env = $relData->Environment();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
  GetEnv($iniData, $env, $installSource, $sourceInstallPath, $overwriteSource, $removeSource, $verbose, $excludeComponents, $forceExclusion);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
sub GetEnv {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
  my $iniData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
  my $env = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
  my $installSource = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
  my $sourceInstallPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
  my $overwriteSource = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
  my $removeSource = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
  my $verbose = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
  my $excludeComponents = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  my $forceExclusion = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
  my $envDb = EnvDb->Open($iniData, $verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
  my %compsToInstall;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
  my %cleanComps;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
  my @compsToRemove;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
  # Edit the list of components if $excludeComponents is set
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
  if (defined $excludeComponents){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
	  $env = FilterCompsToExclude($env, $excludeComponents, $verbose, $forceExclusion);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
  # Check the status of each component in the new environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
  my $error = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
  foreach my $thisComp (sort keys %{$env}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
    my $thisVer = $env->{$thisComp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
    $iniData->PathData()->CheckReleaseExists($thisComp, $thisVer);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
    my $installedVer = $envDb->Version($thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
    if (defined $installedVer) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
      if ($installedVer eq $thisVer) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
        # The requested version is already installed, so check its status.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
        (my $status) = $envDb->CheckComp($thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
        if ($status == EnvDb::STATUS_CLEAN) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
          # Do nothing.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
          if ($verbose) { print "$thisComp $thisVer is already installed, and is clean\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
          $cleanComps{$thisComp} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
        elsif ($status == EnvDb::STATUS_PENDING_RELEASE && !$overwriteSource) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
          print "Error: $thisComp is pending release\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
          $error = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
        elsif ($status == EnvDb::STATUS_DIRTY || $status == EnvDb::STATUS_DIRTY_SOURCE || $status == EnvDb::STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
          if ($verbose) { print "$thisComp $thisVer is already installed, but is dirty\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
          push (@compsToRemove, $thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
          $compsToInstall{$thisComp} = $thisVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
        elsif ($status == EnvDb::STATUS_NOT_INSTALLED) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
          die;
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
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
        if ($envDb->Status($thisComp) == EnvDb::STATUS_PENDING_RELEASE && !$overwriteSource) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
          print "Error: $thisComp is pending release\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
          $error = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
        if ($verbose) { print "$thisComp $installedVer currently installed\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
        push (@compsToRemove, $thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
        $compsToInstall{$thisComp} = $thisVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
      $compsToInstall{$thisComp} = $thisVer;
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
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
  if ($error) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
    die "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
  # Add to the remove list components in the current environment that aren't in the new environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
  my $currentEnv = $envDb->VersionInfo();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
  foreach my $thisComp (keys %{$currentEnv}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
    unless (exists $compsToInstall{$thisComp} or exists $cleanComps{$thisComp}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
      (my $status) = $envDb->CheckComp($thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
      if ($status == EnvDb::STATUS_CLEAN) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
	if ($verbose) { print "$thisComp currently installed (clean), but not in new environment - will be removed\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
	push (@compsToRemove, $thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
      elsif ($status == EnvDb::STATUS_DIRTY || $status == EnvDb::STATUS_DIRTY_SOURCE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
	if ($verbose) { print "$thisComp currently installed (dirty), but not in new environment - will be removed\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
	push (@compsToRemove, $thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
      elsif ($status == EnvDb::STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
	print "Warning: $thisComp is pending release - its binaries cannot be automatically removed.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
	print "         Continue with GetEnv? [y/n] ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
	my $response = <STDIN>;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
	chomp $response;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
	if (lc $response eq 'y') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
	  # Remove EnvDb entry.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
	  my $ver = $envDb->Version($thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
	  if (defined $ver) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
	    $envDb->DeleteSignature($thisComp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
	    $envDb->SetVersion($thisComp, undef);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
	  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
	  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
	    die;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
	  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
	else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
	  die "GetEnv aborted\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
      elsif ($status == EnvDb::STATUS_NOT_INSTALLED) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
	die;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
  # Remove old binaries and source.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
  foreach my $thisComp (@compsToRemove) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
    print "Removing $thisComp...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
    if ($removeSource) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
      $envDb->DeleteSource($thisComp, 0, 1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
    $envDb->RemoveComponent($thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
  # Install new binaries (and possibly source).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
  foreach my $thisComp (sort keys %compsToInstall) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
    my $thisVer = $compsToInstall{$thisComp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
    print "Installing $thisComp $thisVer...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
    $envDb->InstallComponent($thisComp, $thisVer, $overwriteSource);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
    if ($installSource) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
      my $installPath = $sourceInstallPath;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
      if (!defined ($installPath)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
        $installPath="\\";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
      $envDb->UnpackSource($thisComp, $thisVer, $installPath, $overwriteSource, 1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
}
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
sub FilterCompsToExclude {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
	my $editEnv = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
	my $excludeComp = lc (shift); 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
	my $verbose = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
	my $forceExclusion = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
	my $editFlag = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
			
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
	print "Checking components to exclude...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
	if(-f $excludeComp) {			# file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
		open FILE, "$excludeComp" or die "Unable to open exclude file $excludeComp - $!. Requested components for exclusion will not be excluded. ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
		
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
		while (<FILE>) {	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
			if(ExcludeComp($_, $editEnv, $verbose) and ($editFlag == 0)){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
				$editFlag = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
			}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
		}				
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
	else{							# single component name
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
		if(ExcludeComp($excludeComp, $editEnv, $verbose)){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
			$editFlag = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
	}	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
	# Make user aware of what they are doing
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
	if(($editFlag) and not ($forceExclusion)){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
		print "Are you happy to continue installing a Release with excluded components? - y/n\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
		my $input = <STDIN>;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
		unless($input =~ /^y$/i){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
			die "Getenv aborted.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
		}	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
	}	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
	print "\n";	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
	return $editEnv;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
sub ExcludeComp{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
	my $component = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
	my $env = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
	my $verbose = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
	my $editFlag = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
	chomp ($component);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
	$component =~ s/\s+$//;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
	$component =~ s/^\s+//;	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
	$component = lc ($component);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
	if($component =~ /^$/){					# empty string
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
	elsif($component =~ /^[\w\.-]+\*$/){			# wild cards
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
		$component =~ s!([\w\.-]+)\*$!$1!;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
		foreach my $comp (keys %{$env}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
			if($comp =~ /^\Q$component\E/){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
				$editFlag = ExcludeComp($comp, $env, $verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
			}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
	}	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
	elsif($component =~ /\*$/){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
		print "$component - did not understand line - ignoring.\n";	# do nothing
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
	}			 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
	elsif($component !~ /\s/){				# possible component name
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
		if (exists $$env{$component}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
			print "$component will be excluded from the new environment as requested.\n" if $verbose;				
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
			delete $$env{$component};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
			$editFlag = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
		else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
			print "$component is not in the archive so cannot exclude it from the new environment.\n" if $verbose;			
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
	else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
		print "'$component' contains spaces in its name - this is not a valid component name.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
	}	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
	return $editFlag;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
GetEnv.pm - Provides an interface for installing and upgrading environments.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
=head1 INTERFACE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
=head2 GetEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
Expects to be passed an C<IniData> reference, a reference to a hash containing the required component release versions, a flag indicating if to install source, a source install path (which may be undefined), a flag indicating if to overwrite source, a flag indicating whether there are components to be excluded or not and a verboisty level. Installs the specified component releases by adding, removing and upgrading existing components as required.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
=head2 GetEnvFromRelData
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
Expects to be passed an C<IniData> reference, a component name, a version, a flag indicating if to install source, a source install path (which may be undefined), a flag indicating if to overwrite source, a flag indicating whether there are components to be excluded or not and a verboisty level. Retreives the version information associated with the specified component release version, and calls C<GetEnv> to install them.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
 Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   295
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   296
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   301
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   302
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   303
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   304
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   305
=cut
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   306
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   307
__END__