Subversion Repositories DevTools

Rev

Rev 2478 | Rev 5709 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2478 Rev 2764
Line 172... Line 172...
172
} else {
172
} else {
173
    Error ("Mode not specified: all, hops, standard");
173
    Error ("Mode not specified: all, hops, standard");
174
}
174
}
175
 
175
 
176
GetAllPackageNames();
176
GetAllPackageNames();
-
 
177
getPackagesInSvn();
177
getReleaseDetails();
178
getReleaseDetails();
178
getPkgDetailsByRTAG_ID();
179
getPkgDetailsByRTAG_ID();
179
my ($pcount, $vcount) = countPackages();
180
my ($pcount, $vcount) = countPackages();
180
print "Directly referenced Packages: $pcount Versions: $vcount\n";
181
print "Directly referenced Packages: $pcount Versions: $vcount\n";
181
LocateStrays() unless ($opt_quick);
182
LocateStrays() unless ($opt_quick);
182
($pcount, $vcount) = countPackages();
183
($pcount, $vcount) = countPackages();
183
print "Indirectly referenced Packages: $pcount Versions: $vcount\n";
184
print "Indirectly referenced Packages: $pcount Versions: $vcount\n";
-
 
185
getSourcePaths();
184
processData();
186
processData();
185
outputData();
187
outputData();
186
 
188
 
187
if ( $opt_verbose > 1 )
189
if ( $opt_verbose > 1 )
188
{
190
{
Line 197... Line 199...
197
($pcount, $vcount) = countPackages();
199
($pcount, $vcount) = countPackages();
198
print "Total References Packages: $pcount Versions: $vcount\n";
200
print "Total References Packages: $pcount Versions: $vcount\n";
199
exit;
201
exit;
200
 
202
 
201
#-------------------------------------------------------------------------------
203
#-------------------------------------------------------------------------------
-
 
204
# Function        : getPackagesInSvn
-
 
205
#
-
 
206
# Description     : Determine packages that have been migrated
-
 
207
#                   Done by looking up RM for any version that has been migrated
-
 
208
#
-
 
209
# Inputs          : 
-
 
210
#
-
 
211
# Returns         : 
-
 
212
#
-
 
213
sub getPackagesInSvn
-
 
214
{
-
 
215
    my (@row);
-
 
216
 
-
 
217
    # if we are not or cannot connect then return 0 as we have not found anything
-
 
218
    connectRM(\$RM_DB) unless $RM_DB;
-
 
219
 
-
 
220
    # First get all packages that are referenced in a Release
-
 
221
    # This will only get the top level packages
-
 
222
    # From non-archived releases
-
 
223
 
-
 
224
    my $m_sqlstr = "SELECT UNIQUE" .
-
 
225
                        " pv.PKG_ID ".                                         #[0]
-
 
226
                   " FROM RELEASE_MANAGER.PACKAGE_VERSIONS pv".
-
 
227
                   " WHERE pv.VCS_TYPE_ID=23";
-
 
228
    my $sth = $RM_DB->prepare($m_sqlstr);
-
 
229
    if ( defined($sth) )
-
 
230
    {
-
 
231
        if ( $sth->execute( ) )
-
 
232
        {
-
 
233
#            print "--- Execute\n";
-
 
234
            if ( $sth->rows )
-
 
235
            {
-
 
236
                #print "--- Execute ROWS\n";
-
 
237
                while ( @row = $sth->fetchrow_array )
-
 
238
                {
-
 
239
                    my $id = $row[0];
-
 
240
                    next unless ( $id );
-
 
241
                    $AllPackages{$id}{inSvn} = 1;
-
 
242
#print "Data: @row\n";
-
 
243
                }
-
 
244
            }
-
 
245
#            print "--- Finish\n";
-
 
246
            $sth->finish();
-
 
247
        }
-
 
248
        else
-
 
249
        {
-
 
250
            Error("Execute failure: $m_sqlstr", $sth->errstr() );
-
 
251
        }
-
 
252
    }
-
 
253
    else
-
 
254
    {
-
 
255
        Error("Prepare failure" );
-
 
256
    }
-
 
257
    
-
 
258
}
-
 
259
 
-
 
260
#-------------------------------------------------------------------------------
202
# Function        : getReleaseDetails
261
# Function        : getReleaseDetails
203
#
262
#
204
# Description     : Determine all candiate releases
263
# Description     : Determine all candiate releases
205
#
264
#
206
# Inputs          : 
265
# Inputs          : 
Line 292... Line 351...
292
}
351
}
293
 
352
 
294
 
353
 
