Subversion Repositories DevTools

Rev

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

Rev 4646 Rev 5125
Line 7... Line 7...
7
# Environment(s): jats
7
# Environment(s): jats
8
#
8
#
9
# Description   :  Remove packages from dpkg_archive that are no longer
9
# Description   :  Remove packages from dpkg_archive that are no longer
10
#                  required - if they can be rebuilt.
10
#                  required - if they can be rebuilt.
11
#
11
#
-
 
12
#                  Keep package version if
-
 
13
#                   Cannot be rebuilt
-
 
14
#                   It is in use by a non-archived release
-
 
15
#                   It is a dependent package of a package in a non-archived release
-
 
16
#                   It is an exposed package in an non-deprecated SDK
-
 
17
#                   It is used in one of the last two SBOMs (within Deployment Manager)
-
 
18
#                   defined within each state of each branch of each project.
-
 
19
#                   It is a dependent package of one of the SBOM packages
-
 
20
#
-
 
21
#                   Packages that are not in RM will be purged
-
 
22
#
-
 
23
#
12
# Usage         :  See POD at end of file
24
# Usage         :  See POD at end of file
13
#
25
#
14
#......................................................................#
26
#......................................................................#
15
 
27
 
16
require 5.008_002;
28
require 5.008_002;
Line 48... Line 60...
48
#
60
#
49
#   Globals
61
#   Globals
50
#
62
#
51
my $progBase;
63
my $progBase;
52
my $RM_DB;
64
my $RM_DB;
-
 
65
my $DM_DB;
53
my $now = time();
66
my $now = time();
54
my $quarantineInstance;
67
my $quarantineInstance;
55
my $logPath;
68
my $logPath;
56
my %pkgPvid;
69
my %pkgPvid;
57
my @quarantineItems;
70
my @quarantineItems;
Line 149... Line 162...
149
if ( $opt_phase =~ m~1~ && !$opt_purge )
162
if ( $opt_phase =~ m~1~ && !$opt_purge )
150
{
163
{
151
    getReleaseDetails();
164
    getReleaseDetails();
152
    GetAllPackageData();
165
    GetAllPackageData();
153
    getTopLevelPackages();
166
    getTopLevelPackages();
-
 
167
    GetRecentDMPackages();
154
    LocateStrays() unless ($opt_quick);
168
    LocateStrays() unless ($opt_quick);
-
 
169
    GetSdkPackageData();
155
 
170
 
156
    if ( $opt_verbose > 1 )
171
    if ( $opt_verbose > 1 )
157
    {
172
    {
158
        print "=========================================================================\n";
173
        print "=========================================================================\n";
159
        DebugDumpData("Releases", \%Releases);
174
        DebugDumpData("Releases", \%Releases);
Line 375... Line 390...
375
    }
390
    }
376
 
391
 
377
    Verbose ("All Packages: $count rows");
392
    Verbose ("All Packages: $count rows");
378
}
393
}
379
 
394
 
380
 
-
 
381
#-------------------------------------------------------------------------------
395
#-------------------------------------------------------------------------------
382
# Function        : getTopLevelPackages
396
# Function        : getTopLevelPackages
383
#
397
#
384
# Description     : Extract top level packages from active releases
398
# Description     : Extract top level packages from active releases
385
#
399
#
Line 460... Line 474...
460
 
474
 
461
    Verbose ("Extract toplevel dependencies: $count rows");
475
    Verbose ("Extract toplevel dependencies: $count rows");
462
}
476
}
463
 
477
 
464
#-------------------------------------------------------------------------------
478
#-------------------------------------------------------------------------------
-
 
479
# Function        : GetSdkPackageData
-
 
480
#
-
 
481
# Description     : Extract Packages that are a part of a non-deprecated SDK
-
 
482
#                   Only want the exposed packages
-
 
483
#
-
 
484
#                   Don't care about the dependencies, so don't add them 
-
 
485
#                   to strays
-
 
486
#
-
 
487
# Inputs          : 
-
 
488
#
-
 
489
# Returns         : 
-
 
490
#
-
 
491
 
-
 
492
sub GetSdkPackageData
-
 
