releasing/makecbr/MakeCBR.pl
author Zheng Shen <zheng.shen@nokia.com>
Wed, 27 Oct 2010 19:16:18 +0800
changeset 663 8e27d440923e
parent 602 3145852acc89
permissions -rw-r--r--
revert to 7c11c3d8d025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
#!/bin/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
# Automated Component Based Releasing system front end
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
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
use Getopt::Long;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
use Cwd;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use FindBin;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use lib $FindBin::Bin;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use CStageRunner;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
use CConfig;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
my @GTTechViewPrepareStages=("CCreateDrive","CGetPrevRel","CCheckMrpUpdates","CDelta", "CCheckEnv");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
my @GTTechViewReleaseStages=("CReleaseEnv","CStoreMrpState");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
my @GTstages=("CRemoveNonGT", "CInstallGTConflicts", "CPrepGTRelease", "CCheckEnv", "CReleaseEnv");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
my @finishStages=("CCleanUp");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
my $help = q/
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
  makecbr.pl -b build_id -c config_file -v release_version [-j max_processes]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
    [-i int_version] [-p prev_version] [-l log_file] [-d debug_output] [-repair]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
   * where:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
  build_id is a unique build identifier
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
  config_file is the filename of the configuration file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
  release_version is the version to be assigned to any updated components
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
   * Optionally:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
  max_processes is the maximum number of parallel processes allowed
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
  int_version is the internal version string to use for publishing components
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
  prev_version is the version to assume as the previous baseline, to override
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
    automatic determination
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
  log_file is a file to log all output to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
  debug_output is a file to write intermediate stage output to in case of an
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
    error
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
   * -repair assumes a failure in GT_TechView and resumes from the MakeEnv step.
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
my($build_id, $config_file, $log_file, $parallel, $release_ver, $debug_file, $help_flag, $prev_ver, $repair, $int_ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
GetOptions (
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
   'b=s'    => \$build_id,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
   'c=s'    => \$config_file,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
   'l=s'    => \$log_file,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
   'v=s'    => \$release_ver,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
   'p=s'    => \$prev_ver,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
   'd=s'    => \$debug_file,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
   '+h'     => \$help_flag,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
   'repair' => \$repair,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
   'i=s'    => \$int_ver,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
   'j=i'    => \$parallel
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
if (defined($help_flag))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
	print $help;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
	exit;
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
if (!defined($config_file))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
	die "A configuration file must be specified (using the -c option)\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
if (!defined($parallel)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
   $parallel = 0;
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
my $options = New CConfig();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
if (defined($log_file))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
	$options->SetLog($log_file) or exit;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
if (defined($debug_file))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
	# Ensure path isn't relative
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
	if ($debug_file !~ /^[A-Za-z]:/)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
		{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
		if ($debug_file =~ /^[^\/\\]/)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
			{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
			# Path is relative
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
			$debug_file = getcwd()."\\".$debug_file;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
			}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
		else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
			{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
			# Path is only missing drive letter
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
			my $drive = getcwd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
			$drive =~ s/^([A-Za-z]):.*$/$1/ or $options->Die("ERROR: getcwd() did not return drive letter, rather '$drive'");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
			$debug_file = $drive.":".$debug_file;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
			}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
	$debug_file =~ s/\//\\/g; # Make all slashes backslashes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
$options->Reload($config_file) or $options->Die("ERROR: Couldn't load config file '$config_file'");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
$options->Set("Build identifier",$build_id) or $options->Die("ERROR: Build identifier '$build_id' is invalid");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
$options->Set("Release version",$release_ver) or $options->Die("ERROR: Release version '$release_ver' is invalid");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
if (defined($int_ver))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
    {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
    $options->Set("Internal version",$int_ver) or $options->Die("ERROR: Internal version '$int_ver' is invalid");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
    {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
    $options->Set("Internal version",$release_ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
if (defined($prev_ver))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
	$options->Set("Last baseline version",$prev_ver) or $options->Die("ERROR: Previous baseline version '$prev_ver' is invalid");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
if (defined($parallel)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
   $options->Set('Max Parallel Tasks', $parallel) or $options->Die("ERROR: Max parallel processes '$parallel' is invalid");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
my @stages = ();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
if (defined($repair))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
	push @stages, "CConfigureRepair";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
	push @stages, @GTTechViewPrepareStages;
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
push @stages, (@GTTechViewReleaseStages, @GTstages, @finishStages);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
my $stageRunner = New CStageRunner(\@stages, $options);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
if (!$stageRunner->Run())
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
	if (defined($debug_file))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
		{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
		$options->Save($debug_file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
	$options->Die("");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
	}