295
sub getPkgDetailsByPVID
354
sub getPkgDetailsByPVID
296
{
355
{
297
    my ($pv_id) = @_;
356
    my (@plist) = @_;
298
    my (@row);
357
    my (@row);
299
 
358
 
300
    #
359
    #
301
    #   Only do once
360
    #   Only do once
302
    #
361
    #
303
    return if ( exists $Packages{$pv_id}{name} );
362
#    return if ( exists $Packages{$pv_id}{name} );
304
    
363
 
305
    # if we are not or cannot connect then return 0 as we have not found anything
364
    # if we are not or cannot connect then return 0 as we have not found anything
306
    connectRM(\$RM_DB) unless $RM_DB;
365
    connectRM(\$RM_DB) unless $RM_DB;
307
 
366
 
308
    my $m_sqlstr = "SELECT" .
367
    my $m_sqlstr = "SELECT" .
309
                        " pv.PV_ID, ".                                          #[0]
368
                        " pv.PV_ID, ".                                          #[0]
Line 314... Line 373...
314
                        " pv.PKG_ID," .                                         #[5]
373
                        " pv.PKG_ID," .                                         #[5]
315
                        " pv.MODIFIED_STAMP, ".                                 #[6]
374
                        " pv.MODIFIED_STAMP, ".                                 #[6]
316
                        " pv.CREATOR_ID  ".                                     #[7]
375
                        " pv.CREATOR_ID  ".                                     #[7]
317
                   " FROM RELEASE_MANAGER.PACKAGE_VERSIONS pv,".
376
                   " FROM RELEASE_MANAGER.PACKAGE_VERSIONS pv,".
318
                   "      RELEASE_MANAGER.PACKAGES pkg ".
377
                   "      RELEASE_MANAGER.PACKAGES pkg ".
319
                   " WHERE pv.PV_ID = \'$pv_id\' ".
378
                   " WHERE pv.PKG_ID = pkg.PKG_ID ".
320
                   "   AND pv.PKG_ID = pkg.PKG_ID" ;
379
                   "   AND pv.PV_ID in ( " . join(',', @plist) . "  )" ;
321
    my $sth = $RM_DB->prepare($m_sqlstr);
380
    my $sth = $RM_DB->prepare($m_sqlstr);
322
    if ( defined($sth) )
381
    if ( defined($sth) )
323
    {
382
    {
324
        if ( $sth->execute( ) )
383
        if ( $sth->execute( ) )
325
        {
384
        {
Line 330... Line 389...
330
                while ( @row = $sth->fetchrow_array )
389
                while ( @row = $sth->fetchrow_array )
331
                {
390
                {
332
                    print join (',',@row), "\n" if ($opt_verbose);
391
                    print join (',',@row), "\n" if ($opt_verbose);
333
 
392
 
334
                    my $pvid = $row[0];
393
                    my $pvid = $row[0];
-
 
394
                    my $pkgid = $row[5];
335
                    $Packages{$pvid}{name} = $row[1];
395
                    $Packages{$pvid}{name} = $row[1];
-
 
396
                    next if ( exists $Packages{$pvid}{version} );
-
 
397
 
336
                    $Packages{$pvid}{version} = $row[2];
398
                    $Packages{$pvid}{version} = $row[2];
337
                    $Packages{$pvid}{locked} = $row[3];
399
                    $Packages{$pvid}{locked} = $row[3];
338
                    $row[4] =~ tr~\\/~/~;
400
                    $row[4] =~ tr~\\/~/~;
339
                    $Packages{$pvid}{vcstag} = $row[4];
401
                    $Packages{$pvid}{vcstag} = $row[4];
340
                    $Packages{$pvid}{pkgid} = $row[5];
402
                    $Packages{$pvid}{pkgid} = $pkgid;
341
#                    $Packages{$pvid}{tlp} = 1;
403
#                    $Packages{$pvid}{tlp} = 1;
342
                    ($Packages{$pvid}{suffix}, $Packages{$pvid}{fullVersion},$Packages{$pvid}{isaRipple} ) = massageVersion( $Packages{$pvid}{version}, $Packages{$pvid}{name} );
404
                    ($Packages{$pvid}{suffix}, $Packages{$pvid}{fullVersion},$Packages{$pvid}{isaRipple} ) = massageVersion( $Packages{$pvid}{version}, $Packages{$pvid}{name} );
343
                    $Suffixes{$Packages{$pvid}{suffix}}++;
405
                    $Suffixes{$Packages{$pvid}{suffix}}++;
344
                    $Packages{$pvid}{Age} = ($now - str2time( $row[6] )) / (60 * 60 * 24);
406
                    $Packages{$pvid}{Age} = ($now - str2time( $row[6] )) / (60 * 60 * 24);
345
                    $Packages{$pvid}{Creator} = $row[7];
407
                    $Packages{$pvid}{Creator} = $row[7];
-
 
408
 
-
 
409
                    $AllPackages{$pkgid}{essential} = 1;
346
                }
410
                }
347
            }
411
            }
348
#            print "--- Finish\n";
412
#            print "--- Finish\n";
349
            $sth->finish();
413
            $sth->finish();
350
        }
414
        }
Line 418... Line 482...
418
            if ( $sth->rows )
482
            if ( $sth->rows )
419
            {
483
            {
420
#                print "--- Execute ROWS\n";
484
#                print "--- Execute ROWS\n";
421
                while ( @row = $sth->fetchrow_array )
485
                while ( @row = $sth->fetchrow_array )
422
                {
486
                {
-
 
487
                    $count++;
423
                    print join (',',@row), "\n" if ($opt_verbose);
488
                    print join (',',@row), "\n" if ($opt_verbose);
424
                    my $pvid = $row[0];
489
                    my $pvid = $row[0];
425
                    unless ( exists $Packages{$pvid}{name} )
490
                    unless ( exists $Packages{$pvid}{name} )
426
                    {
491
                    {
-
 
492
                        my $pkgid = $row[5];
427
                        $Packages{$pvid}{name} = $row[1];
493
                        $Packages{$pvid}{name} = $row[1];
428
                        $Packages{$pvid}{version} = $row[2];
494
                        $Packages{$pvid}{version} = $row[2];
429
                        $Packages{$pvid}{locked} = $row[3];
495
                        $Packages{$pvid}{locked} = $row[3];
430
                        $row[4] =~ tr~\\/~/~;
496
                        $row[4] =~ tr~\\/~/~;
431
                        $Packages{$pvid}{vcstag} = $row[4];
497
                        $Packages{$pvid}{vcstag} = $row[4];
432
                        $Packages{$pvid}{pkgid} = $row[5];
498
                        $Packages{$pvid}{pkgid} = $pkgid;
433
                        $Packages{$pvid}{tlp} = 1;
499
                        $Packages{$pvid}{tlp} = 1;
434
                        ($Packages{$pvid}{suffix}, $Packages{$pvid}{fullVersion},$Packages{$pvid}{isaRipple} ) = massageVersion( $Packages{$pvid}{version}, $Packages{$pvid}{name} );
500
                        ($Packages{$pvid}{suffix}, $Packages{$pvid}{fullVersion},$Packages{$pvid}{isaRipple} ) = massageVersion( $Packages{$pvid}{version}, $Packages{$pvid}{name} );
435
                        $Suffixes{$Packages{$pvid}{suffix}}++;
501
                        $Suffixes{$Packages{$pvid}{suffix}}++;
-
 
502
                        $AllPackages{$pkgid}{essential} = 1;
436
 
503
 
437
                        push @StrayPackages, $pvid;
504
                        push @StrayPackages, $pvid;
438
                    }
505
                    }
439
 
506
 
440
                    my $rtag_id = $row[6];
507
                    my $rtag_id = $row[6];
Line 465... Line 532...
465
                    }
532
                    }
466
 
533
 
467
 
534
 
468
                    if ( $opt_limit )
535
                    if ( $opt_limit )
469
                    {
536
                    {
470
                        last if ( $count++ > $opt_limit );
537
                        last if ( $count > $opt_limit );
471
                    }
538
                    }
472
                }
539
                }
473
            }
540
            }
