Subversion Repositories DevTools

Rev

Rev 392 | Rev 5710 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
392 dpurdie 1
#! perl
2
########################################################################
3
# Copyright ( C ) 2004 ERG Limited, All rights reserved
4
#
5
# Module name   : jats.sh
6
# Module type   : Makefile system
7
# Compiler(s)   : n/a
8
# Environment(s): jats
9
#
10
# Description   : Display the currently released version of ALL packages
11
#                 that are a part of a given release
12
#
13
#                   Displays the previous vesrion of the package as well
14
#
15
#                 Currently hard coded to SEATTLE (SEA) > Phase 2 - I2
16
#
17
# Usage:
18
#
19
# Version   Who      Date        Description
20
#
21
#......................................................................#
22
 
23
require 5.006_001;
24
use strict;
25
use warnings;
26
use JatsError;
27
use JatsRmApi;
28
use JatsVersionUtils;
29
 
30
#use Data::Dumper;
31
use DBI;
32
use Cwd;
33
 
34
my $GBE_PERL     = $ENV{'GBE_PERL'};        # Essential ENV variables
35
my $GBE_CORE     = $ENV{'GBE_CORE'};
36
my $opt_verbose = 1;
37
my $RM_DB;
38
my @GDATA;
39
my %PVID;
40
 
41
sub getPkgDetailsByRTAG_ID
42
{
43
    my ($RTAG_ID) =@_;
44
    my $foundDetails = 0;
45
    my (@row);
46
 
47
    # if we are not or cannot connect then return 0 as we have not found anything
48
    connectRM(\$RM_DB);
49
 
50
    # First get details from pv_id
51
 
52
    my $m_sqlstr = "SELECT pv.PV_ID, pkg.PKG_NAME, pv.PKG_VERSION, pv.LAST_PV_ID" .
53
                   " FROM RELEASE_CONTENT rc, PACKAGE_VERSIONS pv, PACKAGES pkg" .
54
                   " WHERE rc.RTAG_ID = $RTAG_ID AND rc.PV_ID = pv.PV_ID AND pv.PKG_ID = pkg.PKG_ID";
55
    my $sth = $RM_DB->prepare($m_sqlstr);
56
    if ( defined($sth) )
57
    {
58
        if ( $sth->execute( ) )
59
        {
60
            print "--- Execute\n";
61
            if ( $sth->rows )
62
            {
63
                print "--- Execute ROWS\n";
64
                while ( @row = $sth->fetchrow_array )
65
                {
66
                    my $pvid = $row[0];
67
                    $PVID{$pvid}{pv_id}            = $row[0];
68
                    $PVID{$pvid}{name}             = $row[1];
69
                    $PVID{$pvid}{version}          = $row[2];
70
                    $PVID{$pvid}{last_pv_id}       = $row[3];
71
                    push @GDATA, $pvid;
72
print "$row[1], $row[2]\n";                    
73
                }
74
            }
75
            print "--- Finish\n";
76
            $sth->finish();
77
        }
78
        else
79
        {
80
            Error("getPkgDetailsByRTAG_ID: Execute failure", $m_sqlstr );
81
        }
82
    }
83
    else
84
    {
85
        Error("Prepare failure" );
86
    }
87
}
88
 
89
#-------------------------------------------------------------------------------
90
# Function        : getPkgDetailsByPV_ID
91
#
92
# Description     : Populate the Packages structure given a PV_ID
93
#
94
# Inputs          : PV_ID           - Package Unique Identifier
95
#
96
# Returns         : Populates Package
97
#
98
sub getPkgDetailsByPV_ID
99
{
100
    my ($PV_ID) = @_;
101
    my $foundDetails = 0;
102
    my (@row);
103
 
104
    connectRM(\$RM_DB) unless ($RM_DB);
105
 
106
    # First get details from pv_id
107
 
108
    my $m_sqlstr = "SELECT pv.PV_ID, pkg.PKG_NAME, pv.PKG_VERSION, pv.LAST_PV_ID" .
109
                    " FROM PACKAGE_VERSIONS pv, PACKAGES pkg" .
110
                    " WHERE pv.PV_ID = \'$PV_ID\' AND pv.PKG_ID = pkg.PKG_ID";
111
 
112
    my $sth = $RM_DB->prepare($m_sqlstr);
113
    if ( defined($sth) )
114
    {
115
        if ( $sth->execute( ) )
116
        {
117
            if ( $sth->rows )
118
            {
119
                while ( @row = $sth->fetchrow_array )
120
                {
121
                    my $pvid = $row[0];
122
                    $PVID{$pvid}{pv_id}            = $row[0];
123
                    $PVID{$pvid}{name}             = $row[1];
124
                    $PVID{$pvid}{version}          = $row[2];
125
                    $PVID{$pvid}{last_pv_id}       = $row[3];
126
                }
127
            }
128
            else
129
            {
130
#                Warning ("No Package details for: PVID: $PV_ID");
131
            }
132
            $sth->finish();
133
        }
134
        else
135
        {
136
            Error("getPkgDetailsByPV_ID: Execute failure", $m_sqlstr );
137
        }
138
    }
139
    else
140
    {
141
        Error("Prepare failure" );
142
    }
143
}
144
 
