Subversion Repositories DevTools

Rev

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

Rev 289 Rev 295
Line 38... Line 38...
38
my $opt_rtag_id;
38
my $opt_rtag_id;
39
my $opt_test = 0;
39
my $opt_test = 0;
40
my $opt_patch = 1;
40
my $opt_patch = 1;
41
my $opt_extract;
41
my $opt_extract;
42
my $opt_rootpkg;
42
my $opt_rootpkg;
-
 
43
my $opt_rootpkg_version;
43
 
44
 
44
#
45
#
45
#   Data Base Interface
46
#   Data Base Interface
46
#
47
#
47
my $RM_DB;
48
my $RM_DB;
Line 59... Line 60...
59
my @StrayPackages;              # Non-top level packages
60
my @StrayPackages;              # Non-top level packages
60
my @create_list;                # List of files created
61
my @create_list;                # List of files created
61
my $fpref = "sbom";             # Sbom Prefix
62
my $fpref = "sbom";             # Sbom Prefix
62
our $GBE_RM_URL;
63
our $GBE_RM_URL;
63
our $GBE_DM_URL;
64
our $GBE_DM_URL;
-
 
65
my $sbom_name;
-
 
66
my $sbom_branch;
-
 
67
my $sbom_project;
-
 
68
my $sbom_version;
-
 
69
my $rtag_release;
-
 
70
my $rtag_project;
64
 
71
 
65
#
72
#
66
#   Constants, that should be variable
73
#   Constants, that should be variable
67
#
74
#
68
my $rm_base = "/dependencies.asp?pv_id=";
75
my $rm_base = "/dependencies.asp?pv_id=";
Line 177... Line 184...
177
{
184
{
178
    #
185
    #
179
    #   Determines the OS_ID's for the bom
186
    #   Determines the OS_ID's for the bom
180
    #
187
    #
181
    getOSIDforBOMID($opt_sbom_id);
188
    getOSIDforBOMID($opt_sbom_id);
-
 
189
    getSBOMDetails($opt_sbom_id);
182
 
190
 
183
    #
191
    #
184
    #   Locate packages associated with the base install for each os
192
    #   Locate packages associated with the base install for each os
185
    #
193
    #
186
    foreach my $base_env_id ( sort keys %os_env_list )
194
    foreach my $base_env_id ( sort keys %os_env_list )
Line 220... Line 228...
220
        #   Determine the package
228
        #   Determine the package
221
        #
229
        #
222
        Error ("Root Package not found: $opt_rootpkg") unless ( exists $Release{$opt_rootpkg} );
230
        Error ("Root Package not found: $opt_rootpkg") unless ( exists $Release{$opt_rootpkg} );
223
        my @root_vers = keys %{$Release{$opt_rootpkg}};
231
        my @root_vers = keys %{$Release{$opt_rootpkg}};
224
        Error ("Multiple versions of Root Package: $opt_rootpkg", @root_vers ) if ( $#root_vers > 0 );
232
        Error ("Multiple versions of Root Package: $opt_rootpkg", @root_vers ) if ( $#root_vers > 0 );
-
 
233
        $opt_rootpkg_version = $root_vers[0];
225
        Message("Root Package: $opt_rootpkg, " . $root_vers[0]);
234
        Message("Root Package: $opt_rootpkg, " . $opt_rootpkg_version);
226
 
235
 
227
        getPkgDetailsByPV_ID( $Release{$opt_rootpkg}{$root_vers[0]}{pv_id} );
236
        getPkgDetailsByPV_ID( $Release{$opt_rootpkg}{$opt_rootpkg_version}{pv_id} );
228
    }
237
    }
229
    else
238
    else
230
    {
239
    {
231
        getPkgDetailsForPVIDs (keys %Release_pvid);
240
        getPkgDetailsForPVIDs (keys %Release_pvid);
232
    }
241
    }
Line 243... Line 252...
243
        unless ( $pv_id );
252
        unless ( $pv_id );
244
 
253
 
245
    #
254
    #
246
    #   Set package as the root package
255
    #   Set package as the root package
247
    $opt_rootpkg = $ARGV[0];
256
    $opt_rootpkg = $ARGV[0];
-
 
257
    $opt_rootpkg_version = $ARGV[1];
248
    getPkgDetailsByPV_ID( $pv_id  );
258
    getPkgDetailsByPV_ID( $pv_id  );
249
    LocateStrays(2);
259
    LocateStrays(2);
250
}
260
}
251
else
261
else
252
{
262
{
Line 358... Line 368...
358
}
368
}
359
exit;
369
exit;
360
 
