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