Subversion Repositories DevTools

Rev

Rev 5710 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#! perl
########################################################################
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
#
# Module name   : jats.sh
# Module type   : Makefile system
# Compiler(s)   : n/a
# Environment(s): jats
#
# Description   : Examine SITS Legacy and SITS TOT+AVM releases and
#                 ensure that the packages are in-sync. The build number are
#                 allowed to differ.
#
#                 Lots of hard coding in this
#
# Usage:
#
# Version   Who      Date        Description
#
#......................................................................#

require 5.006_001;
use strict;
use warnings;
use JatsError;
use JatsVersionUtils;
use JatsRmApi;

#use Data::Dumper;
use DBI;
use Cwd;

my $GBE_PERL     = $ENV{'GBE_PERL'};        # Essential ENV variables
my $GBE_CORE     = $ENV{'GBE_CORE'};
my $opt_verbose = 0;
my %all_names;
my @stop_list = qw (ERGavm.syd AVMAppUpgrade.syd AVMApplicationEngine.syd
                    ERGavmug.syd ERGtot.syd ERGtotug.syd IDC.syd IDCDB.syd ocp5000.syd
                    );

my %stop_list = map { ${_} => 1 } @stop_list;
my $RM_DB;


my @GDATA;
sub getPkgDetailsByRTAG_ID
{
    my ($RTAG_ID, $datap) = @_;
    my $foundDetails = 0;
    my (@row);

    # if we are not or cannot connect then return 0 as we have not found anything
    connectRM ( \$RM_DB ) unless ( $RM_DB );

    # First get details from pv_id

    my $m_sqlstr = "SELECT pv.PV_ID, pkg.PKG_NAME, pv.PKG_VERSION, pv.PKG_LABEL, pv.SRC_PATH, pv.BUILD_TYPE" .
                    " FROM RELEASE_CONTENT rc, PACKAGE_VERSIONS pv, PACKAGES pkg" .
                    " WHERE rc.RTAG_ID = $RTAG_ID AND rc.PV_ID = pv.PV_ID AND pv.PKG_ID = pkg.PKG_ID";
    my $sth = $RM_DB->prepare($m_sqlstr);
    if ( defined($sth) )
    {
        if ( $sth->execute( ) )
        {
            if ( $sth->rows )
            {
                while ( @row = $sth->fetchrow_array )
                {
                    my ($name, $version, $suffix, $full ) = SplitPackage ($row[1], $row[2]);
                    my ($maj, $min, $patch, $build ) = SplitVersion( $version );

#print "$name, $suffix, $version, -- $maj, $min, $patch, $build\n";
                    $name .= '.' . $suffix if $suffix;
                    $datap->{$name} = join( '.', $maj,$min,$patch);
                    $all_names{$name} = 1;

#printf ( "%40s %-15s %s\n",  $name, "$maj.$min.$patch.$build", $row[2]);
                }
            }
            $sth->finish();
        }
    }
    else
    {
        Error("Prepare failure" );
    }

    disconnectRM(\$RM_DB);

}

#-------------------------------------------------------------------------------
# Function        : Main
#
# Description     :
#
# Inputs          :
#
# Returns         :
#

ErrorConfig( 'name'    =>'SANITY' );

#
#   Get versions for the two packages
#
my %legacy;
my %avm;

getPkgDetailsByRTAG_ID(1861, \%legacy);        # 1861 : Syd Release Legacy
getPkgDetailsByRTAG_ID(3822, \%avm);           # 3822 : Syd Tot and AVM

#DebugDumpData ("Legacy", \%legacy );

#
#   Examine all packages
#
my $same = 0;
my $diff = 0;
my $not_common = 0;
my @diffs;

foreach my $package ( sort keys %all_names )
{
#    print "Examine: $package\n";
    next if ( $stop_list{ $package} );

    if ( exists $legacy{$package} && exists $avm{$package} )
    {
#        print "Package in both: $package\n";
        if ( $legacy{$package} ne $avm{$package} )
        {
#            print "Package differs $package: $legacy{$package} ne $avm{$package}\n";
            $diff ++;
            push @diffs, $package;
        }
        else
        {
            $same++;
        }
    }
    else
    {
        $not_common++;
#        print "Package not in both\n";
    }
}

if ( $diff )
{
    print "The following packages are different\n\n";
    foreach my $package ( @diffs )
    {
        printf( "%30s Legacy: >%9s<    AVM-TOT:%9s\n", $package, $legacy{$package}, $avm{$package});
    }
}
print "\nPackage same: $same, Different: $diff, Stopped: $#stop_list, Not Common: $not_common\n";


exit;