Rev 7299 | Blame | Compare with Previous | Last modification | View Log | RSS feed
######################################################################### COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.## Module name : jats_ccmerge_build# Module type : JATS Utility# Environment(s): JATS## Description : A script to merge a build.pl from an autobuilder branch back# to the main line.# a build.##......................................................................#require 5.006_001;use strict;use warnings;use JatsError;use JatsSystem;use FileUtils;use Pod::Usage; # required for help supportuse Getopt::Long;use File::Copy;use Cwd;my $VERSION = "1.5.5"; # Update this## Options#my $opt_debug = $ENV{'GBE_DEBUG'}; # Allow global debugmy $opt_verbose = $ENV{'GBE_VERBOSE'}; # Allow global verbosemy $opt_help = 0;## Global Data#my $UNIX = $ENV{'GBE_UNIX'};my @error_list;my $last_result;my @last_results;#-------------------------------------------------------------------------------# Function : Mainline Entry Point## Description :## Inputs :### Parse the user options#my $result = GetOptions ("help|h:+" => \$opt_help,"manual:3" => \$opt_help,"verbose|v:+" => \$opt_verbose, # flag, multiple use allowed);## UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!### Process help and manual options#pod2usage(-verbose => 0, -message => "Version: $VERSION")if ($opt_help == 1 || ! $result || $#ARGV >= 0);pod2usage(-verbose => 1) if ($opt_help == 2 );pod2usage(-verbose => 2) if ($opt_help > 2);## Configure the error reporting process now that we have the user options#ErrorConfig( 'name' => 'MERGBUILD','verbose' => $opt_verbose );## Only for windows#Error ("This program only works under Windows")if ( $UNIX );## Determine the branch of the build.pl file#Error ("No build.pl file found" )unless ( -f 'build.pl' );ClearCmd ('describe', '-fmt', '%Sn', 'build.pl' );Error ('Can\'t describe build.pl', @error_list) if @error_list;Error ('build.pl may be hijacked. It is not a Vob Object') unless ( $last_result );my $branch = $last_result;Verbose ("Branch: $branch");## Determine parent branch#my @parts = split( '/', $branch );Error ("Build.pl is not on an AutoBuilder Branch." )unless ( $parts[-2] =~ m~^AutoBuilder\.~ );my $parent = join ('/', @parts[0 .. $#parts - 2]);Verbose "Parent Branch: $parent\n";## Checkout the build.pl file on the parent branch#File::Copy::copy( 'build.pl', 'build.pl.merge' );ClearCmd ('co', '-unreserved', '-c', 'Merged back from AutoBuild', '-ndata', 'build.pl@@'.$parent.'/LATEST');Error ('Can\'t checkout build.pl', @error_list) if @error_list;## Draw a merge link to show what has been done#Verbose ("Creating Hyperlink" );my $source_name = 'build.pl@@'.$branch;my $target_name = 'build.pl@@'.$parent.'/CHECKEDOUT';ClearCmd ('mkhlink', 'Merge', $source_name, $target_name);Warning ('Can\'t create merge arrows', @error_list) if @error_list;## Copy in the base build.pl file and make it writable#Verbose ('Copy original build.pl file');File::Copy::move( 'build.pl.merge', 'build.pl' );chmod( 0755, 'build.pl' );exit 0;#-------------------------------------------------------------------------------# Function : ClearCmd## Description : Execute a ClearCase command and capture the results# Errors are held in one array# Result are held in another## Inputs :## Returns :#sub ClearCmd{my $cmd = QuoteCommand (@_);Verbose2( "cleartool $cmd" );@error_list = ();@last_results = ();$last_result = undef;open(CMD, "cleartool $cmd 2>&1 |") || Error( "can't run command: $!" );while (<CMD>){chomp;$last_result = $_;$last_result =~ tr~\\/~/~s;push @last_results, $last_result;Verbose2 ( "cleartool resp:" . $_);push @error_list, $_ if ( m~Error:~ );}close(CMD);Verbose2( "Exit Status: $?" );return $? / 256;}#-------------------------------------------------------------------------------# Documentation#=pod=for htmltoc GENERAL::ClearCase::=head1 NAMEjats_ccmerge_build - Merge autobuilt build.pl file to parent branch=head1 SYNOPSISjats jats_ccmerge_build [options]Options:-help - brief help message-help -help - Detailed help message-man[=n] - Full documentation-verbose[=n] - Control program verbosity=head1 OPTIONS=over 8=item B<-help>Print a brief help message and exits.=item B<-help -help>Print a detailed help message with an explanation for each option.=item B<-man[=n]>Prints the manual page and exits.If a numeric manual level is provide then it will be used to control theverbosity of help provided. This should be in the range of 1 to 3.=item B<--verbose[=n]>This option will increase the level of verbosity of the JATS command and commandinvoked by the JATS shell.If an argument is provided, then it will be used to set the level, otherwise theexisting level will be incremented. This option may be specified multiple times.=back=head1 DESCRIPTIONThis program assists in the maintainance of the the JATS build.pl file.When a package is rippled by the build daemons the resultant build.pl file isplaced on a ClearCase branch dedicated to the AutoBuild process. When a developermanually modifies the build file it 'should' be on the packages main branch andnot on the daemons AutoBuild branch.This utility simplifies this process. The utility will:=over 8=item *Ensure that the build.pl file exists=item *Determine the full ClearCase branch of the build.pl fileThis command can only be executed within a ClearCase view. Moreover the usermust have located the build.pl file. If the build.pl file is not on anAutoBuilder branch then the utility will terminate.=item *Determine the parent of the AutoBuiler branch=item *Checkout the build.pl on the tail of the parent branchThe original 'build.pl' is preserved. At the end of the checkout the versionthat is checkout will have the content of the original build.pl=item *Draw a Merge Arraw from the build.pl to the checked out version.=item *Mark the resultant file writable.=back=cut