Blame | Last modification | View Log | RSS feed
######################################################################### COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.## Module name : rmMerge_listVersions.pl# Module type : JATS Utility# Compiler(s) : Perl# Environment(s): jats## Description : List package names of all packages imported from Pulse## Usage : See POD at the end of this file##......................................................................#require 5.008_002;use strict;use warnings;use Pod::Usage;use Getopt::Long;use Pod::Usage;use Getopt::Long;use JatsError;use JatsRmApi;use JatsSystem;use FileUtils;use ConfigurationFile;use JatsProperties;use File::Copy;use DBI;my $RM_DB;my $oldRMCred = ['OLD', 'jdbc:oracle:thin:@auawsards001:1521:RELEASEM', 'RM_READONLY', 'RM_READONLY'];my $VERSION = 1.0;my $opt_help=0;my $opt_verbose=0;my $opt_debug=0;my $opt_execute;my $opt_ripple;my $pname;my $pversion;my $pvid;#-------------------------------------------------------------------------------# Function : Mainline Entry Point## Description :## Inputs :#my $result = GetOptions ("help:+" => \$opt_help,"manual:3" => \$opt_help,"verbose:+" => \$opt_verbose,"debug:+" => \$opt_debug,"execute!" => \$opt_execute,);## 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);pod2usage(-verbose => 1) if ( $opt_help == 2 );pod2usage(-verbose => 2) if ( $opt_help > 2 );pod2usage(-verbose => 0, -message => "Version: $VERSION") if ( $#ARGV >= 0 );## Configure the error reporting rmMerge_process now that we have the user options#ErrorConfig( 'name' =>'MIGRATE','verbose' => $opt_verbose,'debug' => $opt_debug,);$pname = shift @ARGV;$pversion =shift @ARGV;my $newData = getData($oldRMCred);foreach my $entry ( @{$newData}) {#System ('sbin/getPkgFromS3.sh', "--bucket=$config{S3Bucket}", '-p', $::GBE_DPKG . '/' . $pv);print("./getPkgTarFromS3.sh $entry->[3] -p=s3Store $entry->[4]\n");System("./getPkgTarFromS3.sh", $entry->[3], '-ps3Store', $entry->[4]);}#-------------------------------------------------------------------------------# Function : getData## Description : Determine if the version exists in a RM instance## Inputs : rmRef - Ref to RM credentials## Returns : Not found - undef# Founf - nice data#sub getData{my ($rmRef) = @_;my $m_sqlstr = <<"END_SQL";SELECTpv.pv_id,pv.pkg_id,pv.pkg_idext,p.pkg_name,pv.pkg_version,pv.v_extFROM release_manager.package_versions pv, release_manager.packages pwhere p.pkg_id = pv.pkg_idand pv.comments like '%Version Imported from Pulse%'END_SQLmy $data = getDataFromRm('checkVersion', $m_sqlstr, $rmRef, {dump => 0, oneRow => 0, 'error' => 'Cannot find named package'});$pvid = $data->[0];return $data;}# Function : getDataFromRm## Description : Get an array of data from RM## Inputs : $name - Query Name# $m_sqlstr - Query# $rmRef - Ref to RM# $options - Ref to a hash of options# sql - show sql# data - show data# dump - show results# oneRow - Only feth one row# error - Must find data## Returns :#sub getDataFromRm{my ($name,$m_sqlstr, $rmRef, $options ) = @_;my @row;my $data;if (ref $options ne 'HASH') {$options = {};}$ENV{GBE_RM_LOCATION} = $rmRef->[1];$ENV{GBE_RM_USERNAME} = $rmRef->[2];$ENV{GBE_RM_PASSWORD} = $rmRef->[3];connectRM(\$RM_DB, $opt_verbose);if ($options->{sql}) {Message("$name: $m_sqlstr")}my $sth = $RM_DB->prepare($m_sqlstr);if ( defined($sth) ){if ( $sth->execute( ) ) {if ( $sth->rows ) {while ( @row = $sth->fetchrow_array ) {if ($options->{data}) {Message ("$name: @row");}#Debug0("$name: @row");push @{$data}, [@row];last if $options->{oneRow};}}$sth->finish();} else {Error("Execute failure:$name: $m_sqlstr", $sth->errstr() );}} else {Error("Prepare failure:$name" );}disconnectRM(\$RM_DB);if (!$data && $options->{error}) {Error( $options->{error} );}if ($data && $options->{oneRow}) {$data = $data->[0];}if ($options->{dump}) {DebugDumpData("$name", $data);}return $data;}#-------------------------------------------------------------------------------# Documentation#=pod=for htmltoc GENERAL::ClearCase::=head1 NAMErmMerge_listVersions - list versions of a package=head1 SYNOPSISjats rmMerge_listVersions [options] PackageName PackageVersion -- commandsOptions:-help - brief help message-help -help - Detailed help message-man - Full documentation-verbose[=n] - Enable additional output-execute - Execure commands-[no]ripple - Include ripples - default no=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<-versbose[=n]>Enable additional output=item B<-execute>When the execute option is provided this utility will execute the displayed commnads.=back=head1 EXAMPLEjats eprog rmMerge_listVersions PackageName PackageVersion -execute -- rmMerge_migrate_package -t {1} {2}Commands will be display and/or execued with the following substitutions=over 8=item * {1} the package name=item * {2} the current version number of the package=item * {3} the previous version number of the package=back=cut