Subversion Repositories DevTools

Rev

Rev 4546 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4546 Rev 4550
Line 39... Line 39...
39
use JatsSystem;
39
use JatsSystem;
40
use Getopt::Long;
40
use Getopt::Long;
41
use Pod::Usage;
41
use Pod::Usage;
42
use FileUtils;
42
use FileUtils;
43
use JatsEnv;
43
use JatsEnv;
-
 
44
use JatsRmApi;
-
 
45
 
-
 
46
use DBI;
44
 
47
 
45
my $VERSION = "1.0.0";                                      # Update this. Inserted into meta data field
48
my $VERSION = "1.0.0";                                      # Update this. Inserted into meta data field
46
 
49
 
47
# User options
50
# User options
48
my $opt_verbose = 1;
51
my $opt_verbose = 1;
Line 52... Line 55...
52
my $opt_pname;
55
my $opt_pname;
53
my $opt_pversion;
56
my $opt_pversion;
54
my $opt_release_note;
57
my $opt_release_note;
55
my $opt_pvid;
58
my $opt_pvid;
56
my $opt_outname;
59
my $opt_outname;
-
 
60
my $opt_updateRmFiles;
57
 
61
 
58
#   Global vars
62
#   Global vars
59
our $GBE_HOSTNAME;
63
our $GBE_HOSTNAME;
60
our $GBE_TOOLS;
64
our $GBE_TOOLS;
61
my $DPKG_ROOT;
65
my $DPKG_ROOT;
Line 84... Line 88...
84
#
88
#
85
# Returns         :
89
# Returns         :
86
#
90
#
87
{
91
{
88
    my $result = GetOptions (
92
    my $result = GetOptions (
89
                    "help+"         => \$opt_help,          # flag, multiple use allowed
93
                    "help+"         => \$opt_help,              # flag, multiple use allowed
90
                    "manual:3"      => \$opt_help,
94
                    "manual:3"      => \$opt_help,              # flag, set value
91
                    "verbose:+"     => \$opt_verbose,       # flag
95
                    "verbose:+"     => \$opt_verbose,           # flag, increment
92
                    "archive=s"     => \$opt_archive,       # string
96
                    "archive=s"     => \$opt_archive,           # string
93
#                    "pname=s"       => \$opt_pname,         # string
97
#                    "pname=s"       => \$opt_pname,            # string
94
#                    "pversion=s"    => \$opt_pversion,      # string
98
#                    "pversion=s"    => \$opt_pversion,         # string
95
                    "releasenote=s" => \$opt_release_note,  # string
99
                    "releasenote=s" => \$opt_release_note,      # string
-
 
100
                    "UpdateRmFiles" =>  \$opt_updateRmFiles     # flag
96
                    );
101
                    );
97
 
102
 
98
    #
103
    #
99
    #   Process help and manual options
104
    #   Process help and manual options
100
    #
105
    #
Line 220... Line 225...
220
    {
225
    {
221
        Error("Cannot transfer XML release note", $!);
226
        Error("Cannot transfer XML release note", $!);
222
    }
227
    }
223
 
228
 
224
    #
229
    #
-
 
230
    #   Update the Release Manager entry - File Data
-
 
231
    #
-
 
232
    if ($opt_updateRmFiles)
-
 
233
    {
-
 
234
        updateRmFiles();
-
 
235
        updateRmNoteInfo();
-
 
236
    }
-
 
237
 
-
 
238
    #
225
    #   All done
239
    #   All done
226
    #
240
    #
227
    Verbose ("Release Note:", DisplayPath(catdir($DPKG_DOC, $opt_outname)));
241
    Verbose ("Release Note:", DisplayPath(catdir($DPKG_DOC, $opt_outname)));
228
    exit 0;
242
    exit 0;
229
}
243
}
Line 361... Line 375...
361
        if ( exists ($data{path}) && length($data{path}) > 0);
375
        if ( exists ($data{path}) && length($data{path}) > 0);
362
 
376
 
363
    push @generateFileListData, \%data;