493
{
-
 
494
    my (@row);
-
 
495
    my $count = 0;
-
 
496
 
-
 
497
    # if we are not or cannot connect then return 0 as we have not found anything
-
 
498
    connectRM(\$RM_DB) unless $RM_DB;
-
 
499
 
-
 
500
    Verbose ("Extract SDK Packages");
-
 
501
 
-
 
502
    # Get all packages that are a part of a non-deprecated SDK
-
 
503
    # Only get the 'exposed' packages
-
 
504
 
-
 
505
    my $limit = $opt_limit ? " AND rownum <= $opt_limit" : '';
-
 
506
    my $m_sqlstr = "SELECT sc.pv_id, " .                #[0]
-
 
507
                   "       p.PKG_NAME, " .              #[1]
-
 
508
                   "       pv.PKG_VERSION" .            #[2]
-
 
509
                   " FROM RELEASE_MANAGER.SDK_CONTENT sc," .
-
 
510
                   "   RELEASE_MANAGER.sdk_tags st," .
-
 
511
                   "   RELEASE_MANAGER.package_versions pv," .
-
 
512
                   "   RELEASE_MANAGER.PACKAGES p" .
-
 
513
                   " WHERE sc.SDKTAG_ID    = st.SDKTAG_ID" .
-
 
514
                   " AND p.PKG_ID = pv.PKG_ID" .
-
 
515
                   " AND pv.PV_ID = sc.pv_id" .
-
 
516
                   " AND sc.SDKPKG_STATE   = 'E'" .
-
 
517
                   " AND st.SDK_STATE NOT IN ('D')" .
-
 
518
                    $limit;
-
 
519
 
-
 
520
    Verbose3("GetSdkPackageData: $m_sqlstr");
-
 
521
    my $sth = $RM_DB->prepare($m_sqlstr);
-
 
522
    if ( defined($sth) )
-
 
523
    {
-
 
524
        if ( $sth->execute( ) )
-
 
525
        {
-
 
526
            if ( $sth->rows )
-
 
527
            {
-
 
528
                while ( @row = $sth->fetchrow_array )
-
 
529
                {
-
 
530
                    $count++;
-
 
531
                    print join (',',@row), "\n" if ($opt_verbose > 2);
-
 
532
                    my $pvid = $row[0];
-
 
533
                    $Packages{$pvid}{sdk} = 1;
-
 
534
                    unless ( exists $Packages{$pvid}{name} )
-
 
535
                    {
-
 
536
                        $Packages{$pvid}{name} = $row[1];
-
 
537
                        $Packages{$pvid}{version} = $row[2];
-
 
538
                    }
-
 
539
 
-
 
540
                    if ( $opt_limit )
-
 
541
                    {
-
 
542
                        last if ( $count > $opt_limit );
-
 
543
                    }
-
 
544
                }
-
 
545
            }
-
 
546
            $sth->finish();
-
 
547
        }
-
 
548
        else
-
 
549
        {
-
 
550
            Error("GetSdkPackageData:Execute failure: $m_sqlstr", $sth->errstr() );
-
 
551
        }
-
 
552
    }
-
 
553
    else
-
 
554
    {
-
 
555
        Error("GetSdkPackageData:Prepare failure" );
-
 
556
    }
-
 
557
 
-
 
558
    Verbose ("Extract SDK Packages: $count rows");
-
 
559
}
-
 
560
 
-
 
561
#-------------------------------------------------------------------------------
-
 
562
# Function        : GetRecentDMPackages
-
 
563
#
-
 
564
# Description     : Extract Packages that referenced in Deployment Manager
-
 
565
#                   Want all package-versions from the last two BOMS in each state
-
 
566
#                   of all projects. 
-
 
567
#
-
 
568
# Inputs          : 
-
 
569
#
-
 
570
# Returns         : 
-
 
571
#
-
 
572
 
-
 
573
sub GetRecentDMPackages
-
 
