Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6887 dpurdie 1
########################################################################
2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
3
#
4
# Module name   : rmMerge_process.pl
5
# Module type   : JATS Utility
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   : Compare two releases 
10
#
11
# Usage         : See POD at the end of this file
12
#
13
#......................................................................#
14
 
15
require 5.008_002;
16
use strict;
17
use warnings;
18
 
19
use Pod::Usage;
20
use Getopt::Long;
21
 
22
use JatsError;
23
use JatsRmApi;
24
use JatsSystem;
25
use FileUtils;
26
use ConfigurationFile;
27
use File::Copy;
28
use DBI;
29
my $RM_DB;
30
 
31
my $opt_help=0;
32
my $opt_verbose=0;
33
my $opt_debug=0;
34
my $oldRtagId;
35
my $newRtagId;
36
 
37
my $VERSION = "1.0";
38
my @oldRMCred = ('OLD', 'jdbc:oracle:thin:@auawsards001:1521:RELEASEM', 'RM_READONLY', 'RM_READONLY');
39
my @newRMCred = ('NEW', 'jdbc:oracle:thin:@auawsards002:1521:RELEASEM', 'RM_READONLY', 'Tp8WmmDKMq2Z');
40
 
41
my %oldData;
42
my %newData;
43
 
44
#-------------------------------------------------------------------------------
45
# Function        : Mainline Entry Point
46
#
47
# Description     :
48
#
49
# Inputs          :
50
#
51
my $result = GetOptions (
52
                "help:+"        => \$opt_help,
53
                "manual:3"      => \$opt_help,
54
                "verbose:+"     => \$opt_verbose,
55
                "debug:+"       => \$opt_debug,
56
                "oldRtag:n"     => \$oldRtagId,
57
                "newRtag:n"     => \$newRtagId,
58
                );
59
 
60
                #
61
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
62
                #
63
 
64
#
65
#   Process help and manual options
66
#
67
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
68
pod2usage(-verbose => 1) if ( $opt_help == 2 );
69
pod2usage(-verbose => 2) if ( $opt_help > 2 );
70
#pod2usage(-verbose => 0, -message => "Version: $VERSION") if ( $#ARGV < 0 );
71
 
72
#
73
#   Configure the error reporting rmMerge_process now that we have the user options
74
#
75
ErrorConfig( 'name'    =>'RELCMP',
76
             'verbose' => $opt_verbose,
77
             'debug' => $opt_debug,
78
            );
79
Error("Need to provide two RTAGs") unless $oldRtagId && $newRtagId;
80
 
81
#
82
#   Determine matching Release Names
83
#
84
getReleaseData($oldRtagId, \%oldData, @oldRMCred);
85
getReleaseData($newRtagId, \%newData, @newRMCred);
86
 
87
#DebugDumpData("oldData", \%oldData);
88
#DebugDumpData("newData", \%newData);
89
 
90
#
91
#   Report differences
92
#
93
my %changedVersions;
94
foreach my $pname ( sort keys %oldData) {
95
    foreach my $pver ( sort keys %{$oldData{$pname}}) {
96
        next if exists $newData{$pname} && exists $newData{$pname}{$pver};
97
        next if exists $newData{$pname};
98
        print("Missing in new: $pname $pver\n");
99
    }
100
}
101
 
102
foreach my $pname ( sort keys %newData) {
103
    foreach my $pver ( sort keys %{$newData{$pname}}) {
104
        next if exists $oldData{$pname}{$pver};
105
        next if exists $oldData{$pname};
106
        print("Missing in old: $pname $pver\n");
107
    }
108
}
109
 
110
foreach my $pname ( sort keys %oldData) {
111
    foreach my $pver ( sort keys %{$oldData{$pname}}) {
112
        next if exists $newData{$pname} && exists $newData{$pname}{$pver};
113
        next unless exists $newData{$pname};
114
        my @versions = keys %{$newData{$pname}} ;
115
        printf("Changed: %30.30s %20.20s -> (N) %s\n", $pname, $pver, join(' ', @versions));
116
    }
117
}
118
 
119
 
120
 
121
#-------------------------------------------------------------------------------
122
# Function        : getReleaseData 
123
#
124
# Description     : Get Release Content and related data for a release
125
#
126
# Inputs          : rtagId
127
#                   dataRef
128
#                   RmCredentails 
129
#
130
# Returns         : 
131
#
132
sub getReleaseData
133
{
134
    my ($rtagId, $dataRef, $id, $url, $name, $passwd) = @_;
135
 
136
    my (@row);
137
 
138
    Message ("Extract data for $id: $rtagId");
139
 
140
    $ENV{GBE_RM_LOCATION} = $url;
141
    $ENV{GBE_RM_USERNAME} = $name;
142
    $ENV{GBE_RM_PASSWORD} = $passwd;
143
 
144
    connectRM(\$RM_DB);
145
 
146
    # First get details from pv_id
147
 
148
    my $m_sqlstr = <<"SQL_END";
149
        SELECT
150
            rc.pv_id,
151
            p.pkg_name,
152
            pv.pkg_version
153
        FROM
154
            release_content rc,
155
            package_versions pv,
156
            packages p
157
        WHERE
158
            rc.rtag_id = :rtag_id
159
            AND rc.pv_id = pv.pv_id
160
            AND p.pkg_id = pv.pkg_id
161
SQL_END
162
    $m_sqlstr =~ s~:rtag_id~$rtagId~g;
163
    my $sth = $RM_DB->prepare($m_sqlstr);
164
    if ( defined($sth) )
165
    {
166
        if ( $sth->execute( ) )
167
        {
168
            if ( $sth->rows )
169
            {
170
                while ( @row = $sth->fetchrow_array )
171
                {
172
                    $dataRef->{$row[1]}{$row[2]}{pvid} = $row[0] 
173
                }
174
            }
175
            $sth->finish();
176
        }
177
        else
178
        {
179
            Error("Execute failure: $m_sqlstr", $sth->errstr() );
180
        }
181
    }
182
    else
183
    {
184
        Error("Prepare failure" );
185
    }
186
 
187
    disconnectRM(\$RM_DB);
188
}
189
 
190