377
    push @generateFileListData, \%data;
364
}
378
}
365
 
379
 
-
 
380
#-------------------------------------------------------------------------------
-
 
381
# Function        : updateRmFiles 
-
 
382
#
-
 
383
# Description     : 
-
 
384
#
-
 
385
# Inputs          : 
-
 
386
#
-
 
387
# Returns         : 
-
 
388
#
-
 
389
my $RM_DB;
-
 
390
my  $updateRmFilesData;
-
 
391
sub updateRmFiles
-
 
392
{
-
 
393
    my $eCount = 0;
-
 
394
    #
-
 
395
    #   If in use the the autobuilder - which it should be, then
-
 
396
    #   modify the user name
-
 
397
    #
-
 
398
    #$ENV{GBE_RM_LOCATION} = 'jdbc:oracle:thin:@auperaora07:1521:RELMANU1';
-
 
399
    #$ENV{GBE_RM_USERNAME} = 'build_user'; 
-
 
400
    #$ENV{GBE_RM_PASSWORD} = 'frog123';
-
 
401
 
-
 
402
    $ENV{GBE_RM_LOCATION} = 'jdbc:oracle:thin:@auperaora07:1521:RELMANU1';
-
 
403
    $ENV{GBE_RM_USERNAME} = 'release_manager'; 
-
 
404
    $ENV{GBE_RM_PASSWORD} = 'release_manager';
-
 
405
 
-
 
406
    if ($ENV{ABT})
-
 
407
    {
-
 
408
        $ENV{GBE_RM_USERNAME} = $ENV{GBE_RM_USERNAME} . '[release_manager]'; 
-
 
409
    }
-
 
410
 
-
 
411
    #
-
 
412
    #   Read in the release note data base
-
 
413
    #
-
 
414
    my $rnDataBase = catdir($DPKG_DOC, 'release_note.xml');
-
 
415
    if (! -f $rnDataBase )
-
 
416
    {
-
 
417
        Error("Release Note XML database not found: $!", $rnDataBase);
-
 
418
    }
-
 
419
    my $xml = XMLin($rnDataBase);
-
 
420
 
-
 
421
    #
-
 
422
    #   Sanity Test the data
-
 
423
    #
-
 
424
    Error("Sanity Check Failure. PVID") unless($opt_pvid eq $xml->{package}{pvid});
-
 
425
    Error("Sanity Check Failure. Name") unless($opt_pname eq $xml->{package}{name});
-
 
426
    Error("Sanity Check Failure. Version") unless($opt_pversion eq $xml->{package}{version});
-
 
427
    Error("Sanity Check Failure. File Section") unless(exists $xml->{files}{file});
-
 
428
#    DebugDumpData("XML DATA", \$xml);
-
 
429
 
-
 
430
    #
-
 
431
    #   Delete any existing entry(s)
-
 
432
    #
-
 
433
    updateRmFilesDelete();
-
 
434
 
-
 
435
    #
-
 
436
    #   Scan each entry and pump required data into the RM Database
-
 
437
    #
-
 
438
    $updateRmFilesData = ""; 
-
 
439
    foreach my $entry (@{$xml->{files}{file}})
-
 
440
    {
-
 
441
        #DebugDumpData("Entry", $entry);
-
 
442
 
-
 
443
        #
-
 
444
        #   Clean up the data
-
 
445
        #
-
 
446
        my $fname = $entry->{name} || '';
-
 
447
        my $fpath  = $entry->{path} || '';
-
 
448
        my $fsize  = $entry->{size} || 0;
-
 
449
        my $fmd5  = $entry->{md5sum} || '';
-
 
450
 
-
 
451
        $fpath =~ s~/$~~ unless $fname;
-
 
452
 
-
 
453
        #
-
 
454
        #   Create SQL fragment for the insert
-
 
455
        #
-
 
456
        $eCount++;
-
 
457
        my $entry = " INTO release_manager.release_components ( pv_id, file_name, file_path, byte_size, crc_cksum, crc_modcrc ) " .
-
 
458
                    " VALUES ( $opt_pvid, '$fname', '$fpath',$fsize , '$fmd5', '')";
-
 
459
        $updateRmFilesData .= $entry;
-
 
460
 
-
 
461
        # The size of the aggregation is key to performance
-
 
462
        # Too big is as bad as too small
-
 
463
        if (length($updateRmFilesData) > 10000)
-
 
464
        {
-
 
465
            updateRmFilesInsert();
-
 
466
        }
-
 
467
    }
-
 
468
    updateRmFilesInsert();
-
 
469
    Verbose ("Inserted $eCount entries into Release_Components");
-
 
470
}
-
 