474
#            print "--- Finish\n";
541
#            print "--- Finish\n";
475
            $sth->finish();
542
            $sth->finish();
Line 481... Line 548...
481
    }
548
    }
482
    else
549
    else
483
    {
550
    {
484
        Error("Prepare failure" );
551
        Error("Prepare failure" );
485
    }
552
    }
-
 
553
 
-
 
554
    Message ("Extract toplevel dependencies: $count rows");
486
}
555
}
487
 
556
 
488
#-------------------------------------------------------------------------------
557
#-------------------------------------------------------------------------------
489
# Function        : GetDepends
558
# Function        : GetDepends
490
#
559
#
491
# Description     :
560
# Description     :
492
#
561
#
493
# Inputs          : $pvid
562
# Inputs          : @plist          - list of pvid's to process
494
#
563
#
495
# Returns         :
564
# Returns         :
496
#
565
#
497
sub GetDepends
566
sub GetDepends
498
{
567
{
499
    my ($pv_id ) = @_;
568
    my (@plist) = @_;
500
 
569
 
501
    #
570
    #
502
    #   Ensure we have package information
571
    #   Ensure we have package information
503
    #
572
    #
504
    getPkgDetailsByPVID( $pv_id );
573
    getPkgDetailsByPVID( @plist );
505
    return if ( $Packages{$pv_id}{depend} );
574
#    return if ( $Packages{$pv_id}{depend} );
506
    $Packages{$pv_id}{depend} = 1;
575
#    $Packages{$pv_id}{depend} = 1;
507
 
576
 
508
    #
577
    #
509
    #   Now extract the package dependacies
578
    #   Now extract the package dependacies
510
    #   There may not be any
579
    #   There may not be any
511
    #
580
    #
512
    my $m_sqlstr = "SELECT ".
581
    my $m_sqlstr = "SELECT ".
513
                    " pd.PV_ID, ".
582
                    " pd.PV_ID, ".
514
                    " pd.DPV_ID " .
583
                    " pd.DPV_ID " .
515
                  " FROM    RELEASE_MANAGER.PACKAGE_DEPENDENCIES pd ".
584
                  " FROM    RELEASE_MANAGER.PACKAGE_DEPENDENCIES pd ".
516
                  " WHERE pd.PV_ID = \'$pv_id\'";
585
                  " WHERE pd.PV_ID in ( " . join(',', @plist) . " )";
517
    my $sth = $RM_DB->prepare($m_sqlstr);
586
    my $sth = $RM_DB->prepare($m_sqlstr);
518
    if ( defined($sth) )
587
    if ( defined($sth) )
519
    {
588
    {
520
        if ( $sth->execute( ) )
589
        if ( $sth->execute( ) )
521
        {
590
        {
Line 571... Line 640...
571
                while ( my @row = $sth->fetchrow_array )
640
                while ( my @row = $sth->fetchrow_array )
572
                {
641
                {
573
                    my $id = $row[0];
642
                    my $id = $row[0];
574
                    my $name = $row[1];
643
                    my $name = $row[1];
575
                    next unless ( $id );
644
                    next unless ( $id );
576
                    $AllPackages{$id} = $name;
645
                    $AllPackages{$id}{name} = $name;
577
                }
646
                }
578
            }
647
            }
579
            $sth->finish();
648
            $sth->finish();
580
        }
649
        }
581
        else
650
        else
582
        {
651
        {
583
        Error("GetAllPackageNames:Execute failure" );
652
            Error("GetAllPackageNames:Execute failure: $m_sqlstr", $sth->errstr() );
584
        }
653
        }
585
    }
654
    }
