Subversion Repositories DevTools

Rev

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

#! perl
########################################################################
# Copyright ( C ) 2004 ERG Limited, All rights reserved
#
# Module name   : jats.sh
# Module type   : Makefile system
# Compiler(s)   : n/a
# Environment(s): jats
#
# Description   : Display the currently released version of ALL packages
#                 that are a part of a given release
#
#                   Displays the previous vesrion of the package as well
#
#                 Currently hard coded to SEATTLE (SEA) > Phase 2 - I2
#
# Usage:
#
# Version   Who      Date        Description
#
#......................................................................#

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

#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 = 1;
my $RM_DB;
my @GDATA;
my %PVID;

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

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

    # First get details from pv_id

    my $m_sqlstr = "SELECT pv.PV_ID, pkg.PKG_NAME, pv.PKG_VERSION, pv.LAST_PV_ID" .
                   " 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( ) )
        {
            print "--- Execute\n";
            if ( $sth->rows )
            {
                print "--- Execute ROWS\n";
                while ( @row = $sth->fetchrow_array )
                {
                    my $pvid = $row[0];
                    $PVID{$pvid}{pv_id}            = $row[0];
                    $PVID{$pvid}{name}             = $row[1];
                    $PVID{$pvid}{version}          = $row[2];
                    $PVID{$pvid}{last_pv_id}       = $row[3];
                    push @GDATA, $pvid;
print "$row[1], $row[2]\n";                    
                }
            }
            print "--- Finish\n";
            $sth->finish();
        }
        else
        {
            Error("getPkgDetailsByRTAG_ID: Execute failure", $m_sqlstr );
        }
    }
    else
    {
        Error("Prepare failure" );
    }
}

#-------------------------------------------------------------------------------
# Function        : getPkgDetailsByPV_ID
#
# Description     : Populate the Packages structure given a PV_ID
#
# Inputs          : PV_ID           - Package Unique Identifier
#
# Returns         : Populates Package
#
sub getPkgDetailsByPV_ID
{
    my ($PV_ID) = @_;
    my $foundDetails = 0;
    my (@row);

    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.LAST_PV_ID" .
                    " FROM PACKAGE_VERSIONS pv, PACKAGES pkg" .
                    " WHERE pv.PV_ID = \'$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 $pvid = $row[0];
                    $PVID{$pvid}{pv_id}            = $row[0];
                    $PVID{$pvid}{name}             = $row[1];
                    $PVID{$pvid}{version}          = $row[2];
                    $PVID{$pvid}{last_pv_id}       = $row[3];
                }
            }
            else
            {
#                Warning ("No Package details for: PVID: $PV_ID");
            }
            $sth->finish();
        }
        else
        {
            Error("getPkgDetailsByPV_ID: Execute failure", $m_sqlstr );
        }
    }
    else
    {
        Error("Prepare failure" );
    }
}


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

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


getPkgDetailsByRTAG_ID(9011);           # SEATTLE (SEA) > Phase 2 - I2
#DebugDumpData("GDATA", \@GDATA);

#
#   Display package and previous versions
#
my $count = 0;
foreach my $pvid ( @GDATA )
{
    my ( $name, $ver, $proj ) = SplitPackage($PVID{$pvid}{name}, $PVID{$pvid}{version} );
    my ( $major, $minor, $patch, $build ) = SplitVersion( $ver );

    my $suspect;
    my @prev;
#    push @prev, $PVID{$pvid}{version};
    my $this_pv_id = $pvid;
    foreach my $ii ( 1..4 )
    {
        if ( $PVID{$this_pv_id}{last_pv_id} == $this_pv_id )
        {
            last;
        }
        my $last_pv_id = $PVID{$this_pv_id}{last_pv_id} ;
        getPkgDetailsByPV_ID ($last_pv_id );
        if ( exists $PVID{$last_pv_id} )
        {
            push @prev, $PVID{$last_pv_id}{version};

        my ( $xname, $xver, $xproj ) = SplitPackage($PVID{$pvid}{name}, $PVID{$last_pv_id}{version} );
        my ( $xmajor, $xminor, $xpatch, $xbuild ) = SplitVersion( $xver );

#print "$major.$minor,$patch :: $xmajor, $xminor, $xpatch\n";
        if ( $xmajor > $major )
        {
            $suspect = 1;
        }
        elsif ( $xmajor == $major )
        {
            if ( $xminor > $minor )
            {
                $suspect = 1;
            }
            elsif ( $xminor == $minor )
            {
                if ( $xpatch > $patch )
                {
                    $suspect = 1;
                }
                elsif ( $xpatch == $patch )
                {
                    if ( $xbuild > $build )
                    {
                        $suspect = 1;
                    }
                }

            }

        }


#print "------- $PVID{$last_pv_id}{version}\n";
            $major = $xmajor;
            $minor = $xminor;
            $patch = $xpatch;
            $build = $xbuild;
            $this_pv_id = $last_pv_id;
            $last_pv_id = $PVID{$last_pv_id}{last_pv_id} ;
        }
        else
        {
            last;
        }
    }

    printf( "%1.1s%30s, %20s :: %s",
        $suspect ? '*' : ' ',
        $PVID{$pvid}{name},
        $PVID{$pvid}{version},
        "@prev"
        );
    print "\n";

#    last if ( ++$count > 10 );
}

exit;