471
 
-
 
472
#-------------------------------------------------------------------------------
-
 
473
# Function        : updateRmFilesInsert 
-
 
474
#
-
 
475
# Description     : Insert entries using the partial SQL statement 
-
 
476
#                   Must be called when the partial SQL buffer get large
-
 
477
#                   as well as at the end to fluch any outstanding inserts
-
 
478
#
-
 
479
# Inputs          : 
-
 
480
#
-
 
481
# Returns         : 
-
 
482
#
-
 
483
sub updateRmFilesInsert
-
 
484
{
-
 
485
    if (length($updateRmFilesData) > 0)
-
 
486
    {
-
 
487
        executeRmQuery(
-
 
488
            'updateRmFilesInsert',
-
 
489
            'INSERT ALL' .$updateRmFilesData . ' SELECT 1 FROM DUAL'
-
 
490
            );
-
 
491
 
-
 
492
        $updateRmFilesData = ""; 
-
 
493
    }
-
 
494
}
-
 
495
#-------------------------------------------------------------------------------
-
 
496
# Function        : updateRmFilesDelete 
-
 
497
#
-
 
498
# Description     : Delete ALL entires in the 'release_components' table associated
-
 
499
#                   with the current pvid
-
 
500
#                   
-
 
501
#                   Needs to be done before new entries are added.    
-
 
502
#
-
 
503
# Inputs          : 
-
 
504
#
-
 
505
# Returns         : 
-
 
506
#
-
 
507
sub updateRmFilesDelete
-
 
508
{
-
 
509
    executeRmQuery(
-
 
510
        'updateRmFilesDelete',
-
 
511
        'delete from release_components where pv_id=' . $opt_pvid
-
 
512
        );
-
 
513
}
-
 
514
 
-
 
515
#-------------------------------------------------------------------------------
-
 
516
# Function        : updateRmNoteInfo 
-
 
517
#
-
 
518
# Description     : Insert Release Note Info into the Release Manager Database
-
 
519
#                   This has the side effect that RM will see the Release Note
-
 
520
#                   as being fully generated.
-
 
521
#
-
 
522
# Inputs          : 
-
 
523
#
-
 
524
# Returns         : 
-
 
525
#
-
 
526
sub updateRmNoteInfo
-
 
527
{
-
 
528
    #
-
 
529
    #   Determine the path to the Release Note in a form that is suitable for the Release Manager
-
 
530
    #   Database. This expects: /dpkg_archive/PkgName/PkgVer/doc/pkgFileName
-
 
531
    #
-
 
532
    my $rnPath = join('/', '', 'dpkg_archive', $opt_pname, $opt_pversion, 'doc', $opt_outname);
-
 
533
    Verbose("RN_INFO:", $rnPath);
-
 
534
 
-
 
535
    # Into the database
-
 
536
    executeRmQuery (
-
 
537
        'updateRmNoteInfo', 
-
 
538
        'update release_manager.package_versions set release_notes_info=\'' . $rnPath . '\' where pv_id=' . $opt_pvid
-
 
539
        );
-
 
540
}
-
 
541
 
-
 
542
#-------------------------------------------------------------------------------
-
 
543
# Function        : executeRmQuery 
-
 
544
#
-
 
545
# Description     : Execute a simple RM query. One that does not expect any return data
-
 