586
    else
655
    else
587
    {
656
    {
588
        Error("GetAllPackageNames:Prepare failure" );
657
        Error("GetAllPackageNames:Prepare failure" );
589
    }
658
    }
590
}
659
}
591
 
660
 
-
 
661
#-------------------------------------------------------------------------------
-
 
662
# Function        : getSourcePaths
-
 
663
#
-
 
664
# Description     : Get source paths for all packages
-
 
665
#                   Really only want those not in SVN
-
 
666
#
-
 
667
# Inputs          : Globals
-
 
668
#
-
 
669
# Returns         : Globals
-
 
670
#
-
 
671
sub getSourcePaths
-
 
672
{
-
 
673
    Message("Get source paths for all packages");
-
 
674
    # if we are not or cannot connect then return 0 as we have not found anything
-
 
675
    connectRM(\$RM_DB) unless $RM_DB;
-
 
676
 
-
 
677
    #
-
 
678
    #   Process on blocks for speed
-
 
679
    #
-
 
680
    my @needed;
-
 
681
    foreach my $pkgid ( keys %AllPackages, 0 )
-
 
682
    {
-
 
683
        if ( $pkgid )
-
 
684
        {
-
 
685
            next unless ( exists $AllPackages{$pkgid}{essential} );
-
 
686
            next if ( $AllPackages{$pkgid}{inSvn} );
-
 
687
            $AllPackages{$pkgid}{essential} = 2;
-
 
688
            push @needed, $pkgid;
-
 
689
#print "= $pkgid, $AllPackages{$pkgid}{name}\n";
-
 
690
        }
-
 
691
 
-
 
692
        #
-
 
693
        #   Have enough for a query
-
 
694
        #
-
 
695
        if ( scalar @needed > 100 || (! $pkgid && scalar @needed > 0) )
-
 
696
        {
-
 
697
            #
-
 
698
            #   Now extract all the source paths
-
 
699
            #
-
 
700
            my $m_sqlstr = "SELECT UNIQUE" .
-
 
701
                        " pv.PKG_ID, ".                                     #[0]
-
 
702
                        " pv.SRC_PATH, ".                                   #[1]
-
 
703
                        " pv.VCS_TYPE_ID ".                                 #[2]
-
 
704
                        " FROM RELEASE_MANAGER.PACKAGE_VERSIONS pv".
-
 
705
                        " WHERE pv.PKG_ID in (" . join(',', @needed) . ")";
-
 
706
 
-
 
707
            my $sth = $RM_DB->prepare($m_sqlstr);
-
 
708
            if ( defined($sth) )
-
 
709
            {
-
 
710
                if ( $sth->execute( ) )
-
 
711
                {
-
 
712
                    if ( $sth->rows )
-
 
713
                    {
-
 
714
                        while ( my @row = $sth->fetchrow_array )
-
 
715
                        {
-
 
716
#print "--- @row\n";
-
 
717
                            my $pkgid = $row[0];
-
 
718
                            my $type = $row[2] || '2';
-
 
719
                            if ( $row[1] )
-
 
720
                            {
-
 
721
                                #
-
 
722
                                #   Trivial cleanup
-
 
723
                                #
-
 
724
                                my $path = '/' . $row[1];   # Force initial /
-
 
725
                                $path =~ tr~\\/~/~s;        # Force / and single /
-
 
726
                                $path =~ s~/+$~~;           # Remove Trailing /
-
 
727
                                $AllPackages{$pkgid}{srcPath}{$path}++;
-
 
728
                            }
-
 
729
                        }
-
 
730
                    }
-
 
731
                    $sth->finish();
-
 
732
                }
-
 
733
                else
-
 
734
                {
-
 
735
                    Error("getSourcePaths:Execute failure: $m_sqlstr", $sth->errstr() );
-
 
736
                }
-
 
737
            }
-
 
738
            else
-
 
739
            {
-
 
740
                Error("getSourcePaths:Prepare failure" );
-
 
741
            }
-
 
742
 
-
 
743
            #
-
 
744
            #   Reset the list
-
 
745
            #
-
 
746
            @needed = ();
-
 
747
        }
-
 
748
    }
-
 
749
}
-
 
