| 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 :
|
|
|
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_reuse=1;
|
|
|
32 |
my $opt_help=0;
|
|
|
33 |
my $opt_verbose=0;
|
|
|
34 |
my $opt_debug=0;
|
|
|
35 |
my $opt_order;
|
|
|
36 |
my $opt_type;
|
|
|
37 |
my $opt_noShow = 0;
|
|
|
38 |
my $opt_refresh;
|
|
|
39 |
my $opt_commands;
|
|
|
40 |
my @opt_rtagId;
|
|
|
41 |
my $opt_dependents = 0;
|
|
|
42 |
|
|
|
43 |
our %basePackageVersions;
|
|
|
44 |
our %testPackageTip;
|
|
|
45 |
our %usedBy;
|
|
|
46 |
my %old;
|
|
|
47 |
my %oldPnames;
|
|
|
48 |
my %oldPackages;
|
|
|
49 |
my %newPnames;
|
|
|
50 |
my %new;
|
|
|
51 |
my %essential;
|
|
|
52 |
my %releaseContents;
|
|
|
53 |
my %releaseNames;
|
|
|
54 |
my %pvidLookup;
|
|
|
55 |
my %pvidLookupOld;
|
|
|
56 |
my %pulseImport;
|
|
|
57 |
|
|
|
58 |
my %data;
|
|
|
59 |
my %stats;
|
|
|
60 |
|
|
|
61 |
my $VERSION = "1.0";
|
|
|
62 |
my $SplitPvid = 1150630;
|
|
|
63 |
my @essentialRtags = (34929, 37552, 6884, 37749 );
|
|
|
64 |
my @EMVRtags = (34090,35929,36050,36151,36169,36172,36193,36212,36214,36216,36217,36249,36250,36270,36271,36272,36273,36309,36411,36589,36609,36749,36750,37229,37451,37695);
|
|
|
65 |
|
|
|
66 |
my @essentialRtagsWhisp = (34929, 36551, 6886, 6884, 37229, 37451);
|
|
|
67 |
my @xxxxessentialRtags = (34929, 37452, 37350, 37489, 37411, 37353, 37150, 37090, 36551, 37490, 37329,37369,37431, 37552);
|
|
|
68 |
|
|
|
69 |
@essentialRtags = @EMVRtags;
|
|
|
70 |
Message("Using EMV tags");
|
|
|
71 |
|
|
|
72 |
my @oldEssential = (36969, 36689, 36754,36949,37289, 37230, 37110, 36970, 37030);
|
|
|
73 |
my @oldRMCred = ('OLD', 'jdbc:oracle:thin:@auawsards001:1521:RELEASEM', 'RM_READONLY', 'RM_READONLY');
|
|
|
74 |
my @newRMCred = ('NEW', 'jdbc:oracle:thin:@auawsards002:1521:RELEASEM', 'RM_READONLY', 'Tp8WmmDKMq2Z');
|
|
|
75 |
|
|
|
76 |
my $oldFile = 'old_rm_export.txt';
|
|
|
77 |
my $newFile = 'new_rm_export.txt';
|
|
|
78 |
|
|
|
79 |
my $newVersions = 'essential_pkgs.txt';
|
|
|
80 |
my $versionData = 'version_data.txt';
|
|
|
81 |
my $rtagData = 'rtag_data.txt';
|
|
|
82 |
my $rcData = 'rc_data.txt';
|
|
|
83 |
my $localDataStore = "LocalData.txt";
|
|
|
84 |
|
|
|
85 |
my $dirSame = 'data/same';
|
|
|
86 |
my $dirDiff = 'data/diff';
|
|
|
87 |
my $dirBuildDiff = 'data/build_diff';
|
|
|
88 |
my $dirSkip = 'data/skip';
|
|
|
89 |
my $dirBroken = 'data/broken';
|
|
|
90 |
my $dirWork = 'data/work';
|
|
|
91 |
my $dirLog = 'data/log';
|
|
|
92 |
mkdir ('data');
|
|
|
93 |
mkdir ($dirWork);
|
|
|
94 |
mkdir ($dirLog);
|
|
|
95 |
unlink 'stopfile';
|
|
|
96 |
|
|
|
97 |
#-------------------------------------------------------------------------------
|
|
|
98 |
# Function : Mainline Entry Point
|
|
|
99 |
#
|
|
|
100 |
# Description :
|
|
|
101 |
#
|
|
|
102 |
# Inputs :
|
|
|
103 |
#
|
|
|
104 |
my $result = GetOptions (
|
|
|
105 |
"help:+" => \$opt_help,
|
|
|
106 |
"manual:3" => \$opt_help,
|
|
|
107 |
"verbose:+" => \$opt_verbose,
|
|
|
108 |
"debug:+" => \$opt_debug,
|
|
|
109 |
"reuse!" => \$opt_reuse,
|
|
|
110 |
"order:n" => \$opt_order,
|
|
|
111 |
"rtagid:n" => \@opt_rtagId,
|
|
|
112 |
"type:s" => \$opt_type,
|
|
|
113 |
"refresh!" => \$opt_refresh,
|
|
|
114 |
"commands!" => \$opt_commands,
|
|
|
115 |
"dependents!" => \$opt_dependents,
|
|
|
116 |
);
|
|
|
117 |
|
|
|
118 |
#
|
|
|
119 |
# UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
|
|
|
120 |
#
|
|
|
121 |
|
|
|
122 |
#
|
|
|
123 |
# Process help and manual options
|
|
|
124 |
#
|
|
|
125 |
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
|
|
|
126 |
pod2usage(-verbose => 1) if ( $opt_help == 2 );
|
|
|
127 |
pod2usage(-verbose => 2) if ( $opt_help > 2 );
|
|
|
128 |
#pod2usage(-verbose => 0, -message => "Version: $VERSION") if ( $#ARGV < 0 );
|
|
|
129 |
|
|
|
130 |
#
|
|
|
131 |
# Configure the error reporting rmMerge_process now that we have the user options
|
|
|
132 |
#
|
|
|
133 |
ErrorConfig( 'name' =>'PROC',
|
|
|
134 |
'verbose' => $opt_verbose,
|
|
|
135 |
'debug' => $opt_debug,
|
|
|
136 |
);
|
|
|
137 |
|
|
|
138 |
#
|
|
|
139 |
# Control output
|
|
|
140 |
#
|
|
|
141 |
if ($opt_order || $opt_type || $opt_commands) {
|
|
|
142 |
$opt_noShow = 1;
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
# User the user provided list of rtags
|
|
|
146 |
#
|
|
|
147 |
if (@opt_rtagId){
|
|
|
148 |
@essentialRtags = @opt_rtagId;
|
|
|
149 |
my $prefix = join('-', sort @essentialRtags);
|
|
|
150 |
|
|
|
151 |
$newVersions = join('-',$prefix,$newVersions);
|
|
|
152 |
$versionData = join('-',$prefix,$versionData);
|
|
|
153 |
$rtagData = join('-',$prefix,$rtagData );
|
|
|
154 |
$rcData = join('-',$prefix,$rcData );
|
|
|
155 |
}
|
|
|
156 |
Message ("Process for: @essentialRtags");
|
|
|
157 |
|
|
|
158 |
#
|
|
|
159 |
# Extract data from the database
|
|
|
160 |
# Save to text files so that it can be reused
|
|
|
161 |
#
|
|
|
162 |
unless ($opt_reuse) {
|
|
|
163 |
GetEssentialVersions( $newVersions, @newRMCred);
|
|
|
164 |
#GetDataFromRM ($oldFile, 0, @oldRMCred );
|
|
|
165 |
#GetDataFromRM ($newFile, 0, @newRMCred );
|
|
|
166 |
GetRtagData($rtagData,@newRMCred);
|
|
|
167 |
GetReleaseContents($rcData,@newRMCred);
|
|
|
168 |
SuckReleaseContents();
|
|
|
169 |
#unlink $localDataStore;
|
|
|
170 |
} else {
|
|
|
171 |
Message ("Reuse old data");
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
if ($opt_refresh) {
|
|
|
175 |
GetDataFromRM ($oldFile, 0, @oldRMCred );
|
|
|
176 |
GetDataFromRM ($newFile, 0, @newRMCred );
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
|
|
|
180 |
#
|
|
|
181 |
# Read in the database info from the text files
|
|
|
182 |
# These must have been created from the database
|
|
|
183 |
#
|
|
|
184 |
# $old. Hash of {$pname.$proj}{version} -> pvid(old),vcsPath
|
|
|
185 |
#
|
|
|
186 |
open (FH, '<', $oldFile) || Error("Cannot open $oldFile");
|
|
|
187 |
while (<FH>) {
|
|
|
188 |
my ($pvid, $pname, $pver, $vcs, $idext) = split(/\s+/,$_);
|
|
|
189 |
$pver =~ m~(.*)\.(.*)$~;
|
|
|
190 |
my $proj = $2;
|
|
|
191 |
$pver = $1;
|
|
|
192 |
# next unless $pver =~ m~000$~;
|
|
|
193 |
|
|
|
194 |
$pver = 'NoVersion' unless defined $pver;
|
|
|
195 |
$proj = 'noProj' unless defined $proj;
|
|
|
196 |
|
|
|
197 |
my $key = $pname . '.' . $proj;
|
|
|
198 |
$old{$key}{$pver} = join($;,$pvid, $vcs, $pname, $proj, $idext);
|
|
|
199 |
$oldPnames{$key} = 1;
|
|
|
200 |
$oldPackages{$pname} = 1;
|
|
|
201 |
$pvidLookupOld{$pvid} = join($;, $key, $pname, $pver, $proj);
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
# Capture PulseImport tags
|
|
|
205 |
# Handle:
|
|
|
206 |
# PulseImport
|
|
|
207 |
# PulseImport.Branch.<BranchName>
|
|
|
208 |
if ($idext =~ m/PulseImport/){
|
|
|
209 |
if ( !exists($pulseImport{$key}) || $pvid > $pulseImport{$key}{pvid} ) {
|
|
|
210 |
delete $pulseImport{$key};
|
|
|
211 |
$pulseImport{$key}{pvid} = $pvid;
|
|
|
212 |
if ($idext =~ m~PulseImport\.Branch\.(.*)~) {
|
|
|
213 |
$pulseImport{$key}{branchName} = $1;
|
|
|
214 |
}
|
|
|
215 |
}
|
|
|
216 |
}
|
|
|
217 |
}
|
|
|
218 |
#
|
|
|
219 |
# $new. Hash of {$pname.$proj}{version} -> pvid(new),vcsPath
|
|
|
220 |
#
|
|
|
221 |
open (FH, '<', $newFile) || Error("Cannot open $newFile");
|
|
|
222 |
while (<FH>) {
|
|
|
223 |
my ($pvid, $pname, $pver, $vcs, $idext) = split(/\s+/,$_);
|
|
|
224 |
$pver =~ m~(.*)\.(.*)$~;
|
|
|
225 |
my $proj = $2;
|
|
|
226 |
$pver = $1;
|
|
|
227 |
# next unless $pver =~ m~000$~;
|
|
|
228 |
|
|
|
229 |
$pver = 'NoVersion' unless defined $pver;
|
|
|
230 |
$proj = 'noProj' unless defined $proj;
|
|
|
231 |
|
|
|
232 |
my $key = $pname . '.' . $proj;
|
|
|
233 |
$new{$key}{$pver} = join($;,$pvid, $vcs, $pname, $proj, $idext);
|
|
|
234 |
$newPnames{$key} = 1;
|
|
|
235 |
$pvidLookup{$pvid} = join($;, $key, $pname, $pver, $proj);
|
|
|
236 |
|
|
|
237 |
}
|
|
|
238 |
#DebugDumpData("OLD", \%old);
|
|
|
239 |
#DebugDumpData("NEW", \%new);
|
|
|
240 |
#
|
|
|
241 |
#
|
|
|
242 |
# Import essential package data
|
|
|
243 |
# A hash of pvid(new) -> dependencies
|
|
|
244 |
# Need to handle those that don't have a dependency
|
|
|
245 |
#
|
|
|
246 |
open (FH, '<', $newVersions) || Error("Cannot open $newVersions");
|
|
|
247 |
while (<FH>) {
|
|
|
248 |
chomp;
|
|
|
249 |
my ($pvid, $dpvid) = split(/\s+/,$_);
|
|
|
250 |
$essential{$pvid} = {} unless exists $essential{$pvid};
|
|
|
251 |
if (defined $dpvid) {
|
|
|
252 |
$essential{$pvid}{$dpvid}=1;
|
|
|
253 |
}
|
|
|
254 |
}
|
|
|
255 |
|
|
|
256 |
#
|
|
|
257 |
# Import Release Content Data
|
|
|
258 |
# pvid(new) --> rtagId(new) with mode. Mode == 1 direct, Mode ==2 indirect
|
|
|
259 |
#
|
|
|
260 |
open (FH, '<', $rcData) || Error("Cannot open $rcData");
|
|
|
261 |
while (<FH>) {
|
|
|
262 |
chomp;
|
|
|
263 |
my ($pvid, $rtagId, $mode) = split(/\s+/,$_);
|
|
|
264 |
$releaseContents{$pvid}{$rtagId}=$mode
|
|
|
265 |
}
|
|
|
266 |
|
|
|
267 |
#
|
|
|
268 |
# Import Release Names
|
|
|
269 |
# rtagId(new) --> name
|
|
|
270 |
#
|
|
|
271 |
open (FH, '<', $rtagData) || Error("Cannot open $rtagData");
|
|
|
272 |
while (<FH>) {
|
|
|
273 |
chomp;
|
|
|
274 |
my ($rtagId, $name) = split(/\s+/,$_,2);
|
|
|
275 |
$releaseNames{$rtagId}= $name
|
|
|
276 |
}
|
|
|
277 |
|
|
|
278 |
restoreLocalData();
|
|
|
279 |
procData();
|
|
|
280 |
saveLocalData();
|
|
|
281 |
|
|
|
282 |
#-------------------------------------------------------------------------------
|
|
|
283 |
# Function : SuckReleaseContents
|
|
|
284 |
#
|
|
|
285 |
# Description :
|
|
|
286 |
#
|
|
|
287 |
# Inputs :
|
|
|
288 |
#
|
|
|
289 |
# Returns :
|
|
|
290 |
sub SuckReleaseContents
|
|
|
291 |
{
|
|
|
292 |
foreach my $rtag ( @essentialRtags) {
|
|
|
293 |
Message ("Serialise Release - $rtag");
|
|
|
294 |
JatsCmd ('eprog', 'rmMerge_suckRelease.pl','-rtag', $rtag);
|
|
|
295 |
}
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
#-------------------------------------------------------------------------------
|
|
|
299 |
# Function : procData
|
|
|
300 |
#
|
|
|
301 |
# Description : rmMerge_process the collected data
|
|
|
302 |
#
|
|
|
303 |
# Inputs :
|
|
|
304 |
#
|
|
|
305 |
# Returns :
|
|
|
306 |
#
|
|
|
307 |
sub procData
|
|
|
308 |
{
|
|
|
309 |
Message("Process Data");
|
|
|
310 |
|
|
|
311 |
foreach my $pvid ( keys %essential) {
|
|
|
312 |
Warning("No data in pvidLookup for $pvid") unless exists $pvidLookup{$pvid};
|
|
|
313 |
}
|
|
|
314 |
|
|
|
315 |
foreach my $pvid ( sort {uc $pvidLookup{$a} cmp uc $pvidLookup{$b}} keys %essential) {
|
|
|
316 |
|
|
|
317 |
next unless exists $releaseContents{$pvid};
|
|
|
318 |
|
|
|
319 |
#
|
|
|
320 |
# Examine this package
|
|
|
321 |
#
|
|
|
322 |
my ($key,$pname, $pver, $proj) = split($;, $pvidLookup{$pvid});
|
|
|
323 |
$data{$key}{$pver}{pvid} = $pvid;
|
|
|
324 |
$data{$key}{$pver}{proj} = $proj;
|
|
|
325 |
$data{$key}{$pver}{txt} = "$pname $pver.$proj";
|
|
|
326 |
$data{$key}{$pver}{ver} = "$pver.$proj";
|
|
|
327 |
$stats{"Total Packages"} ++;
|
|
|
328 |
|
|
|
329 |
#
|
|
|
330 |
# If the packageName.Proj does not exist in the old then its a simple transfer
|
|
|
331 |
#
|
|
|
332 |
if ( ! exists $releaseContents{$pvid} ) {
|
|
|
333 |
$data{$key}{$pver}{state} = 'U'; # Not essential
|
|
|
334 |
$stats{"Not Essential"}++;
|
|
|
335 |
}
|
|
|
336 |
elsif ( ! exists ($oldPackages{$pname}) ) {
|
|
|
337 |
$data{$key}{$pver}{state} = 'N'; # New package
|
|
|
338 |
$stats{"New Package"} ++;
|
|
|
339 |
|
|
|
340 |
} elsif (! exists $old{$key}) {
|
|
|
341 |
$data{$key}{$pver}{state} = 'n'; # New Project in an existing package
|
|
|
342 |
$stats{"New Project"} ++;
|
|
|
343 |
|
|
|
344 |
} elsif ($pvid < $SplitPvid ) {
|
|
|
345 |
#
|
|
|
346 |
# PV is a pre-split version no work to be done
|
|
|
347 |
#
|
|
|
348 |
$data{$key}{$pver}{state} = 'P'; # Pre Clone version
|
|
|
349 |
$stats{"Pre Clone"} ++;
|
|
|
350 |
|
|
|
351 |
} elsif (! exists $old{$key}{$pver}) {
|
|
|
352 |
#
|
|
|
353 |
# If the packageName.Proj does exist, but the version does not then
|
|
|
354 |
# is a mostly simple transfer
|
|
|
355 |
#
|
|
|
356 |
$data{$key}{$pver}{state} = 'S'; # Not a clash
|
|
|
357 |
$stats{"No Clash"} ++;
|
|
|
358 |
|
|
|
359 |
} else {
|
|
|
360 |
testPackage($key, $pver);
|
|
|
361 |
$data{$key}{$pver}{state} = getState($key, $pver);
|
|
|
362 |
$stats{"Total Clashes"} ++;
|
|
|
363 |
$stats{"ClashMode-" . getState($key, $pver)}++;
|
|
|
364 |
}
|
|
|
365 |
}
|
|
|
366 |
|
|
|
367 |
unless ($opt_noShow) {
|
|
|
368 |
print("Packages to Merge\n");
|
|
|
369 |
print("Keys: N: New Package, n:New Project, P:PreClone, S:No Clash, D:Diff, d: Build Diff, G:Identical in both, K:Skip Diff, U:unessential\n");
|
|
|
370 |
foreach my $pname ( sort keys %data){
|
|
|
371 |
foreach my $pver ( sort keys %{$data{$pname}}) {
|
|
|
372 |
print(" ",$data{$pname}{$pver}{state}, ' ' ,$data{$pname}{$pver}{txt}, "\n");
|
|
|
373 |
}
|
|
|
374 |
}
|
|
|
375 |
}
|
|
|
376 |
|
|
|
377 |
|
|
|
378 |
#DebugDumpData("Data", \%data);
|
|
|
379 |
DebugDumpData("Stats", \%stats) unless ($opt_noShow);
|
|
|
380 |
|
|
|
381 |
print("Clashes to resolve\n");
|
|
|
382 |
foreach my $pname ( sort keys %data){
|
|
|
383 |
foreach my $pver ( sort keys %{$data{$pname}}) {
|
|
|
384 |
next unless ($data{$pname}{$pver}{state} =~ m/[dD]/ );
|
|
|
385 |
my ($oldPvid, $oldVcs, $oldPname, $oldProj) = split($;, $old{$pname}{$pver} );
|
|
|
386 |
my $newPvid = $data{$pname}{$pver}{pvid};
|
|
|
387 |
|
|
|
388 |
print(" ",$data{$pname}{$pver}{state}, " $pname, $pver (N:$newPvid, O:$oldPvid)\n");
|
|
|
389 |
foreach my $rtagId (keys %{$releaseContents{$newPvid}} ) {
|
|
|
390 |
my $mode = $releaseContents{$newPvid}{$rtagId} > 1 ? " [indirectly]": "";
|
|
|
391 |
print(" Used by: $rtagId, $releaseNames{$rtagId}$mode\n");
|
|
|
392 |
}
|
|
|
393 |
|
|
|
394 |
if (my $usageData = GetUsedProjects($oldPvid,@oldRMCred)) {
|
|
|
395 |
foreach my $entry ( @$usageData) {
|
|
|
396 |
print(" Used by Old Release: $entry->[2], $entry->[1] - $entry->[3]\n");
|
|
|
397 |
}
|
|
|
398 |
}
|
|
|
399 |
|
|
|
400 |
if (my $usageData = GetUsedSdks($oldPvid,@oldRMCred)) {
|
|
|
401 |
foreach my $entry ( @$usageData) {
|
|
|
402 |
print(" Used by Old SDK: $entry->[2], $entry->[1] - $entry->[3]\n");
|
|
|
403 |
}
|
|
|
404 |
}
|
|
|
405 |
|
|
|
406 |
if (my $usageData = GetUsedSboms($oldPvid,@oldRMCred)) {
|
|
|
407 |
foreach my $entry ( @$usageData) {
|
|
|
408 |
print(" Used by Old SBOM: $entry->[2], $entry->[1] - $entry->[3]\n");
|
|
|
409 |
}
|
|
|
410 |
}
|
|
|
411 |
|
|
|
412 |
}
|
|
|
413 |
}
|
|
|
414 |
|
|
|
415 |
#
|
|
|
416 |
# Examine packages that do exist in the old system to determine if they can be
|
|
|
417 |
# merged to the SVN tip in the old system
|
|
|
418 |
#
|
|
|
419 |
# Only need to rmMerge_process those package-versions that do not clash (S)
|
|
|
420 |
# New 'projects' (n) may need to be branched
|
|
|
421 |
#
|
|
|
422 |
Verbose("Determine SVN branch needs\n");
|
|
|
423 |
foreach my $pname ( sort keys %data){
|
|
|
424 |
foreach my $pver ( sort keys %{$data{$pname}}) {
|
|
|
425 |
if ($data{$pname}{$pver}{state} eq 'n' ) {
|
|
|
426 |
$data{$pname}{$pver}{bstate} = 'F';
|
|
|
427 |
$data{$pname}{$pver}{numChanges} = 0;
|
|
|
428 |
next;
|
|
|
429 |
}
|
|
|
430 |
next unless ($data{$pname}{$pver}{state} =~ m/[S]/ );
|
|
|
431 |
Verbose("Examine ($data{$pname}{$pver}{state}) $pname, $pver");
|
|
|
432 |
my $bstate = '-';
|
|
|
433 |
my $numChanges = 0;
|
|
|
434 |
if ($numChanges = testPackageChanges($pname,$pver) ) {
|
|
|
435 |
$bstate = testPackageTip($pname,$pver);
|
|
|
436 |
}
|
|
|
437 |
$data{$pname}{$pver}{bstate} = $bstate;
|
|
|
438 |
$data{$pname}{$pver}{numChanges} = $numChanges;
|
|
|
439 |
|
|
|
440 |
$data{$pname}{$pver}{branchVersion} = getBranchVersion($pname, $pver);
|
|
|
441 |
}
|
|
|
442 |
}
|
|
|
443 |
|
|
|
444 |
unless ($opt_noShow) {
|
|
|
445 |
print("SVN branching\n");
|
|
|
446 |
print("Key. Col1: N: New Package, n:New Project, P:PreClone, S:No Clash, D:Diff, d: Build Diff, G:Identical in both, K:Skip Diff\n");
|
|
|
447 |
print("Key. Col2 -: No Changes to old Repo, S:Tip Identical, D:Tip Diff, d: Tip Build Diff, F:Force Branch\n");
|
|
|
448 |
print("Those marked as 'D' will need to be branched\n");
|
|
|
449 |
my $branchCount = 0;
|
|
|
450 |
foreach my $pname ( sort {uc $a cmp uc $b } keys %data){
|
|
|
451 |
foreach my $pver ( sort {$data{$pname}{$a} cmp $data{$pname}{$b} } keys %{$data{$pname}}) {
|
|
|
452 |
next unless (exists $data{$pname}{$pver}{bstate} );
|
|
|
453 |
printf( " %s%s %3.3s %s %s\n",$data{$pname}{$pver}{state},$data{$pname}{$pver}{bstate}, $data{$pname}{$pver}{numChanges} , $pname, $pver);
|
|
|
454 |
$branchCount++ if $data{$pname}{$pver}{bstate} =~ m/[DF]/;
|
|
|
455 |
}
|
|
|
456 |
}
|
|
|
457 |
print("Number of branches: $branchCount\n");
|
|
|
458 |
}
|
|
|
459 |
|
|
|
460 |
###########################################################################
|
|
|
461 |
# Determine the rmMerge_processing order
|
|
|
462 |
# Test essential data
|
|
|
463 |
#
|
|
|
464 |
foreach my $pvid ( keys %essential) {
|
|
|
465 |
unless (exists $pvidLookup{$pvid} ) {
|
|
|
466 |
ReportError ("PVID not in lookup: $pvid");
|
|
|
467 |
}
|
|
|
468 |
}
|
|
|
469 |
ErrorDoExit();
|
|
|
470 |
my %depOrder;
|
|
|
471 |
my $order=0;
|
|
|
472 |
my %depData;
|
|
|
473 |
|
|
|
474 |
foreach my $pvid ( keys %essential) {
|
|
|
475 |
$depData{$pvid} = {};
|
|
|
476 |
foreach my $dpvid ( keys %{$essential{$pvid}}) {
|
|
|
477 |
$depData{$pvid}{$dpvid} = 1;
|
|
|
478 |
}
|
|
|
479 |
}
|
|
|
480 |
|
|
|
481 |
#
|
|
|
482 |
# Cleanup
|
|
|
483 |
# Also delete those where we know the package has been transferred to the old Repo already
|
|
|
484 |
#
|
|
|
485 |
foreach my $key ( sort keys %data){
|
|
|
486 |
foreach my $pver ( sort keys %{$data{$key}}) {
|
|
|
487 |
next unless ( exists ($data{$key}{$pver}{state}));
|
|
|
488 |
#next unless ( exists ($data{$key}{$pver}{bstate}));
|
|
|
489 |
#next unless ($data{$key}{$pver}{bstate} =~ m~-~);
|
|
|
490 |
next unless ($data{$key}{$pver}{state} =~ m~[PGK]~);
|
|
|
491 |
delete $depData{$data{$key}{$pver}{pvid}} ;
|
|
|
492 |
}
|
|
|
493 |
}
|
|
|
494 |
|
|
|
495 |
#
|
|
|
496 |
# First pass - remove dependencies that don't exists in the set
|
|
|
497 |
# Hopefully these have already been rmMerge_processed
|
|
|
498 |
#
|
|
|
499 |
foreach my $pvid ( keys %depData) {
|
|
|
500 |
foreach my $dpvid ( keys %{$depData{$pvid}} ) {
|
|
|
501 |
delete $depData{$pvid}{$dpvid} unless exists( $depData{$dpvid});
|
|
|
502 |
}
|
|
|
503 |
}
|
|
|
504 |
|
|
|
505 |
while (1) {
|
|
|
506 |
$order++;
|
|
|
507 |
my @found;
|
|
|
508 |
last unless scalar keys %depData;
|
|
|
509 |
|
|
|
510 |
# locate items that have no dependencies
|
|
|
511 |
foreach my $pvid ( keys %depData) {
|
|
|
512 |
my @deps = keys %{$depData{$pvid}};
|
|
|
513 |
unless (@deps) {
|
|
|
514 |
$depOrder{$pvid} = $order;
|
|
|
515 |
push @found, $pvid;
|
|
|
516 |
delete $depData{$pvid};
|
|
|
517 |
if (exists $pvidLookup{$pvid} ) {
|
|
|
518 |
my ($key,$pname, $pver, $proj) = split($;, $pvidLookup{$pvid});
|
|
|
519 |
if (exists ($data{$key}) && exists ($data{$key}{$pver})) {
|
|
|
520 |
$data{$key}{$pver}{order} = $order;
|
|
|
521 |
}
|
|
|
522 |
}
|
|
|
523 |
}
|
|
|
524 |
}
|
|
|
525 |
|
|
|
526 |
# Remove those items that have been rmMerge_processed
|
|
|
527 |
foreach my $pvid (keys %depData) {
|
|
|
528 |
foreach my $dpvid ( @found) {
|
|
|
529 |
delete $depData{$pvid}{$dpvid};
|
|
|
530 |
}
|
|
|
531 |
}
|
|
|
532 |
}
|
|
|
533 |
|
|
|
534 |
#
|
|
|
535 |
# Print summary of what we have discovered
|
|
|
536 |
#
|
|
|
537 |
my $pkgCount = 0;
|
|
|
538 |
my @commands;
|
|
|
539 |
print("Packages to Merge\n");
|
|
|
540 |
print("Col1 - Keys: N: New Package, -:New Project, P:PreClone, S:No Clash, D:Diff, d: Build Diff, G:Identical in both, K:Skip Diff\n");
|
|
|
541 |
print("Col2 - Keys -: No Changes to old Repo, S:Tip Identical, D:Tip Diff, d: Tip Build Diff, F: Force Branch\n");
|
|
|
542 |
print("Col3 - Increment Code\n");
|
|
|
543 |
print("Col4 - Increment type\n");
|
|
|
544 |
print("Col5 - Increment warning\n");
|
|
|
545 |
print("Col6 - Insertion Order\n");
|
|
|
546 |
print("Col7 - Number of changes in oldRm since split\n");
|
|
|
547 |
print("Col8 - Package Name and Version\n");
|
|
|
548 |
foreach my $pname ( sort { uc $a cmp uc $b } keys %data){
|
|
|
549 |
foreach my $pver ( sort {uc $a cmp uc $b} keys %{$data{$pname}}) {
|
|
|
550 |
|
|
|
551 |
#
|
|
|
552 |
# If filtering the order
|
|
|
553 |
#
|
|
|
554 |
if ($opt_order) {
|
|
|
555 |
next unless exists $data{$pname}{$pver}{order};
|
|
|
556 |
next unless (($data{$pname}{$pver}{order} <= $opt_order) || ($data{$pname}{$pver}{order} == -$opt_order));
|
|
|
557 |
}
|
|
|
558 |
|
|
|
559 |
if ($opt_type) {
|
|
|
560 |
next unless ($data{$pname}{$pver}{proj} eq $opt_type);
|
|
|
561 |
}
|
|
|
562 |
|
|
|
563 |
if ($opt_commands) {
|
|
|
564 |
if (exists $data{$pname}{$pver}{order}){
|
|
|
565 |
push @commands, join($;, $data{$pname}{$pver}{order}, $data{$pname}{$pver}{txt} );
|
|
|
566 |
}
|
|
|
567 |
}
|
|
|
568 |
|
|
|
569 |
$pkgCount++;
|
|
|
570 |
|
|
|
571 |
#
|
|
|
572 |
# Determine branch point information
|
|
|
573 |
# Display old version and branch name
|
|
|
574 |
#
|
|
|
575 |
my $bpText = "";
|
|
|
576 |
my $it = "";
|
|
|
577 |
if (exists($pulseImport{$pname})) {
|
|
|
578 |
my ($okey,$opname, $opver, $oproj) = split($;, $pvidLookupOld{$pulseImport{$pname}{pvid}});
|
|
|
579 |
$bpText = "$opver.$oproj ($pulseImport{$pname}{pvid})";
|
|
|
580 |
|
|
|
581 |
if (exists($pulseImport{$pname}{branchName})) {
|
|
|
582 |
$bpText .= " Branch:" . $pulseImport{$pname}{branchName};
|
|
|
583 |
}
|
|
|
584 |
|
|
|
585 |
my ($itype, $icode) = isVersionGreater($data{$pname}{$pver}{ver}, "$opver.$oproj");
|
|
|
586 |
$it = $icode . $itype;
|
|
|
587 |
if ($itype == 2 || $itype == 0) {
|
|
|
588 |
$it .= '?';
|
|
|
589 |
$stats{Warnings}++;
|
|
|
590 |
}
|
|
|
591 |
}
|
|
|
592 |
|
|
|
593 |
|
|
|
594 |
printf(" %s%s %-3.3s %3.3s %3.3s %s , %s , %s\n",
|
|
|
595 |
$data{$pname}{$pver}{state},
|
|
|
596 |
$data{$pname}{$pver}{bstate} || ' ',
|
|
|
597 |
$it || ' ',
|
|
|
598 |
$data{$pname}{$pver}{order} || 'x',
|
|
|
599 |
$data{$pname}{$pver}{numChanges} || ' ' ,
|
|
|
600 |
$data{$pname}{$pver}{txt},
|
|
|
601 |
$data{$pname}{$pver}{branchVersion} || '',
|
|
|
602 |
$bpText
|
|
|
603 |
);
|
|
|
604 |
}
|
|
|
605 |
}
|
|
|
606 |
print("Packages displayed: $pkgCount\n");
|
|
|
607 |
|
|
|
608 |
if ($opt_commands) {
|
|
|
609 |
my $lastSort = '';
|
|
|
610 |
foreach ( sort @commands) {
|
|
|
611 |
my ($order, $text) = split($;, $_);
|
|
|
612 |
if ($order ne $lastSort){
|
|
|
613 |
$lastSort = $order;
|
|
|
614 |
print("# Order: $order\n");
|
|
|
615 |
}
|
|
|
616 |
print("jats eprog rmMerge_migrate_package.pl $text\n");
|
|
|
617 |
}
|
|
|
618 |
}
|
|
|
619 |
|
|
|
620 |
DebugDumpData("Stats", \%stats);
|
|
|
621 |
#DebugDumpData("Data", \%data);
|
|
|
622 |
#DebugDumpData("Essentials", \%essential);
|
|
|
623 |
#DebugDumpData("depOrder", \%depOrder);
|
|
|
624 |
|
|
|
625 |
|
|
|
626 |
}
|
|
|
627 |
|
|
|
628 |
#-------------------------------------------------------------------------------
|
|
|
629 |
# Function : testPackageChanges
|
|
|
630 |
#
|
|
|
631 |
# Description : See if there have been any changes to a package in the OLD
|
|
|
632 |
# RM since the clone
|
|
|
633 |
#
|
|
|
634 |
# Inputs : $key (pname + proj)
|
|
|
635 |
# $pver - version to test
|
|
|
636 |
#
|
|
|
637 |
# Returns : Number of versions in the old RM created since the split
|
|
|
638 |
#
|
|
|
639 |
sub testPackageChanges
|
|
|
640 |
{
|
|
|
641 |
my ($key,$pver) = @_;
|
|
|
642 |
my $found =0;
|
|
|
643 |
|
|
|
644 |
foreach my $pver ( keys %{$old{$key}}) {
|
|
|
645 |
my ($oldPvid, $oldVcs, $oldPname, $oldProj) = split($;, $old{$key}{$pver} );
|
|
|
646 |
if ($oldPvid > $SplitPvid) {
|
|
|
647 |
$found ++;
|
|
|
648 |
}
|
|
|
649 |
}
|
|
|
650 |
return $found;
|
|
|
651 |
}
|
|
|
652 |
|
|
|
653 |
#-------------------------------------------------------------------------------
|
|
|
654 |
# Function : getBranchVersion
|
|
|
655 |
#
|
|
|
656 |
# Description : Determine the package-version in the old Release Manager that would
|
|
|
657 |
# be a suitable branch point for this package-version
|
|
|
658 |
#
|
|
|
659 |
# Assume:
|
|
|
660 |
# For a given packageName/Extension determine the highest PVID before the split
|
|
|
661 |
#
|
|
|
662 |
# Inputs : $key (pname + proj)
|
|
|
663 |
# $pver - version to test
|
|
|
664 |
#
|
|
|
665 |
# Returns : The package version in the old RM
|
|
|
666 |
#
|
|
|
667 |
sub getBranchVersion
|
|
|
668 |
{
|
|
|
669 |
my ($key,$pver) = @_;
|
|
|
670 |
my $maxPvid = 0;
|
|
|
671 |
my $maxPver;
|
|
|
672 |
|
|
|
673 |
foreach my $pver ( keys %{$old{$key}}) {
|
|
|
674 |
my ($oldPvid, $oldVcs, $oldPname, $oldProj) = split($;, $old{$key}{$pver} );
|
|
|
675 |
if ($oldPvid <= $SplitPvid) {
|
|
|
676 |
if ($oldPvid > $maxPvid) {
|
|
|
677 |
$maxPvid = $oldPvid;
|
|
|
678 |
$maxPver = $pver;
|
|
|
679 |
}
|
|
|
680 |
}
|
|
|
681 |
}
|
|
|
682 |
return $maxPver;
|
|
|
683 |
}
|
|
|
684 |
|
|
|
685 |
#-------------------------------------------------------------------------------
|
|
|
686 |
# Function : testPackageTip
|
|
|
687 |
#
|
|
|
688 |
# Description : Test a new packageVersion against the tip of the same package
|
|
|
689 |
# in the old Repo. If there are only build file changes, then
|
|
|
690 |
# its a simple merge.
|
|
|
691 |
#
|
|
|
692 |
# Inputs : $key (pname + proj)
|
|
|
693 |
# $pver - version to test
|
|
|
694 |
#
|
|
|
695 |
# Returns : Diff Mode
|
|
|
696 |
# 'D' - Code diff
|
|
|
697 |
# 'd' - Build Diff
|
|
|
698 |
# 'S' - Same
|
|
|
699 |
# '?' - Error
|
|
|
700 |
#
|
|
|
701 |
sub testPackageTip
|
|
|
702 |
{
|
|
|
703 |
my ($key,$pver) = @_;
|
|
|
704 |
my $rCode = "?";
|
|
|
705 |
|
|
|
706 |
if (-f 'stopfile') {
|
|
|
707 |
Error('StopFile detected');
|
|
|
708 |
}
|
|
|
709 |
|
|
|
710 |
if (exists $testPackageTip{$key}{$pver}) {
|
|
|
711 |
return $testPackageTip{$key}{$pver};
|
|
|
712 |
}
|
|
|
713 |
|
|
|
714 |
my ($newPvid, $newVcs, $newPname, $newProj) = split($;, $new{$key}{$pver} );
|
|
|
715 |
|
|
|
716 |
#
|
|
|
717 |
# Need to massage the newVcs to extract the tip of the package in the old system
|
|
|
718 |
#
|
|
|
719 |
my $oldVcs = $newVcs;
|
|
|
720 |
$oldVcs =~ s~AUPERASVN02~AUPERASVN01~;
|
|
|
721 |
$oldVcs =~ m~(.*)::~;
|
|
|
722 |
$oldVcs = $1;
|
|
|
723 |
|
|
|
724 |
my $pname = $key;
|
|
|
725 |
my $version= $pver;
|
|
|
726 |
|
|
|
727 |
print("Extract $pname $version, $oldVcs, $newVcs\n");
|
|
|
728 |
my $oldName = join('_', $pname, $version, 'oldTip');
|
|
|
729 |
my $newName = join('_', $pname, $version, 'new');
|
|
|
730 |
my $diffLog = join('_', $pname, $version, 'tipDiff.txt');
|
|
|
731 |
my $buildDiffLog = join('_', $pname, $version, 'BuildTipDiff.txt');
|
|
|
732 |
|
|
|
733 |
my $oldView = catdir($dirWork,$oldName );
|
|
|
734 |
my $newView = catdir($dirWork,$newName );
|
|
|
735 |
|
|
|
736 |
my $diffLogPath = catfile($dirLog, $diffLog);
|
|
|
737 |
my $buildDiffLogPath = catfile($dirLog, $buildDiffLog);
|
|
|
738 |
|
|
|
739 |
|
|
|
740 |
|
|
|
741 |
JatsCmd('-logfile', catfile($dirLog, $oldName.'.log'),'jats_vcsrelease.pl', '-extractfiles', '-noprefix', '-root',$dirWork, '-view', $oldName ,'-label', $oldVcs );
|
|
|
742 |
JatsCmd('-logfile', catfile($dirLog, $newName.'.log'),'jats_vcsrelease.pl', '-extractfiles', '-noprefix', '-root',$dirWork, '-view', $newName ,'-label', $newVcs );
|
|
|
743 |
my $rv = System('--Shell','diff', '-rq', $oldView, $newView, "1>$diffLogPath");
|
|
|
744 |
print("TipDiff [$diffLog]: $rv\n");
|
|
|
745 |
if ($rv == 0) {
|
|
|
746 |
$rCode = "S";
|
|
|
747 |
} elsif ($rv == 1) {
|
|
|
748 |
my $rv = System('--Shell','diff', '-rq', '--exclude=build.pl', $oldView, $newView, "1>$buildDiffLogPath");
|
|
|
749 |
print("TipBuildDiff [$buildDiffLog]: $rv\n");
|
|
|
750 |
if ($rv == 0) {
|
|
|
751 |
$rCode = 'd';
|
|
|
752 |
} else {
|
|
|
753 |
$rCode = 'D';
|
|
|
754 |
}
|
|
|
755 |
}
|
|
|
756 |
RmDirTree($oldView);
|
|
|
757 |
RmDirTree($newView);
|
|
|
758 |
|
|
|
759 |
$testPackageTip{$key}{$pver} = $rCode;
|
|
|
760 |
saveLocalData();
|
|
|
761 |
return $rCode;
|
|
|
762 |
}
|
|
|
763 |
|
|
|
764 |
|
|
|
765 |
#-------------------------------------------------------------------------------
|
|
|
766 |
# Function : testPackage
|
|
|
767 |
#
|
|
|
768 |
# Description : Test a package to see how different it is between the two
|
|
|
769 |
# repositories
|
|
|
770 |
#
|
|
|
771 |
# Inputs : $key (pname + proj)
|
|
|
772 |
# $pver - version to test
|
|
|
773 |
#
|
|
|
774 |
# Returns :
|
|
|
775 |
#
|
|
|
776 |
sub testPackage
|
|
|
777 |
{
|
|
|
778 |
my ($key, $pver) = @_;
|
|
|
779 |
|
|
|
780 |
if (-f 'stopfile') {
|
|
|
781 |
Error('StopFile detected');
|
|
|
782 |
}
|
|
|
783 |
|
|
|
784 |
my ($newPvid, $newVcs, $newPname, $newProj) = split($;, $new{$key}{$pver} );
|
|
|
785 |
my ($oldPvid, $oldVcs, $oldPname, $oldProj) = split($;, $old{$key}{$pver} );
|
|
|
786 |
|
|
|
787 |
testPackagesCore($key,$pver,$oldVcs, $newVcs);
|
|
|
788 |
}
|
|
|
789 |
|
|
|
790 |
|
|
|
791 |
#-------------------------------------------------------------------------------
|
|
|
792 |
# Function : testPackagesCore
|
|
|
793 |
#
|
|
|
794 |
# Description : Core of the package testing rmMerge_process
|
|
|
795 |
#
|
|
|
796 |
# Inputs : $pname
|
|
|
797 |
# $pver
|
|
|
798 |
# $oldvcs
|
|
|
799 |
# $newvcs
|
|
|
800 |
#
|
|
|
801 |
# Returns :
|
|
|
802 |
#
|
|
|
803 |
|
|
|
804 |
sub testPackagesCore
|
|
|
805 |
{
|
|
|
806 |
my ($pname, $version, $oldvcs, $newvcs ) = @_;
|
|
|
807 |
if (isSame($pname, $version) || isDiff($pname, $version) || isBuildDiff($pname, $version) || isSkip($pname, $version) || isBroken($pname, $version))
|
|
|
808 |
{
|
|
|
809 |
Verbose ("Skipping: $pname, $version : " . getState($pname,$version));
|
|
|
810 |
return;
|
|
|
811 |
}
|
|
|
812 |
|
|
|
813 |
if (-f 'stopfile') {
|
|
|
814 |
Error('StopFile detected');
|
|
|
815 |
}
|
|
|
816 |
|
|
|
817 |
|
|
|
818 |
print("Extract $pname $version, $oldvcs, $newvcs\n");
|
|
|
819 |
my $oldName = join('_', $pname, $version, 'old');
|
|
|
820 |
my $newName = join('_', $pname, $version, 'new');
|
|
|
821 |
|
|
|
822 |
my $oldView = catdir($dirWork,$oldName );
|
|
|
823 |
my $newView = catdir($dirWork,$newName );
|
|
|
824 |
|
|
|
825 |
|
|
|
826 |
JatsCmd('-logfile', catfile($dirLog, $oldName.'.log'),'jats_vcsrelease.pl', '-extractfiles', '-noprefix', '-root',$dirWork, '-view', $oldName ,'-label', $oldvcs );
|
|
|
827 |
JatsCmd('-logfile', catfile($dirLog, $newName.'.log'),'jats_vcsrelease.pl', '-extractfiles', '-noprefix', '-root',$dirWork, '-view', $newName ,'-label', $newvcs );
|
|
|
828 |
my $rv = System('diff', '-rq', $oldView, $newView);
|
|
|
829 |
print("Diff: $rv\n");
|
|
|
830 |
if ($rv == 0) {
|
|
|
831 |
markSame($pname, $version);
|
|
|
832 |
} elsif ($rv == 1) {
|
|
|
833 |
my $rv = System('diff', '-rq', '--exclude=build.pl', $oldView, $newView);
|
|
|
834 |
print("BuildDiff: $rv\n");
|
|
|
835 |
if ($rv == 0) {
|
|
|
836 |
markBuildDiff($pname, $version, $oldView, $newView);
|
|
|
837 |
} else {
|
|
|
838 |
markDiff($pname, $version, $oldView, $newView);
|
|
|
839 |
}
|
|
|
840 |
} else {
|
|
|
841 |
markBroken($pname, $version);
|
|
|
842 |
}
|
|
|
843 |
RmDirTree($oldView);
|
|
|
844 |
RmDirTree($newView);
|
|
|
845 |
}
|
|
|
846 |
|
|
|
847 |
#-------------------------------------------------------------------------------
|
|
|
848 |
# Function : isSame
|
|
|
849 |
#
|
|
|
850 |
# Description : known to be good
|
|
|
851 |
#
|
|
|
852 |
# Inputs :
|
|
|
853 |
#
|
|
|
854 |
# Returns :
|
|
|
855 |
#
|
|
|
856 |
sub isSame
|
|
|
857 |
{
|
|
|
858 |
my ($pname, $pver) = @_;
|
|
|
859 |
my $file = catdir($dirSame, join('__', $pname, $pver));
|
|
|
860 |
mkdir $dirSame || Error ("Cannot create $dirSame");
|
|
|
861 |
return (-f $file);
|
|
|
862 |
}
|
|
|
863 |
sub isDiff
|
|
|
864 |
{
|
|
|
865 |
my ($pname, $pver) = @_;
|
|
|
866 |
my $file = catdir($dirDiff, join('__', $pname, $pver));
|
|
|
867 |
mkdir $dirDiff || Error ("Cannot create $dirSame");
|
|
|
868 |
return (-f $file);
|
|
|
869 |
}
|
|
|
870 |
sub isSkip
|
|
|
871 |
{
|
|
|
872 |
my ($pname, $pver) = @_;
|
|
|
873 |
my $file = catdir($dirSkip, join('__', $pname, $pver));
|
|
|
874 |
mkdir $dirSkip || Error ("Cannot create $dirSame");
|
|
|
875 |
return (-f $file);
|
|
|
876 |
}
|
|
|
877 |
|
|
|
878 |
sub isBroken
|
|
|
879 |
{
|
|
|
880 |
my ($pname, $pver) = @_;
|
|
|
881 |
my $file = catdir($dirBroken, join('__', $pname, $pver));
|
|
|
882 |
mkdir $dirBroken || Error ("Cannot create $dirSame");
|
|
|
883 |
return (-f $file);
|
|
|
884 |
}
|
|
|
885 |
sub isBuildDiff
|
|
|
886 |
{
|
|
|
887 |
my ($pname, $pver) = @_;
|
|
|
888 |
my $file = catdir($dirBuildDiff, join('__', $pname, $pver));
|
|
|
889 |
mkdir $dirBuildDiff || Error ("Cannot create $dirSame");
|
|
|
890 |
return (-f $file);
|
|
|
891 |
}
|
|
|
892 |
|
|
|
893 |
sub getState
|
|
|
894 |
{
|
|
|
895 |
my ($pname, $pver) = @_;
|
|
|
896 |
return 'G' if isSame($pname,$pver);
|
|
|
897 |
return 'K' if isSkip($pname,$pver);
|
|
|
898 |
return 'd' if isBuildDiff($pname,$pver);
|
|
|
899 |
return 'D' if isDiff($pname,$pver);
|
|
|
900 |
return 'B' if isBroken($pname,$pver);
|
|
|
901 |
return '?';
|
|
|
902 |
|
|
|
903 |
}
|
|
|
904 |
#-------------------------------------------------------------------------------
|
|
|
905 |
# Function : markSame
|
|
|
906 |
#
|
|
|
907 |
# Description : Mark known to be the same
|
|
|
908 |
#
|
|
|
909 |
# Inputs :
|
|
|
910 |
#
|
|
|
911 |
# Returns :
|
|
|
912 |
#
|
|
|
913 |
sub markSame
|
|
|
914 |
{
|
|
|
915 |
my ($pname, $pver) = @_;
|
|
|
916 |
my $file = catdir($dirSame, join('__', $pname, $pver));
|
|
|
917 |
mkdir $dirSame || Error ("Cannot create $dirSame");
|
|
|
918 |
TouchFile($file);
|
|
|
919 |
}
|
|
|
920 |
|
|
|
921 |
sub markBroken
|
|
|
922 |
{
|
|
|
923 |
my ($pname, $pver) = @_;
|
|
|
924 |
my $file = catdir($dirBroken, join('__', $pname, $pver));
|
|
|
925 |
mkdir $dirBroken || Error ("Cannot create $dirSame");
|
|
|
926 |
TouchFile($file);
|
|
|
927 |
}
|
|
|
928 |
|
|
|
929 |
#-------------------------------------------------------------------------------
|
|
|
930 |
# Function : markDiff
|
|
|
931 |
#
|
|
|
932 |
# Description : Mark known to be the same
|
|
|
933 |
#
|
|
|
934 |
# Inputs :
|
|
|
935 |
#
|
|
|
936 |
# Returns :
|
|
|
937 |
#
|
|
|
938 |
sub markDiff
|
|
|
939 |
{
|
|
|
940 |
my ($pname, $pver, $dold, $dnew) = @_;
|
|
|
941 |
my $file = catdir($dirDiff, join('__', $pname, $pver));
|
|
|
942 |
mkdir $dirDiff || Error ("Cannot create $dirDiff");
|
|
|
943 |
TouchFile($file);
|
|
|
944 |
my $told = catdir($dirDiff,StripDir($dold));
|
|
|
945 |
my $tnew = catdir($dirDiff,StripDir($dnew));
|
|
|
946 |
|
|
|
947 |
RmDirTree($told);
|
|
|
948 |
RmDirTree($tnew);
|
|
|
949 |
move($dold, $told ) || Warning("Cannot move $dold, $dirSame");
|
|
|
950 |
move($dnew, $tnew) || Warning("Cannot move $dnew, $dirSame");
|
|
|
951 |
}
|
|
|
952 |
sub markBuildDiff
|
|
|
953 |
{
|
|
|
954 |
my ($pname, $pver, $dold, $dnew) = @_;
|
|
|
955 |
my $file = catdir($dirBuildDiff, join('__', $pname, $pver));
|
|
|
956 |
mkdir $dirBuildDiff || Error ("Cannot create $dirDiff");
|
|
|
957 |
TouchFile($file);
|
|
|
958 |
my $told = catdir($dirBuildDiff,StripDir($dold));
|
|
|
959 |
my $tnew = catdir($dirBuildDiff,StripDir($dnew));
|
|
|
960 |
|
|
|
961 |
RmDirTree($told);
|
|
|
962 |
RmDirTree($tnew);
|
|
|
963 |
move($dold, $told ) || Warning("Cannot move $dold, $dirSame");
|
|
|
964 |
move($dnew, $tnew) || Warning("Cannot move $dnew, $dirSame");
|
|
|
965 |
}
|
|
|
966 |
|
|
|
967 |
|
|
|
968 |
|
|
|
969 |
#-------------------------------------------------------------------------------
|
|
|
970 |
# Function : GetDataFromRM
|
|
|
971 |
#
|
|
|
972 |
# Description : Get Data from RM
|
|
|
973 |
#
|
|
|
974 |
# Inputs : $oref - Ref to output hash
|
|
|
975 |
# $credentials - to use to access RM
|
|
|
976 |
#
|
|
|
977 |
# Returns :
|
|
|
978 |
#
|
|
|
979 |
sub GetDataFromRM
|
|
|
980 |
{
|
|
|
981 |
my ($oref, $startPvid, $id, $url, $name, $passwd) = @_;
|
|
|
982 |
|
|
|
983 |
my (@row);
|
|
|
984 |
my $fh;
|
|
|
985 |
|
|
|
986 |
Message ("Extract data for: $oref");
|
|
|
987 |
open ($fh, '>' , $oref) || Error ("Cant write to $oref");
|
|
|
988 |
|
|
|
989 |
$ENV{GBE_RM_LOCATION} = $url;
|
|
|
990 |
$ENV{GBE_RM_USERNAME} = $name;
|
|
|
991 |
$ENV{GBE_RM_PASSWORD} = $passwd;
|
|
|
992 |
|
|
|
993 |
connectRM(\$RM_DB) unless ( $RM_DB );
|
|
|
994 |
|
|
|
995 |
# First get details from pv_id
|
|
|
996 |
my $m_sqlstr = <<"END_SQL";
|
|
|
997 |
SELECT pv.pv_id, p.pkg_name, pv.pkg_version,release_manager.PK_RMAPI.return_vcs_tag(PV_ID), NVL(pv.PKG_IDEXT,'-')
|
|
|
998 |
FROM RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGES p
|
|
|
999 |
WHERE pv.PKG_ID = p.PKG_ID AND pv.PV_ID > $startPvid ORDER by UPPER(p.pkg_name) DESC
|
|
|
1000 |
END_SQL
|
|
|
1001 |
|
|
|
1002 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
1003 |
if ( defined($sth) )
|
|
|
1004 |
{
|
|
|
1005 |
if ( $sth->execute( ) )
|
|
|
1006 |
{
|
|
|
1007 |
if ( $sth->rows )
|
|
|
1008 |
{
|
|
|
1009 |
while ( @row = $sth->fetchrow_array )
|
|
|
1010 |
{
|
|
|
1011 |
print $fh join(' ', @row), "\n";
|
|
|
1012 |
}
|
|
|
1013 |
}
|
|
|
1014 |
$sth->finish();
|
|
|
1015 |
}
|
|
|
1016 |
else
|
|
|
1017 |
{
|
|
|
1018 |
Error("Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
1019 |
}
|
|
|
1020 |
}
|
|
|
1021 |
else
|
|
|
1022 |
{
|
|
|
1023 |
Error("Prepare failure" );
|
|
|
1024 |
}
|
|
|
1025 |
|
|
|
1026 |
disconnectRM(\$RM_DB);
|
|
|
1027 |
close($fh);
|
|
|
1028 |
}
|
|
|
1029 |
|
|
|
1030 |
#-------------------------------------------------------------------------------
|
|
|
1031 |
# Function : GetEssentialVersions
|
|
|
1032 |
#
|
|
|
1033 |
# Description : Get Data from RM
|
|
|
1034 |
#
|
|
|
1035 |
# Inputs : $oref - Ref to output hash
|
|
|
1036 |
# $credentials - to use to access RM
|
|
|
1037 |
#
|
|
|
1038 |
# Returns :
|
|
|
1039 |
#
|
|
|
1040 |
sub GetEssentialVersions
|
|
|
1041 |
{
|
|
|
1042 |
my ($oref, $id, $url, $name, $passwd) = @_;
|
|
|
1043 |
|
|
|
1044 |
my (@row);
|
|
|
1045 |
my $fh;
|
|
|
1046 |
my %pvid;
|
|
|
1047 |
|
|
|
1048 |
Message ("Extract Essential versions for: $oref");
|
|
|
1049 |
open ($fh, '>' , $oref) || Error ("Cant write to $oref");
|
|
|
1050 |
|
|
|
1051 |
$ENV{GBE_RM_LOCATION} = $url;
|
|
|
1052 |
$ENV{GBE_RM_USERNAME} = $name;
|
|
|
1053 |
$ENV{GBE_RM_PASSWORD} = $passwd;
|
|
|
1054 |
|
|
|
1055 |
connectRM(\$RM_DB) unless ( $RM_DB );
|
|
|
1056 |
|
|
|
1057 |
# First get details from pv_id
|
|
|
1058 |
|
|
|
1059 |
my $m_sqlstr = "select unique pv_id from release_content rc where rc.rtag_id in ( " . join(',', @essentialRtags) . " ) order by pv_id desc";
|
|
|
1060 |
#Debug0("$m_sqlstr");
|
|
|
1061 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
1062 |
if ( defined($sth) )
|
|
|
1063 |
{
|
|
|
1064 |
if ( $sth->execute( ) )
|
|
|
1065 |
{
|
|
|
1066 |
if ( $sth->rows )
|
|
|
1067 |
{
|
|
|
1068 |
while ( @row = $sth->fetchrow_array )
|
|
|
1069 |
{
|
|
|
1070 |
$pvid{$row[0]} = 1;
|
|
|
1071 |
print $fh $row[0], "\n";
|
|
|
1072 |
|
|
|
1073 |
}
|
|
|
1074 |
}
|
|
|
1075 |
$sth->finish();
|
|
|
1076 |
}
|
|
|
1077 |
else
|
|
|
1078 |
{
|
|
|
1079 |
Error("Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
1080 |
}
|
|
|
1081 |
}
|
|
|
1082 |
else
|
|
|
1083 |
{
|
|
|
1084 |
Error("Prepare failure" );
|
|
|
1085 |
}
|
|
|
1086 |
|
|
|
1087 |
#
|
|
|
1088 |
# Get all the dependencies - even if they are pegged
|
|
|
1089 |
#
|
|
|
1090 |
while (1)
|
|
|
1091 |
{
|
|
|
1092 |
my @pvidList;
|
|
|
1093 |
my $more = 0;
|
|
|
1094 |
foreach my $key ( keys %pvid) {
|
|
|
1095 |
if ($pvid{$key} == 1) {
|
|
|
1096 |
push @pvidList, $key;
|
|
|
1097 |
$pvid{$key} = 2;
|
|
|
1098 |
$more++;
|
|
|
1099 |
last if $more > 700;
|
|
|
1100 |
}
|
|
|
1101 |
}
|
|
|
1102 |
|
|
|
1103 |
last unless $more;
|
|
|
1104 |
$m_sqlstr = "select unique dpv_id from package_dependencies where pv_id in ( " . join(',', @pvidList) . " )";
|
|
|
1105 |
#Debug0("$m_sqlstr");
|
|
|
1106 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
1107 |
if ( defined($sth) )
|
|
|
1108 |
{
|
|
|
1109 |
if ( $sth->execute( ) )
|
|
|
1110 |
{
|
|
|
1111 |
if ( $sth->rows )
|
|
|
1112 |
{
|
|
|
1113 |
while ( @row = $sth->fetchrow_array ) {
|
|
|
1114 |
unless (exists $pvid{$row[0]}) {
|
|
|
1115 |
$pvid{$row[0]} = 1;
|
|
|
1116 |
}
|
|
|
1117 |
}
|
|
|
1118 |
}
|
|
|
1119 |
$sth->finish();
|
|
|
1120 |
}
|
|
|
1121 |
else
|
|
|
1122 |
{
|
|
|
1123 |
Error("Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
1124 |
}
|
|
|
1125 |
}
|
|
|
1126 |
else
|
|
|
1127 |
{
|
|
|
1128 |
Error("Prepare failure" );
|
|
|
1129 |
}
|
|
|
1130 |
}
|
|
|
1131 |
|
|
|
1132 |
#
|
|
|
1133 |
# Get all package dependencies
|
|
|
1134 |
#
|
|
|
1135 |
my @allPvIds = keys %pvid;
|
|
|
1136 |
while (1)
|
|
|
1137 |
{
|
|
|
1138 |
my @pvidList;
|
|
|
1139 |
@pvidList = splice (@allPvIds, 0, 700);
|
|
|
1140 |
last unless @pvidList;
|
|
|
1141 |
|
|
|
1142 |
$m_sqlstr = "select pv_id, dpv_id from package_dependencies where pv_id in ( " . join(',', @pvidList) . " )";
|
|
|
1143 |
#Debug0("$m_sqlstr");
|
|
|
1144 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
1145 |
if ( defined($sth) )
|
|
|
1146 |
{
|
|
|
1147 |
if ( $sth->execute( ) )
|
|
|
1148 |
{
|
|
|
1149 |
if ( $sth->rows )
|
|
|
1150 |
{
|
|
|
1151 |
while ( @row = $sth->fetchrow_array ) {
|
|
|
1152 |
print $fh join(' ', @row), "\n";
|
|
|
1153 |
}
|
|
|
1154 |
}
|
|
|
1155 |
$sth->finish();
|
|
|
1156 |
}
|
|
|
1157 |
else
|
|
|
1158 |
{
|
|
|
1159 |
Error("Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
1160 |
}
|
|
|
1161 |
}
|
|
|
1162 |
else
|
|
|
1163 |
{
|
|
|
1164 |
Error("Prepare failure" );
|
|
|
1165 |
}
|
|
|
1166 |
}
|
|
|
1167 |
|
|
|
1168 |
|
|
|
1169 |
disconnectRM(\$RM_DB);
|
|
|
1170 |
close($fh);
|
|
|
1171 |
}
|
|
|
1172 |
|
|
|
1173 |
#-------------------------------------------------------------------------------
|
|
|
1174 |
# Function : GetRtagData
|
|
|
1175 |
#
|
|
|
1176 |
# Description : Get Data from RM
|
|
|
1177 |
#
|
|
|
1178 |
# Inputs : $oref - Ref to output hash
|
|
|
1179 |
# $credentials - to use to access RM
|
|
|
1180 |
#
|
|
|
1181 |
# Returns :
|
|
|
1182 |
#
|
|
|
1183 |
sub GetRtagData
|
|
|
1184 |
{
|
|
|
1185 |
my ($oref, $id, $url, $name, $passwd) = @_;
|
|
|
1186 |
|
|
|
1187 |
my (@row);
|
|
|
1188 |
my $fh;
|
|
|
1189 |
|
|
|
1190 |
Message ("Extract Essential versions for: $oref");
|
|
|
1191 |
open ($fh, '>' , $oref) || Error ("Cant write to $oref");
|
|
|
1192 |
|
|
|
1193 |
$ENV{GBE_RM_LOCATION} = $url;
|
|
|
1194 |
$ENV{GBE_RM_USERNAME} = $name;
|
|
|
1195 |
$ENV{GBE_RM_PASSWORD} = $passwd;
|
|
|
1196 |
|
|
|
1197 |
connectRM(\$RM_DB) unless ( $RM_DB );
|
|
|
1198 |
|
|
|
1199 |
# First get details from pv_id
|
|
|
1200 |
|
|
|
1201 |
my $m_sqlstr = "select rtag_id, rtag_name from release_manager.release_tags where rtag_id in ( " . join(',', @essentialRtags) . " ) order by UPPER(rtag_name) desc";
|
|
|
1202 |
#Debug0("$m_sqlstr");
|
|
|
1203 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
1204 |
if ( defined($sth) )
|
|
|
1205 |
{
|
|
|
1206 |
if ( $sth->execute( ) )
|
|
|
1207 |
{
|
|
|
1208 |
if ( $sth->rows )
|
|
|
1209 |
{
|
|
|
1210 |
while ( @row = $sth->fetchrow_array )
|
|
|
1211 |
{
|
|
|
1212 |
print $fh join(' ', @row), "\n";
|
|
|
1213 |
}
|
|
|
1214 |
}
|
|
|
1215 |
$sth->finish();
|
|
|
1216 |
}
|
|
|
1217 |
else
|
|
|
1218 |
{
|
|
|
1219 |
Error("Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
1220 |
}
|
|
|
1221 |
}
|
|
|
1222 |
else
|
|
|
1223 |
{
|
|
|
1224 |
Error("Prepare failure" );
|
|
|
1225 |
}
|
|
|
1226 |
|
|
|
1227 |
disconnectRM(\$RM_DB);
|
|
|
1228 |
close($fh);
|
|
|
1229 |
}
|
|
|
1230 |
|
|
|
1231 |
#-------------------------------------------------------------------------------
|
|
|
1232 |
# Function : GetReleaseContents
|
|
|
1233 |
#
|
|
|
1234 |
# Description : Get Data from RM
|
|
|
1235 |
#
|
|
|
1236 |
# Inputs : $oref - Ref to output hash
|
|
|
1237 |
# $credentials - to use to access RM
|
|
|
1238 |
#
|
|
|
1239 |
# Returns :
|
|
|
1240 |
#
|
|
|
1241 |
sub GetReleaseContents
|
|
|
1242 |
{
|
|
|
1243 |
my ($oref, $id, $url, $name, $passwd) = @_;
|
|
|
1244 |
|
|
|
1245 |
my (@row);
|
|
|
1246 |
my $fh;
|
|
|
1247 |
|
|
|
1248 |
Message ("Get Release Contents for: $oref");
|
|
|
1249 |
open ($fh, '>' , $oref) || Error ("Cant write to $oref");
|
|
|
1250 |
|
|
|
1251 |
$ENV{GBE_RM_LOCATION} = $url;
|
|
|
1252 |
$ENV{GBE_RM_USERNAME} = $name;
|
|
|
1253 |
$ENV{GBE_RM_PASSWORD} = $passwd;
|
|
|
1254 |
|
|
|
1255 |
connectRM(\$RM_DB) unless ( $RM_DB );
|
|
|
1256 |
|
|
|
1257 |
#
|
|
|
1258 |
# Process the required releases on at a time as we need to drill down and determine
|
|
|
1259 |
# all the dependencies - only get the non-pegged dependencies
|
|
|
1260 |
#
|
|
|
1261 |
# $pv_id {pvid} => 2: Not Pegged. 1: Pegged
|
|
|
1262 |
#
|
|
|
1263 |
foreach my $rtagId ( @essentialRtags )
|
|
|
1264 |
{
|
|
|
1265 |
my %pvid;
|
|
|
1266 |
my $m_sqlstr = "SELECT UNIQUE rc.pv_id, NVL2(pg.pv_id, 2, 1) FROM release_manager.release_content rc, release_manager.pegged_versions pg WHERE rc.rtag_id = $rtagId AND rc.rtag_id = pg.rtag_id(+) AND rc.pv_id = pg.pv_id(+)";
|
|
|
1267 |
#Debug0("$m_sqlstr");
|
|
|
1268 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
1269 |
if ( defined($sth) ) {
|
|
|
1270 |
if ( $sth->execute( ) ) {
|
|
|
1271 |
if ( $sth->rows ) {
|
|
|
1272 |
while ( @row = $sth->fetchrow_array ) {
|
|
|
1273 |
#Debug0("Data: @row");
|
|
|
1274 |
$pvid{$row[0]} = 1;
|
|
|
1275 |
$pvid{$row[0]} |= 0x1000 if ($row[1] ne 1);
|
|
|
1276 |
}
|
|
|
1277 |
}
|
|
|
1278 |
$sth->finish();
|
|
|
1279 |
}
|
|
|
1280 |
else
|
|
|
1281 |
{
|
|
|
1282 |
Error("Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
1283 |
}
|
|
|
1284 |
}
|
|
|
1285 |
else
|
|
|
1286 |
{
|
|
|
1287 |
Error("Prepare failure" );
|
|
|
1288 |
}
|
|
|
1289 |
#DebugDumpData("pvid",\%pvid);
|
|
|
1290 |
|
|
|
1291 |
#
|
|
|
1292 |
# Get all the dependencies and attribute them to this release
|
|
|
1293 |
#
|
|
|
1294 |
while ($opt_dependents)
|
|
|
1295 |
{
|
|
|
1296 |
my @pvidList;
|
|
|
1297 |
my $more = 0;
|
|
|
1298 |
foreach my $key ( keys %pvid) {
|
|
|
1299 |
unless ($pvid{$key} & 0x1000 ) {
|
|
|
1300 |
push @pvidList, $key;
|
|
|
1301 |
$pvid{$key} |= 0x1000;
|
|
|
1302 |
$more++;
|
|
|
1303 |
last if $more > 700;
|
|
|
1304 |
}
|
|
|
1305 |
}
|
|
|
1306 |
|
|
|
1307 |
last unless $more;
|
|
|
1308 |
$m_sqlstr = "select unique dpv_id from package_dependencies where pv_id in ( " . join(',', @pvidList) . " )";
|
|
|
1309 |
#Debug0("$m_sqlstr");
|
|
|
1310 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
1311 |
if ( defined($sth) )
|
|
|
1312 |
{
|
|
|
1313 |
if ( $sth->execute( ) )
|
|
|
1314 |
{
|
|
|
1315 |
if ( $sth->rows )
|
|
|
1316 |
{
|
|
|
1317 |
while ( @row = $sth->fetchrow_array ) {
|
|
|
1318 |
#Debug0("Data: @row");
|
|
|
1319 |
unless (exists $pvid{$row[0]}) {
|
|
|
1320 |
$pvid{$row[0]} = 2;
|
|
|
1321 |
}
|
|
|
1322 |
}
|
|
|
1323 |
}
|
|
|
1324 |
$sth->finish();
|
|
|
1325 |
}
|
|
|
1326 |
else
|
|
|
1327 |
{
|
|
|
1328 |
Error("Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
1329 |
}
|
|
|
1330 |
}
|
|
|
1331 |
else
|
|
|
1332 |
{
|
|
|
1333 |
Error("Prepare failure" );
|
|
|
1334 |
}
|
|
|
1335 |
}
|
|
|
1336 |
|
|
|
1337 |
#
|
|
|
1338 |
# Output the data
|
|
|
1339 |
#
|
|
|
1340 |
foreach my $pvid ( sort keys %pvid )
|
|
|
1341 |
{
|
|
|
1342 |
print $fh join(' ',$pvid,$rtagId, $pvid{$pvid} & 3 ), "\n";
|
|
|
1343 |
}
|
|
|
1344 |
}
|
|
|
1345 |
|
|
|
1346 |
disconnectRM(\$RM_DB);
|
|
|
1347 |
close($fh);
|
|
|
1348 |
|
|
|
1349 |
}
|
|
|
1350 |
|
|
|
1351 |
#-------------------------------------------------------------------------------
|
|
|
1352 |
# Function : isVersionGreater
|
|
|
1353 |
#
|
|
|
1354 |
# Description : Test two versions
|
|
|
1355 |
#
|
|
|
1356 |
# Inputs : $v1, $v2
|
|
|
1357 |
#
|
|
|
1358 |
# Returns : Tupple
|
|
|
1359 |
# 2 : Cannot parse
|
|
|
1360 |
# 1 : v1 >= v2
|
|
|
1361 |
# 0 : v1 < v2 or change in project
|
|
|
1362 |
# 3 : ripple change
|
|
|
1363 |
#
|
|
|
1364 |
# Code Letter
|
|
|
1365 |
# M - Major
|
|
|
1366 |
# m - Minor
|
|
|
1367 |
# p - Patch
|
|
|
1368 |
# r - Ripple
|
|
|
1369 |
# s - Same
|
|
|
1370 |
# E - Error
|
|
|
1371 |
# X - Project Change
|
|
|
1372 |
#
|
|
|
1373 |
sub isVersionGreater
|
|
|
1374 |
{
|
|
|
1375 |
my ($v1, $v2) = @_;
|
|
|
1376 |
my ($rv,$rc) = isVersionGreaterWrapper(@_);
|
|
|
1377 |
#Debug0("isVersionGreater: $v1, $v2 :: $rv, $rc");
|
|
|
1378 |
return $rv, $rc;
|
|
|
1379 |
}
|
|
|
1380 |
sub isVersionGreaterWrapper
|
|
|
1381 |
{
|
|
|
1382 |
my ($v1, $v2) = @_;
|
|
|
1383 |
return (1,'s') if $v1 eq $v2;
|
|
|
1384 |
|
|
|
1385 |
my ($v11, $v12, $v13, $v14, $v15 ) = SplitVersion( $v1);
|
|
|
1386 |
my ($v21, $v22, $v23, $v24, $v25 ) = SplitVersion( $v2);
|
|
|
1387 |
|
|
|
1388 |
return (2,'E') if (! defined($v11) || !defined($v21));
|
|
|
1389 |
|
|
|
1390 |
return (0,'X') unless $v15 eq $v25;
|
|
|
1391 |
|
|
|
1392 |
if ($v11 > $v21) {
|
|
|
1393 |
return (1,'M');
|
|
|
1394 |
} elsif ($v11 == $v21) {
|
|
|
1395 |
if ($v12 > $v22) {
|
|
|
1396 |
return (1,'m');
|
|
|
1397 |
} elsif ($v12 == $v22) {
|
|
|
1398 |
if ($v13 > $v23) {
|
|
|
1399 |
return (1,'p');
|
|
|
1400 |
} elsif ($v13 == $v23) {
|
|
|
1401 |
if ($v14 == $v24) {
|
|
|
1402 |
return (1,'s');
|
|
|
1403 |
} else {
|
|
|
1404 |
return (3,'r');
|
|
|
1405 |
}
|
|
|
1406 |
}
|
|
|
1407 |
}
|
|
|
1408 |
}
|
|
|
1409 |
return 0,'E';
|
|
|
1410 |
}
|
|
|
1411 |
|
|
|
1412 |
#-------------------------------------------------------------------------------
|
|
|
1413 |
# Function : SplitVersion
|
|
|
1414 |
#
|
|
|
1415 |
# Description : Spit a 'nice' version number into bits
|
|
|
1416 |
#
|
|
|
1417 |
# Inputs : $vn - version number
|
|
|
1418 |
#
|
|
|
1419 |
# Returns : An array of bits or UNDEF
|
|
|
1420 |
#
|
|
|
1421 |
sub SplitVersion
|
|
|
1422 |
{
|
|
|
1423 |
my ($vn) = @_;
|
|
|
1424 |
if ($vn =~ m~^(\d+)\.(\d+)\.(\d+)(\d{3})\.(\w+)$~) {
|
|
|
1425 |
return $1,$2,$3,$4,$5;
|
|
|
1426 |
} else {
|
|
|
1427 |
return undef;
|
|
|
1428 |
}
|
|
|
1429 |
}
|
|
|
1430 |
|
|
|
1431 |
#-------------------------------------------------------------------------------
|
|
|
1432 |
# Function : saveLocalData
|
|
|
1433 |
#
|
|
|
1434 |
# Description : Saves a hash of data to disk
|
|
|
1435 |
#
|
|
|
1436 |
# Inputs :
|
|
|
1437 |
#
|
|
|
1438 |
# Returns :
|
|
|
1439 |
#
|
|
|
1440 |
sub saveLocalData
|
|
|
1441 |
{
|
|
|
1442 |
#
|
|
|
1443 |
# Dump out the configuration information
|
|
|
1444 |
#
|
|
|
1445 |
my $fh = ConfigurationFile::New( $localDataStore);
|
|
|
1446 |
|
|
|
1447 |
$fh->DumpData( "\n# testPackageTip\n#\n", "testPackageTip", \%testPackageTip );
|
|
|
1448 |
$fh->DumpData( "\n# basePackageVersions\n#\n", "basePackageVersions", \%basePackageVersions );
|
|
|
1449 |
$fh->DumpData( "\n# usedBy\n#\n", "usedBy", \%usedBy );
|
|
|
1450 |
|
|
|
1451 |
$fh->Close();
|
|
|
1452 |
}
|
|
|
1453 |
|
|
|
1454 |
#-------------------------------------------------------------------------------
|
|
|
1455 |
# Function : restoreLocalData
|
|
|
1456 |
#
|
|
|
1457 |
# Description : Read in the locally preserved data
|
|
|
1458 |
#
|
|
|
1459 |
# Inputs :
|
|
|
1460 |
#
|
|
|
1461 |
# Returns :
|
|
|
1462 |
#
|
|
|
1463 |
sub restoreLocalData
|
|
|
1464 |
{
|
|
|
1465 |
if (-f $localDataStore) {
|
|
|
1466 |
require ( $localDataStore );
|
|
|
1467 |
}
|
|
|
1468 |
}
|
|
|
1469 |
|
|
|
1470 |
|
|
|
1471 |
#-------------------------------------------------------------------------------
|
|
|
1472 |
# Function : GetUsedProjects
|
|
|
1473 |
#
|
|
|
1474 |
# Description : Determine the projects used by a specific PV_ID
|
|
|
1475 |
#
|
|
|
1476 |
# Inputs : $pvid
|
|
|
1477 |
# @credentials
|
|
|
1478 |
#
|
|
|
1479 |
# Returns :
|
|
|
1480 |
#
|
|
|
1481 |
sub GetUsedProjects
|
|
|
1482 |
{
|
|
|
1483 |
my ($pvid, $id, $url, $name, $passwd) = @_;
|
|
|
1484 |
my (@row);
|
|
|
1485 |
|
|
|
1486 |
Debug ("GetUsedProjects: $pvid");
|
|
|
1487 |
unless (exists $usedBy{GetUsedProjects}{$pvid}) {
|
|
|
1488 |
|
|
|
1489 |
$ENV{GBE_RM_LOCATION} = $url;
|
|
|
1490 |
$ENV{GBE_RM_USERNAME} = $name;
|
|
|
1491 |
$ENV{GBE_RM_PASSWORD} = $passwd;
|
|
|
1492 |
|
|
|
1493 |
connectRM(\$RM_DB);
|
|
|
1494 |
|
|
|
1495 |
my @data;
|
|
|
1496 |
my $m_sqlstr = <<"END_SQL";
|
|
|
1497 |
SELECT proj.PROJ_ID,
|
|
|
1498 |
proj.PROJ_NAME,
|
|
|
1499 |
ev.RTAG_ID,
|
|
|
1500 |
rt.rtag_name
|
|
|
1501 |
FROM ENVIRONMENT_VIEW ev,
|
|
|
1502 |
PACKAGE_VERSIONS pv,
|
|
|
1503 |
RELEASE_TAGS rt,
|
|
|
1504 |
PROJECTS proj
|
|
|
1505 |
WHERE ev.PV_ID = pv.PV_ID
|
|
|
1506 |
AND ev.RTAG_ID = rt.RTAG_ID
|
|
|
1507 |
AND rt.PROJ_ID = proj.PROJ_ID
|
|
|
1508 |
AND ev.PV_ID = $pvid
|
|
|
1509 |
ORDER BY UPPER(proj.PROJ_NAME), UPPER(RTAG_NAME)
|
|
|
1510 |
END_SQL
|
|
|
1511 |
#Debug0("$m_sqlstr");
|
|
|
1512 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
1513 |
if ( defined($sth) ) {
|
|
|
1514 |
if ( $sth->execute( ) ) {
|
|
|
1515 |
if ( $sth->rows ) {
|
|
|
1516 |
while ( @row = $sth->fetchrow_array ) {
|
|
|
1517 |
my @dataCopy = @row;
|
|
|
1518 |
push @data,\@dataCopy;
|
|
|
1519 |
}
|
|
|
1520 |
}
|
|
|
1521 |
$sth->finish();
|
|
|
1522 |
} else {
|
|
|
1523 |
Error("Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
1524 |
}
|
|
|
1525 |
} else {
|
|
|
1526 |
Error("Prepare failure" );
|
|
|
1527 |
}
|
|
|
1528 |
|
|
|
1529 |
disconnectRM(\$RM_DB);
|
|
|
1530 |
$usedBy{GetUsedProjects}{$pvid} = \@data;
|
|
|
1531 |
}
|
|
|
1532 |
return $usedBy{GetUsedProjects}{$pvid};
|
|
|
1533 |
}
|
|
|
1534 |
|
|
|
1535 |
#-------------------------------------------------------------------------------
|
|
|
1536 |
# Function : GetUsedSdks
|
|
|
1537 |
#
|
|
|
1538 |
# Description : Determine the SDKs used by a specific PV_ID
|
|
|
1539 |
#
|
|
|
1540 |
# Inputs : $pvid
|
|
|
1541 |
# @credentials
|
|
|
1542 |
#
|
|
|
1543 |
# Returns :
|
|
|
1544 |
#
|
|
|
1545 |
sub GetUsedSdks
|
|
|
1546 |
{
|
|
|
1547 |
my ($pvid, $id, $url, $name, $passwd) = @_;
|
|
|
1548 |
my (@row);
|
|
|
1549 |
|
|
|
1550 |
Debug ("GetUsedProjects: $pvid");
|
|
|
1551 |
unless (exists $usedBy{GetUsedSdks}{$pvid}) {
|
|
|
1552 |
|
|
|
1553 |
$ENV{GBE_RM_LOCATION} = $url;
|
|
|
1554 |
$ENV{GBE_RM_USERNAME} = $name;
|
|
|
1555 |
$ENV{GBE_RM_PASSWORD} = $passwd;
|
|
|
1556 |
|
|
|
1557 |
connectRM(\$RM_DB);
|
|
|
1558 |
my @data;
|
|
|
1559 |
my $m_sqlstr = <<"END_SQL";
|
|
|
1560 |
SELECT DISTINCT st.SDK_ID, SDK_NAME, st.sdktag_id, st.sdktag_name
|
|
|
1561 |
FROM release_manager.SDK_CONTENT sc,
|
|
|
1562 |
release_manager.SDK_TAGS st,
|
|
|
1563 |
release_manager.SDK_NAMES sn,
|
|
|
1564 |
release_manager.PACKAGE_VERSIONS pv
|
|
|
1565 |
WHERE sc.SDKTAG_ID = st.SDKTAG_ID
|
|
|
1566 |
AND (sc.PV_ID = :PV_ID )
|
|
|
1567 |
AND st.SDK_ID = sn.SDK_ID
|
|
|
1568 |
AND sc.PV_ID = pv.PV_ID
|
|
|
1569 |
ORDER BY UPPER(SDK_NAME)
|
|
|
1570 |
END_SQL
|
|
|
1571 |
#Debug0("$m_sqlstr");
|
|
|
1572 |
$m_sqlstr =~ s~:PV_ID~$pvid~g;
|
|
|
1573 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
1574 |
if ( defined($sth) ) {
|
|
|
1575 |
if ( $sth->execute( ) ) {
|
|
|
1576 |
if ( $sth->rows ) {
|
|
|
1577 |
while ( @row = $sth->fetchrow_array ) {
|
|
|
1578 |
my @dataCopy = @row;
|
|
|
1579 |
push @data,\@dataCopy;
|
|
|
1580 |
}
|
|
|
1581 |
}
|
|
|
1582 |
$sth->finish();
|
|
|
1583 |
} else {
|
|
|
1584 |
Error("Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
1585 |
}
|
|
|
1586 |
} else {
|
|
|
1587 |
Error("Prepare failure" );
|
|
|
1588 |
}
|
|
|
1589 |
|
|
|
1590 |
disconnectRM(\$RM_DB);
|
|
|
1591 |
$usedBy{GetUsedSdks}{$pvid} = \@data;
|
|
|
1592 |
}
|
|
|
1593 |
return $usedBy{GetUsedSdks}{$pvid};
|
|
|
1594 |
}
|
|
|
1595 |
|
|
|
1596 |
#-------------------------------------------------------------------------------
|
|
|
1597 |
# Function : GetUsedSboms
|
|
|
1598 |
#
|
|
|
1599 |
# Description : Determine the SBOMs used by a specific PV_ID
|
|
|
1600 |
#
|
|
|
1601 |
# Inputs : $pvid
|
|
|
1602 |
# @credentials
|
|
|
1603 |
#
|
|
|
1604 |
# Returns :
|
|
|
1605 |
#
|
|
|
1606 |
sub GetUsedSboms
|
|
|
1607 |
{
|
|
|
1608 |
my ($pvid, $id, $url, $name, $passwd) = @_;
|
|
|
1609 |
my (@row);
|
|
|
1610 |
|
|
|
1611 |
Debug ("GetUsedProjects: $pvid");
|
|
|
1612 |
|
|
|
1613 |
unless (exists $usedBy{GetUsedSboms}{$pvid}) {
|
|
|
1614 |
|
|
|
1615 |
$ENV{GBE_RM_LOCATION} = $url;
|
|
|
1616 |
$ENV{GBE_RM_USERNAME} = $name;
|
|
|
1617 |
$ENV{GBE_RM_PASSWORD} = $passwd;
|
|
|
1618 |
|
|
|
1619 |
connectRM(\$RM_DB);
|
|
|
1620 |
|
|
|
1621 |
my @data;
|
|
|
1622 |
my $m_sqlstr = <<"END_SQL";
|
|
|
1623 |
SELECT DISTINCT b.branch_id, proj.proj_name ||' - '|| br.branch_name as name, b.bom_id, b.bom_version
|
|
|
1624 |
FROM package_versions pv,
|
|
|
1625 |
packages pkg,
|
|
|
1626 |
DEPLOYMENT_MANAGER.os_contents osc,
|
|
|
1627 |
DEPLOYMENT_MANAGER.operating_systems os,
|
|
|
1628 |
DEPLOYMENT_MANAGER.network_nodes nn,
|
|
|
1629 |
DEPLOYMENT_MANAGER.bom_contents bc,
|
|
|
1630 |
DEPLOYMENT_MANAGER.boms b,
|
|
|
1631 |
DEPLOYMENT_MANAGER.bom_names bn,
|
|
|
1632 |
DEPLOYMENT_MANAGER.branches br,
|
|
|
1633 |
DEPLOYMENT_MANAGER.dm_projects proj
|
|
|
1634 |
WHERE pv.pkg_id = pkg.pkg_id
|
|
|
1635 |
AND osc.prod_id = pv.pv_id
|
|
|
1636 |
AND os.os_id = osc.os_id
|
|
|
1637 |
AND nn.node_id = os.node_id
|
|
|
1638 |
AND bc.node_id = nn.node_id
|
|
|
1639 |
AND b.bom_id = bc.bom_id
|
|
|
1640 |
AND bn.bom_name_id = b.bom_name_id
|
|
|
1641 |
AND br.branch_id = b.branch_id
|
|
|
1642 |
AND proj.proj_id = br.proj_id
|
|
|
1643 |
AND br.is_hidden IS NULL
|
|
|
1644 |
AND (osc.prod_id = :PV_ID )
|
|
|
1645 |
ORDER BY UPPER(name)
|
|
|
1646 |
END_SQL
|
|
|
1647 |
#Debug0("$m_sqlstr");
|
|
|
1648 |
$m_sqlstr =~ s~:PV_ID~$pvid~g;
|
|
|
1649 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
1650 |
if ( defined($sth) ) {
|
|
|
1651 |
if ( $sth->execute( ) ) {
|
|
|
1652 |
if ( $sth->rows ) {
|
|
|
1653 |
while ( @row = $sth->fetchrow_array ) {
|
|
|
1654 |
my @dataCopy = @row;
|
|
|
1655 |
push @data,\@dataCopy;
|
|
|
1656 |
}
|
|
|
1657 |
}
|
|
|
1658 |
$sth->finish();
|
|
|
1659 |
} else {
|
|
|
1660 |
Error("Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
1661 |
}
|
|
|
1662 |
} else {
|
|
|
1663 |
Error("Prepare failure" );
|
|
|
1664 |
}
|
|
|
1665 |
|
|
|
1666 |
disconnectRM(\$RM_DB);
|
|
|
1667 |
|
|
|
1668 |
$usedBy{GetUsedSboms}{$pvid} = \@data;
|
|
|
1669 |
}
|
|
|
1670 |
return $usedBy{GetUsedSboms}{$pvid};
|
|
|
1671 |
}
|
|
|
1672 |
#-------------------------------------------------------------------------------
|
|
|
1673 |
# Documentation
|
|
|
1674 |
#
|
|
|
1675 |
|
|
|
1676 |
=pod
|
|
|
1677 |
|
|
|
1678 |
=for htmltoc GENERAL::ClearCase::
|
|
|
1679 |
|
|
|
1680 |
=head1 NAME
|
|
|
1681 |
|
|
|
1682 |
rmMerge_process - Process data for Release Manager Merge
|
|
|
1683 |
|
|
|
1684 |
=head1 SYNOPSIS
|
|
|
1685 |
|
|
|
1686 |
jats rmMerge_spit [options] PackageName PackageVersion
|
|
|
1687 |
|
|
|
1688 |
Options:
|
|
|
1689 |
-help - brief help message
|
|
|
1690 |
-help -help - Detailed help message
|
|
|
1691 |
-man - Full documentation
|
|
|
1692 |
-[no]reuse - Reuse exsiting rmData (default)
|
|
|
1693 |
-refresh - Refresh data - don't get new package versions
|
|
|
1694 |
-order=n - Only displlay packes with rmMerge_processing order <= n
|
|
|
1695 |
-type=nnn - Only display type nnn
|
|
|
1696 |
-command - Display commands to transfer packages
|
|
|
1697 |
-[no]dependents - Include indirect dependents
|
|
|
1698 |
|
|
|
1699 |
=head1 OPTIONS
|
|
|
1700 |
|
|
|
1701 |
=over 8
|
|
|
1702 |
|
|
|
1703 |
=item B<-help>
|
|
|
1704 |
|
|
|
1705 |
Print a brief help message and exits.
|
|
|
1706 |
|
|
|
1707 |
=item B<-help -help>
|
|
|
1708 |
|
|
|
1709 |
Print a detailed help message with an explanation for each option.
|
|
|
1710 |
|
|
|
1711 |
=back
|
|
|
1712 |
|
|
|
1713 |
=head2 OPTIONS
|
|
|
1714 |
|
|
|
1715 |
=over
|
|
|
1716 |
|
|
|
1717 |
=item -[no]reuse
|
|
|
1718 |
|
|
|
1719 |
The default option is 'reuse'. The 'noreuse' option will cause the program to extract a lot of
|
|
|
1720 |
data from the two Release Manager databases. This is time consuming.
|
|
|
1721 |
|
|
|
1722 |
=item -order=n
|
|
|
1723 |
|
|
|
1724 |
The option will cause the final display to be filtered such that only packages with an insertion
|
|
|
1725 |
order of less than or equal to that specified will be displayed.
|
|
|
1726 |
|
|
|
1727 |
=back
|
|
|
1728 |
|
|
|
1729 |
=head1 EXAMPLE
|
|
|
1730 |
|
|
|
1731 |
jats eprog rmMerge_process
|
|
|
1732 |
|
|
|
1733 |
=cut
|
|
|
1734 |
|