574
{
-
 
575
    my (@row);
-
 
576
    my $count = 0;
-
 
577
 
-
 
578
    # if we are not or cannot connect then return 0 as we have not found anything
-
 
579
    connectDM(\$DM_DB) unless ($DM_DB);
-
 
580
 
-
 
581
    Verbose ("Extract DM Packages");
-
 
582
 
-
 
583
    # Get all packages that are a part of a non-deprecated SDK
-
 
584
    # Only get the 'exposed' packages
-
 
585
 
-
 
586
    my $limit = $opt_limit ? " AND rownum <= $opt_limit" : '';
-
 
587
    my $m_sqlstr = 
-
 
588
        " SELECT DISTINCT pv.pv_id,".               #[0] 
-
 
589
        "   pkg.pkg_name,".                         #[1] 
-
 
590
        "   pv.pkg_version".                        #[2] 
-
 
591
        " FROM bom_contents bc,".
-
 
592
        "   DEPLOYMENT_MANAGER.operating_systems os,".
-
 
593
        "   DEPLOYMENT_MANAGER.os_contents osc,".
-
 
594
        "   DEPLOYMENT_MANAGER.PACKAGES pkg,".
-
 
595
        "   DEPLOYMENT_MANAGER.PACKAGE_VERSIONS pv,".
-
 
596
        "   DEPLOYMENT_MANAGER.PRODUCT_DETAILS pd".
-
 
597
        " WHERE osc.os_id = os.os_id".
-
 
598
        " AND os.node_id  = bc.node_id".
-
 
599
        " AND bc.bom_id  IN".
-
 
600
        "   (SELECT bom_id".
-
 
601
        "   FROM".
-
 
602
        "     (SELECT bom_id,".
-
 
603
        "       state_id,".
-
 
604
        "       RANK( ) OVER (PARTITION BY state_id ORDER BY bom_id DESC) SRLNO".
-
 
605
        "     FROM DEPLOYMENT_MANAGER.bom_state".
-
 
606
        "     )".
-
 
607
        "   WHERE SRLNO <= 2".
-
 
608
        "   )".
-
 
609
        " AND pd.PROD_ID (+) = osc.PROD_ID".
-
 
610
        " AND pv.pkg_id      = pkg.pkg_id".
-
 
611
        " AND osc.prod_id    = pv.pv_id".
-
 
612
        " ORDER BY UPPER(pkg.pkg_name),".
-
 
613
        "   UPPER(pv.PKG_VERSION)".
-
 
614
        $limit;
-
 
615
 
-
 
616
    Verbose3("GetRecentDMPackages: $m_sqlstr");
-
 
617
    my $sth = $DM_DB->prepare($m_sqlstr);
-
 
618
    if ( defined($sth) )
-
 
619
    {
-
 
620
        if ( $sth->execute( ) )
-
 
621
        {
-
 
622
            if ( $sth->rows )
-
 
623
            {
-
 
624
                while ( @row = $sth->fetchrow_array )
-
 
625
                {
-
 
626
                    $count++;
-
 
627
                    print join (',',@row), "\n" if ($opt_verbose > 2);
-
 
628
                    my $pvid = $row[0];
-
 
629
                    $Packages{$pvid}{dm} = 1;
-
 
630
                    unless ( exists $Packages{$pvid}{name} )
-
 
631
                    {
-
 
632
                        $Packages{$pvid}{name} = $row[1];
-
 
633
                        $Packages{$pvid}{version} = $row[2];
-
 
634
                    }
-
 
635
                    push @StrayPackages, $pvid;
-
 
636
 
-
 
637
                    if ( $opt_limit )
-
 
638
                    {
-
 
639
                        last if ( $count > $opt_limit );
-
 
640
                    }
-
 
641
                }
-
 
642
            }
-
 
643
            $sth->finish();
-
 
644
        }
-
 
645
        else
-
 
646
        {
-
 
647
            Error("GetRecentDMPackages:Execute failure: $m_sqlstr", $sth->errstr() );
-
 
648
        }
-
 
649
    }
-
 
650
    else
-
 
651
    {
-
 
652
        Error("GetRecentDMPackages:Prepare failure" );
-
 
653
    }
-
 
654
 
-
 
655
    Verbose ("Extract Deployed Packages: $count rows");
-
 
656
}
-
 
657
 
-
 
658
#-------------------------------------------------------------------------------
465
# Function        : GetDepends
659
# Function        : GetDepends
466
#
660
#
467
# Description     :
661
# Description     :
468
#
662
#
469
# Inputs          : @plist          - list of pvid's to process
663
# Inputs          : @plist          - list of pvid's to process
Line 562... Line 756...
562
    my $count = 0;
756
    my $count = 0;
563
    my $direct = 0;
757
    my $direct = 0;
564
    my $indirect = 0;
758
    my $indirect = 0;
565
    my $buildable = 0;
759
    my $buildable = 0;
566
    my $bad = 0;
760
    my $bad = 0;
-
 
761
    my $sdk = 0;
567
 
762
 
568
    foreach my $pvid ( keys %Packages )
763
    foreach my $pvid ( keys %Packages )