145
 
146
#-------------------------------------------------------------------------------
147
# Function        : Main
148
#
149
# Description     :
150
#
151
# Inputs          :
152
#
153
# Returns         :
154
#
155
 
156
ErrorConfig( 'name'    =>'PLAY5a' );
157
 
158
 
159
getPkgDetailsByRTAG_ID(9011);           # SEATTLE (SEA) > Phase 2 - I2
160
#DebugDumpData("GDATA", \@GDATA);
161
 
162
#
163
#   Display package and previous versions
164
#
165
my $count = 0;
166
foreach my $pvid ( @GDATA )
167
{
168
    my ( $name, $ver, $proj ) = SplitPackage($PVID{$pvid}{name}, $PVID{$pvid}{version} );
169
    my ( $major, $minor, $patch, $build ) = SplitVersion( $ver );
170
 
171
    my $suspect;
172
    my @prev;
173
#    push @prev, $PVID{$pvid}{version};
174
    my $this_pv_id = $pvid;
175
    foreach my $ii ( 1..4 )
176
    {
177
        if ( $PVID{$this_pv_id}{last_pv_id} == $this_pv_id )
178
        {
179
            last;
180
        }
181
        my $last_pv_id = $PVID{$this_pv_id}{last_pv_id} ;
182
        getPkgDetailsByPV_ID ($last_pv_id );
183
        if ( exists $PVID{$last_pv_id} )
184
        {
185
            push @prev, $PVID{$last_pv_id}{version};
186
 
187
        my ( $xname, $xver, $xproj ) = SplitPackage($PVID{$pvid}{name}, $PVID{$last_pv_id}{version} );
188
        my ( $xmajor, $xminor, $xpatch, $xbuild ) = SplitVersion( $xver );
189
 
190
#print "$major.$minor,$patch :: $xmajor, $xminor, $xpatch\n";
191
        if ( $xmajor > $major )
192
        {
193
            $suspect = 1;
194
        }
195
        elsif ( $xmajor == $major )
196
        {
197
            if ( $xminor > $minor )
198
            {
199
                $suspect = 1;
200
            }
201
            elsif ( $xminor == $minor )
202
            {
203
                if ( $xpatch > $patch )
204
                {
205
                    $suspect = 1;
206
                }
207
                elsif ( $xpatch == $patch )
208
                {
209
                    if ( $xbuild > $build )
210
                    {
211
                        $suspect = 1;
212
                    }
213
                }
214
 
215
            }
216
 
217
        }
218
 
219
 
220
#print "------- $PVID{$last_pv_id}{version}\n";
221
            $major = $xmajor;
222
            $minor = $xminor;
223
            $patch = $xpatch;
224
            $build = $xbuild;
225
            $this_pv_id = $last_pv_id;
226
            $last_pv_id = $PVID{$last_pv_id}{last_pv_id} ;
227
        }
228
        else
229
        {
230
            last;
231
        }
232
    }
233
 
234
    printf( "%1.1s%30s, %20s :: %s",
235
        $suspect ? '*' : ' ',
236
        $PVID{$pvid}{name},
237
        $PVID{$pvid}{version},
238
        "@prev"
239
        );
240
    print "\n";
241
 
242
#    last if ( ++$count > 10 );
243
}
244
 
245
exit;
246
 
247