370
 
361
 
371
 
362
#-------------------------------------------------------------------------------
372
#-------------------------------------------------------------------------------
-
 
373
# Function        : getSBOMDetails
-
 
374
#
-
 
375
# Description     : Get some details about the SBOM
-
 
376
#                   Used fro descriptive text
-
 
377
#
-
 
378
# Inputs          : $bom_id             - BOM to process
-
 
379
#
-
 
380
# Returns         : 
-
 
381
#
-
 
382
sub getSBOMDetails
-
 
383
{
-
 
384
    my ($bom_id) = @_;
-
 
385
    my $foundDetails = 0;
-
 
386
    my (@row);
-
 
387
Verbose ("getSBOMDetails");
-
 
388
    connectDM(\$DM_DB) unless ($DM_DB);
-
 
389
 
-
 
390
    my $m_sqlstr = "SELECT distinct dp.PROJ_NAME ,bn.BOM_NAME, br.BRANCH_NAME, bm.BOM_VERSION, bm.BOM_LIFECYCLE" .
-
 
391
                   " FROM DEPLOYMENT_MANAGER.BOMS bm, DEPLOYMENT_MANAGER.BOM_NAMES bn, DEPLOYMENT_MANAGER.BRANCHES br, DEPLOYMENT_MANAGER.DM_PROJECTS dp" .
-
 
392
                   " WHERE bm.BOM_ID = $bom_id AND bm.BOM_NAME_ID = bn.BOM_NAME_ID AND bm.BRANCH_ID = br.BRANCH_ID AND br.PROJ_ID = dp.PROJ_ID";
-
 
393
 
-
 
394
    my $sth = $DM_DB->prepare($m_sqlstr);
-
 
395
    if ( defined($sth) )
-
 
396
    {
-
 
397
        if ( $sth->execute( ) )
-
 
398
        {
-
 
399
            if ( $sth->rows )
-
 
400
            {
-
 
401
                while ( @row = $sth->fetchrow_array )
-
 
402
                {
-
 
403
                    $sbom_project   = $row[0];
-
 
404
                    $sbom_name      = $row[1];
-
 
405
                    $sbom_branch    = $row[2];
-
 
406
                    $sbom_version   = $row[3] . '.' . $row[4];
-
 
407
                    $foundDetails = 1;
-
 
408
                }
-
 
409
            }
-
 
410
            $sth->finish();
-
 
411
        }
-
 
412
        else
-
 
413
        {
-
 
414
            Error("getSBOMDetails:Execute failure", $m_sqlstr );
-
 
415
        }
-
 
416
    }
-
 
417
    else
-
 
418
    {
-
 
419
        Error("getSBOMDetails:Prepare failure" );
-
 
420
    }
-
 
421
 
-
 
422
    Error("getSBOMDetails:No OS Information Found" ) unless $foundDetails;
-
 
423
    
-
 
424
}
-
 
425
 
-
 
426
#-------------------------------------------------------------------------------
-
 
427
# Function        : getReleaseDetails
-
 
428
#
-
 
429
# Description     : Get some details about the Release
-
 
430
#                   Used fro descriptive text
-
 
431
#
-
 
432
# Inputs          : $rtag_id             - RTAG_ID to process
-
 
433
#
-
 
434
# Returns         : 
-
 
435
#
-
 
436
sub getReleaseDetails
-
 