750
 
592
 
751
 
593
#-------------------------------------------------------------------------------
752
#-------------------------------------------------------------------------------
594
# Function        : massageVersion
753
# Function        : massageVersion
595
#
754
#
596
# Description     : Process a version number and return usful bits
755
# Description     : Process a version number and return usful bits
Line 822... Line 981...
822
 
981
 
823
 
982
 
824
#-------------------------------------------------------------------------------
983
#-------------------------------------------------------------------------------
825
# Function        : LocateStrays
984
# Function        : LocateStrays
826
#
985
#
827
# Description     :
986
# Description     : Locate stray packages
-
 
987
#                   Try to do several at a time to speed up processing
828
#
988
#
829
# Inputs          :
989
# Inputs          :
830
#
990
#
831
# Returns         :
991
# Returns         :
832
#
992
#
833
sub LocateStrays
993
sub LocateStrays
834
{
994
{
835
    Message ("Locate indirectly referenced packages");
995
    Message ("Locate indirectly referenced packages");
836
    while ( $#StrayPackages >= 0 )
996
    while ( $#StrayPackages >= 0 )
837
    {
997
    {
838
        my $pv_id = pop @StrayPackages;
998
#print "Strays Remaining: ", scalar @StrayPackages ,"\n";
839
 
999
 
-
 
1000
        my @plist;
-
 
1001
        while ( $#plist <= 200 && @StrayPackages )
-
 
1002
        {
-
 
1003
            my $pv_id = pop @StrayPackages;
840
        next if ( exists $Packages{$pv_id}{done} );
1004
            next if ( exists $Packages{$pv_id}{done} );
841
#print "... ",$#StrayPackages,"\n";
1005
            push @plist, $pv_id;
-
 
1006
        }
-
 
1007
 
842
        GetDepends( $pv_id);
1008
        GetDepends(@plist) if @plist;
-
 
1009
 
-
 
1010
        foreach ( @plist)
-
 
1011
        {
843
        $Packages{$pv_id}{done} = 1;
1012
            $Packages{$_}{done} = 1;
-
 
1013
        }
844
    }
1014
    }
845
}
1015
}
846
 
1016
 
847
#-------------------------------------------------------------------------------
1017
#-------------------------------------------------------------------------------
848
# Function        : countPackages
1018
# Function        : countPackages