546
#
-
 
547
# Inputs          : $fname           - OprName, for error reporting
-
 
548
#                   $m_sqlstr        - SQL String
-
 
549
#
-
 
550
# Returns         : Will exit on error
-
 
551
#
-
 
552
sub executeRmQuery
-
 
553
{
-
 
554
    my ($fname, $m_sqlstr) = @_;
-
 
555
 
-
 
556
    #
-
 
557
    #   Connect to the Database - once
-
 
558
    #
-
 
559
    connectRM(\$RM_DB, 0) unless $RM_DB;
-
 
560
 
-
 
561
    #
-
 
562
    #   Create the full SQL statement
-
 
563
    #
-
 
564
    my $sth = $RM_DB->prepare($m_sqlstr);
-
 
565
    if ( defined($sth) )
-
 
566
    {
-
 
567
        if ( $sth->execute() )
-
 
568
        {
-
 
569
            $sth->finish();
-
 
570
        }
-
 
571
        else
-
 
572
        {
-
 
573
            Error("$fname: Execute failure: $m_sqlstr", $sth->errstr() );
-
 
574
        }
-
 
575
    }
-
 
576
    else
-
 
577
    {
-
 
578
        Error("$fname: Prepare failure");
-
 
579
    }
-
 
580
}
-
 
581
 
366
 
582
 
367
#-------------------------------------------------------------------------------
583
#-------------------------------------------------------------------------------
368
#   Documentation
584
#   Documentation
369
#
585
#
370
 
586
 
Line 372... Line 588...
372
 
588
 
373
=for htmltoc    SYSUTIL::
589
=for htmltoc    SYSUTIL::
374
 
590
 
375
=head1 NAME
591
=head1 NAME
376
 
592
 
377
jats_get_releasenote_data - Get Release Note Data
593
jats_gen_releasenote - Generate a Release Note
378
 
594
 
379
=head1 SYNOPSIS
595
=head1 SYNOPSIS
380
 
596
 
381
 jats get_releasenote_data [options]
597
 jats jats_gen_releasenote [options]
382
 
598
 
383
 Options:
599
 Options:
384
    -help              - Brief help message
600
    -help              - Brief help message
385
    -help -help        - Detailed help message
601
    -help -help        - Detailed help message
386
    -man               - Full documentation
602
    -man               - Full documentation
387
    -verbose           - Display additional progress messages
603
    -verbose           - Display additional progress messages
388
    -outfile=name      - [Optional] Name of the output XML file
604
    -outfile=name      - [Optional] Name of the output XML file
389
    -archive=name      - [Optional] Name package archive
605
    -archive=name      - [Optional] Name package archive
390
    -releasenote=path  - Path to the Release Note Data
606
    -releasenote=path  - Path to the Release Note Data
-
 
607
    -UpdateRmFiles     - Update the Files list in Release Manager
391
    
608
    
392
 
609
 
393
=head1 OPTIONS
610
=head1 OPTIONS
394
 
611
 
395
=over 8
612
=over 8
Line 419... Line 636...
419
If not provided by the user the output filename will be created in the current directory
636
If not provided by the user the output filename will be created in the current directory
420
and it will be named after the package name and package version.
637
and it will be named after the package name and package version.
421
 
638
 
422
If the filename does not end in .xml, then .xml will be appended to the file name.
639
If the filename does not end in .xml, then .xml will be appended to the file name.
423
 
640
 
-
 
641
=item B<-UpdateRmFiles>
-
 
642
 
-
 
643
This option will case the utility to ppdate the Files list in Release Manager.
-
 
644
 
-
 
645
The existinf file list will be replaced by the one within the package.
-
 
646
 
-
 
647
Note: Write Access to Release Manager is required.
-
 
648
 
424
=back
649
=back
425
 
650
 
426
=head1 DESCRIPTION
651
=head1 DESCRIPTION
427
 
652
 
428
This utility program is used to extract sufficient information from Release Manager and other
653
This utility program is used to extract sufficient information from Release Manager and other