437
{
-
 
438
    my ($rtag_id) = @_;
-
 
439
    my $foundDetails = 0;
-
 
440
    my (@row);
-
 
441
Verbose ("getReleaseDetails");
-
 
442
    connectDM(\$DM_DB) unless ($DM_DB);
-
 
443
 
-
 
444
    my $m_sqlstr = "SELECT distinct rt.RTAG_NAME, pr.PROJ_NAME" .
-
 
445
                   " FROM RELEASE_MANAGER.RELEASE_TAGS rt, RELEASE_MANAGER.PROJECTS pr" .
-
 
446
                   " WHERE rt.RTAG_ID = $rtag_id AND rt.PROJ_ID = pr.PROJ_ID";
-
 
447
 
-
 
448
    my $sth = $DM_DB->prepare($m_sqlstr);
-
 
449
    if ( defined($sth) )
-
 
450
    {
-
 
451
        if ( $sth->execute( ) )
-
 
452
        {
-
 
453
            if ( $sth->rows )
-
 
454
            {
-
 
455
                while ( @row = $sth->fetchrow_array )
-
 
456
                {
-
 
457
                    $rtag_release = $row[0];
-
 
458
                    $rtag_project = $row[1];
-
 
459
                    $foundDetails = 1;
-
 
460
                }
-
 
461
            }
-
 
462
            $sth->finish();
-
 
463
        }
-
 
464
        else
-
 
465
        {
-
 
466
            Error("getReleaseDetails:Execute failure", $m_sqlstr );
-
 
467
        }
-
 
468
    }
-
 
469
    else
-
 
470
    {
-
 
471
        Error("getReleaseDetails:Prepare failure" );
-
 
472
    }
-
 
473
 
-
 
474
    Error("getReleaseDetails:No OS Information Found" ) unless $foundDetails;
-
 
475
    
-
 
476
}
-
 
477
 
-
 
478
 
-
 
479
 
-
 
480
#-------------------------------------------------------------------------------
363
# Function        : getOSIDforBOMID
481
# Function        : getOSIDforBOMID
364
#
482
#
365
# Description     : Get all the os_id's associated with a BOMID
483
# Description     : Get all the os_id's associated with a BOMID
366
#
484
#
367
# Inputs          : $bom_id             - BOM to process
485
# Inputs          : $bom_id             - BOM to process
Line 1010... Line 1128...
1010
    my $file = "${fpref}_depends.html";
1128
    my $file = "${fpref}_depends.html";
1011
    push @create_list, $file;
1129
    push @create_list, $file;
1012
    open (DP, ">$file" )  || Error ("Cannot create $file");
1130
    open (DP, ">$file" )  || Error ("Cannot create $file");
1013
 
1131
 
1014
    #
1132
    #
-
 
1133
    #   Generate a header
-
 
1134
    #
-
 
1135
    print DP "<dl><dt><h1>Extraction Details</h1></dt>\n";
-
 
1136
    if ( $opt_sbom_id )
-
 
1137
    {
-
 
1138
        print DP "<dd>SBOM Base</dd>\n";
-
 
1139
        print DP "<dd>Project: $sbom_project</dd>\n";
-
 
1140
        print DP "<dd>BOM    : $sbom_name</dd>\n";
-
 
1141
        print DP "<dd>Branch : $sbom_branch</dd>\n";
-
 
1142
        print DP "<dd>Version: $sbom_version</dd>\n";
-
 
1143
        print DP "<dd>SBOM ID: $opt_sbom_id</dd>\n";
-
 
1144
    }
-
 
1145
 
-
 
1146
    if ( $opt_rtag_id )
-
 
1147
    {
-
 
1148
        getReleaseDetails($opt_rtag_id);
-
 
1149
        print DP "<dd>Release Base</dd>\n";
-
 
1150
        print DP "<dd>Project: $rtag_project</dd>\n";
-
 
1151
        print DP "<dd>Release: $rtag_release</dd>\n";
-
 
1152
        print DP "<dd>RTAG ID: $opt_rtag_id</dd>\n";
-
 
1153
    }
-
 
1154
 
-
 
1155
    print DP "<dd>Root Package: $opt_rootpkg , $opt_rootpkg_version</dd>\n" if ($opt_rootpkg);
-
 
1156
    print DP "</dl>\n";
-
 
1157
 
-
 
1158
    #
1015
    #   Generate an index
1159
    #   Generate an index
1016
    #
1160
    #
1017
    print DP "<dl><dt><h1>Index</h1></dt>\n";
1161
    print DP "<dl><dt><h1>Index</h1></dt>\n";
1018
    print DP "<dd><a href=\"#Ignore\">Ignored Packages</a></dd>\n";
1162
    print DP "<dd><a href=\"#Ignore\">Ignored Packages</a></dd>\n";
1019
    print DP "<dd><a href=\"#Depend\">Dependency Info</a></dd>\n";
1163
    print DP "<dd><a href=\"#Depend\">Dependency Info</a></dd>\n";