569
    {
764
    {
570
        my $entry = $Packages{$pvid};
765
        my $entry = $Packages{$pvid};
571
        unless ( defined $entry->{name} && defined $entry->{version})
766
        unless ( defined $entry->{name} && defined $entry->{version})
Line 579... Line 774...
579
        if ( $entry->{locked} && $entry->{locked} eq 'Y' && $entry->{buildStandard} > 0 )
774
        if ( $entry->{locked} && $entry->{locked} eq 'Y' && $entry->{buildStandard} > 0 )
580
        {
775
        {
581
            $buildable++;
776
            $buildable++;
582
        }
777
        }
583
 
778
 
584
        $direct++ if ( $entry->{tlp} );
779
        if ( $entry->{tlp} ) {
-
 
780
            $direct++;
-
 
781
        }
585
        $indirect++ if ( $entry->{slp} );
782
        elsif ( $entry->{slp} ) {
-
 
783
            $indirect++;
-
 
784
        }
-
 
785
        elsif ($entry->{sdk}) {
-
 
786
            $sdk++;
-
 
787
        }
-
 
788
 
586
    }
789
    }
587
 
790
 
588
    my $file = "quarantine.raw.txt";
791
    my $file = "quarantine.raw.txt";
589
    Verbose ("Create: $file");
792
    Verbose ("Create: $file");
590
    my $fh = ConfigurationFile::New( $file );
793
    my $fh = ConfigurationFile::New( $file );
Line 597... Line 800...
597
        "\n# Release Data.\n#\n",
800
        "\n# Release Data.\n#\n",
598
        "Releases", \%Releases );
801
        "Releases", \%Releases );
599
        
802
        
600
    $fh->Close();
803
    $fh->Close();
601
 
804
 
602
    Verbose("Packages: $count, Bad: $bad: Buildable: $buildable, Directly included: $direct, Indirect: $indirect");
805
    Verbose("Packages: $count, Bad: $bad: Buildable: $buildable, Directly included: $direct, Indirect: $indirect, Sdk: $sdk");
603
}
806
}
604
 
807
 
605
#-------------------------------------------------------------------------------
808
#-------------------------------------------------------------------------------
606
# Function        : prepQdir
809
# Function        : prepQdir
607
#
810
#
Line 766... Line 969...
766
    close(PKGS);
969
    close(PKGS);
767
 
970
 
768
 
971
 
769
    #
972
    #
770
    #
973
    #
-
 
974
    #   Scan all packages found in dpkg_archive and see if we should keep it
771
    #   Display information
975
    #   Quarantine those we cannot find a reason to keep
772
    #
976
    #
773
    foreach my $pkgName ( sort keys %pkgPvid )
977
    foreach my $pkgName ( sort keys %pkgPvid )
774
    {
978
    {
775
        foreach my $pkgVersion ( sort keys %{$pkgPvid{$pkgName}} )
979
        foreach my $pkgVersion ( sort keys %{$pkgPvid{$pkgName}} )
776
        {
980
        {
Line 778... Line 982...
778
            my $pvid = $pkgPvid{$pkgName}{$pkgVersion}{pvid};
982
            my $pvid = $pkgPvid{$pkgName}{$pkgVersion}{pvid};
779
 
983
 
780
            if ( $pvid && $mtime )
984
            if ( $pvid && $mtime )
781
            {
985
            {
782
                my $entry = $Packages{$pvid};
986
                my $entry = $Packages{$pvid};
783
                next if ( exists $entry->{tlp} || exists $entry->{slp} );
987
                next if ( exists $entry->{tlp} || exists $entry->{slp} || exists $entry->{sdk} || exists $entry->{dm} );
784
                next if ( $mtime <= $config{retain} );
988
                next if ( $mtime <= $config{retain} );
785
                next unless ( $entry->{buildStandard} );
989
                next unless ( $entry->{buildStandard} );
786
                next if ( $entry->{isPatch} );
990
                next if ( $entry->{isPatch} );
787
                next if ( $entry->{locked} ne 'Y');
991
                next if ( $entry->{locked} ne 'Y');
788
#                next if ( $entry->{buildType} eq 'M' );
992
#                next if ( $entry->{buildType} eq 'M' );
Line 1165... Line 1369...
1165
 
1369
 
1166
Determine package-versions in use by Release Manager.
1370
Determine package-versions in use by Release Manager.
1167
 
1371
 
1168
=item *
1372
=item *
1169
 
1373
 
-
 
1374
Determine package-versions in recent Deployment Manager SBOMS.
-
 
1375
 
-
 
1376
=item *
-
 
1377
 
1170
Determine package-versions that can be rebuilt
1378
Determine package-versions that can be rebuilt
1171
 
1379
 
1172
=item *
1380
=item *
1173
 
1381
 
1174
Recursively find all the dependent packages of all packages. New package
1382
Recursively find all the dependent packages of all packages. New package