Subversion Repositories DevTools

Rev

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

Rev 6383 Rev 6391
Line 61... Line 61...
61
my $opt_pvid;
61
my $opt_pvid;
62
my $opt_outname;
62
my $opt_outname;
63
my $opt_outputXml;
63
my $opt_outputXml;
64
my $opt_updateRmFiles;
64
my $opt_updateRmFiles;
65
my $opt_workingDir;
65
my $opt_workingDir;
-
 
66
my $opt_noRM;
66
 
67
 
67
#   Global vars
68
#   Global vars
68
our $GBE_HOSTNAME;
69
our $GBE_HOSTNAME;
69
my $DPKG_ROOT;
70
my $DPKG_ROOT;
70
my $DPKG_DOC;
71
my $DPKG_DOC;
Line 100... Line 101...
100
                    "verbose:+"     => \$opt_verbose,           # flag, increment
101
                    "verbose:+"     => \$opt_verbose,           # flag, increment
101
                    "archive=s"     => \$opt_archive,           # string
102
                    "archive=s"     => \$opt_archive,           # string
102
                    "releasenote=s" => \$opt_release_note,      # string
103
                    "releasenote=s" => \$opt_release_note,      # string
103
                    "UpdateRmFiles" => \$opt_updateRmFiles,     # flag
104
                    "UpdateRmFiles" => \$opt_updateRmFiles,     # flag
104
                    "WorkDir=s"     => \$opt_workingDir,        # String
105
                    "WorkDir=s"     => \$opt_workingDir,        # String
-
 
106
                    "noRM"          => \$opt_noRM,              # Flag
105
                    );
107
                    );
106
 
108
 
107
    #
109
    #
108
    #   Process help and manual options
110
    #   Process help and manual options
109
    #
111
    #
Line 186... Line 188...
186
    #   Locate the release note data file
188
    #   Locate the release note data file
187
    #   This was created as a prerequisite to the build
189
    #   This was created as a prerequisite to the build
188
    #   Note: windows requires '/' in the file list
190
    #   Note: windows requires '/' in the file list
189
    #
191
    #
190
    my @filesList;
192
    my @filesList;
-
 
193
    my $appendGenFiles = 1;
191
    foreach my $item ( glob(catdir($DPKG_ROOT, 'built.files.*.xml'))) {
194
    foreach my $item ( glob(catdir($DPKG_ROOT, 'built.files.*.xml'))) {
192
        $item =~ s~\\~/~g;
195
        $item =~ s~\\~/~g;
193
        push @filesList, $item;
196
        push @filesList, $item;
194
    }
197
    }
195
    unless (scalar @filesList > 0)
198
    unless (scalar @filesList > 0)
196
    {
199
    {
197
        Warning("No file list found within the package: $opt_pname/$opt_pversion");
200
        Warning("No file list found within the package: $opt_pname/$opt_pversion");
-
 
201
        $appendGenFiles = 0;
198
        #
202
        #
199
        #   No filelist found in the package
203
        #   No filelist found in the package
200
        #   This may occur for packages that did not go though the build system
204
        #   This may occur for packages that did not go though the build system
201
        #   Create a package-list
205
        #   Create a package-list
202
        #
206
        #
Line 209... Line 213...
209
    #   Create output directory within the package
213
    #   Create output directory within the package
210
    #
214
    #
211
    mkpath($DPKG_DOC, 0, 0775);
215
    mkpath($DPKG_DOC, 0, 0775);
212
 
216
 
213
    #
217
    #
-
 
218
    #   Generate name of temp file
-
 
219
    #   
-
 
220
    my $builtFiles = 'built.files.releasenote.xml';
-
 
221
    if (defined $opt_workingDir) {
-
 
222
        $builtFiles = join('/', $opt_workingDir, $builtFiles);
-
 
223
    }
-
 
224
    Verbose("TempFile: $builtFiles");
-
 
225
 
-
 
226
    #
214
    #   Merge the Release Note and the various file lists into a single
227
    #   Merge the Release Note and the various file lists into a single
215
    #   XML file. Keep the file local
228
    #   XML file. Keep the file local
216
    #
229
    #
217
    System('--NoShell', '--Exit', 'java', '-jar', 
230
    System('--NoShell', '--Exit', 'java', '-jar', 
218
           catdir($JATS_RN, 'saxon9he.jar'), 
231
           catdir($JATS_RN, 'saxon9he.jar'), 
219
           '-xsl:' . catdir($JATS_RN, 'merge.xslt'),
232
           '-xsl:' . catdir($JATS_RN, 'merge.xslt'),
220
           "-s:$opt_release_note",
233
           "-s:$opt_release_note",
221
           'fileList=' . join(',', @filesList),
234
           'fileList=' . join(',', @filesList),
222
           '-o:' . 'built.files.releasenote.xml'
235
           '-o:' . $builtFiles
223
            );
236
            );
224
 
237
 
225
    #
238
    #
226
    #   Generate the HTML Release Note
239
    #   Generate the HTML Release Note
227
    #   Output directly to the body of the package
240
    #   Output directly to the body of the package
228
    #
241
    #
229
    System('--NoShell', '--Exit', 'java', '-jar', 
242
    System('--NoShell', '--Exit', 'java', '-jar', 
230
           catdir($JATS_RN, 'saxon9he.jar'), 
243
           catdir($JATS_RN, 'saxon9he.jar'), 
231
           '-xsl:' . catdir($JATS_RN, 'releaseNote2html.xslt'),
244
           '-xsl:' . catdir($JATS_RN, 'releaseNote2html.xslt'),
232
           '-s:' . 'built.files.releasenote.xml',
245
           '-s:' . $builtFiles,
233
           "-o:" . catdir($DPKG_DOC, $opt_outname)
246
           "-o:" . catdir($DPKG_DOC, $opt_outname)
234
            );
247
            );
235
 
248
 
236
    #
249
    #
237
    #   Transfer the XML database directly into the package
250
    #   Transfer the XML database directly into the package
238
    #
251
    #
239
    unless( File::Copy::copy('built.files.releasenote.xml', $opt_outputXml) )
252
    unless( File::Copy::copy($builtFiles, $opt_outputXml) ) {
240
    {
-
 
241
        Error("Cannot transfer XML release note", $!, $opt_outputXml);
253
        Error("Cannot transfer XML release note", $!, $opt_outputXml);
242
    }
254
    }
-
 
255
    unlink $builtFiles; 
243
 
256
 
244
    #
257
    #
245
    #   Delete the built.files.xxx.xml that may be present in the root of the package
258
    #   Delete the built.files.xxx.xml that may be present in the root of the package
246
    #   These are no longer needed - they have been incorporated into the release_note.xml file
259
    #   These are no longer needed - they have been incorporated into the release_note.xml file
247
    #
260
    #
Line 252... Line 265...
252
    #
265
    #
253
    #   Update the Release Manager entry - File Data
266
    #   Update the Release Manager entry - File Data
254
    #
267
    #
255
    if ($opt_updateRmFiles)
268
    if ($opt_updateRmFiles)
256
    {
269
    {
-
 
270
        my $genFileData;
-
 
271
        $genFileData = genFileData($opt_outname, 'release_note.xml') if ($appendGenFiles);
-
 
272
 
257
        updateRmFiles();
273
        updateRmFiles($genFileData);
258
        updateRmNoteInfo();
274
        updateRmNoteInfo();
259
    }
275
    }
260
 
276
 
261
    #
277
    #
262
    #   All done
278
    #   All done
Line 300... Line 316...
300
    Verbose("Package Version: $opt_pversion") ;
316
    Verbose("Package Version: $opt_pversion") ;
301
    Verbose("Package Pvid: $opt_pvid") ;
317
    Verbose("Package Pvid: $opt_pvid") ;
302
}
318
}
303
 
319
 
304
#-------------------------------------------------------------------------------
320
#-------------------------------------------------------------------------------
-
 
321
# Function        : genFileData  
-
 
322
#
-
 
323
# Description     : Generate File Data for some locally generated files so that they
-
 
324
#                   will appear in the Release Manager database 
-
 
325
#
-
 
326
# Inputs          : List of files to process
-
 
327
#                   Assumed they are in the $DPKG_DOC directory 
-
 
328
#
-
 
329
# Returns         : An array of data items
-
 
330
#                   Need:
-
 
331
#                       {path}
-
 
332
#                       {name}
-
 
333
#                       {size}
-
 
334
#                       {md5sum}
-
 
335
#                       {fullname}
-
 
336
#                       {type}
-
 
337
#                       {machtype}
-
 
338
#                       {host}
-
 
339
#                   
-
 
340
sub genFileData
-
 
341
{
-
 
342
    my (@fileList) = @_;
-
 
343
    my $retData;
-
 
344
    Verbose('genFileData');
-
 
345
 
-
 
346
    #
-
 
347
    #   Create entry for the 'doc' folder
-
 
348
    #
-
 
349
    {
-
 
350
        my %data;
-
 
351
        $data{fullname} = 'doc';
-
 
352
        $data{path} = 'doc';
-
 
353
        $data{type} = 'dir';
-
 
354
        $data{machtype} = 'unknown';
-
 
355
        $data{host} = $GBE_HOSTNAME;
-
 
356
        push @{$retData},\%data;
-
 
357
    }
-
 
358
 
-
 
359
    #
-
 
360
    #   Process each file
-
 
361
    #
-
 
362
    foreach my $file ( @fileList) {
-
 
363
        my %data;
-
 
364
 
-
 
365
        my $source = catfile($DPKG_DOC, $file);
-
 
366
        $data{md5sum} = genMd5Sum($source);
-
 
367
        $data{size} = (stat($source))[7];
-
 
368
 
-
 
369
        $data{name} = $file;
-
 
370
        $data{fullname} = 'doc/' . $file;
-
 
371
        $data{path} = 'doc/';
-
 
372
        $data{type} = 'file';
-
 
373
        $data{machtype} = 'unknown';
-
 
374
        $data{host} = $GBE_HOSTNAME;
-
 
375
        push @{$retData},\%data;
-
 
376
    }
-
 
377
 
-
 
378
    return $retData;
-
 
379
}
-
 
380
 
-
 
381
#-------------------------------------------------------------------------------
305
# Function        : generateFileList
382
# Function        : generateFileList
306
#                   generateFileListProc 
383
#                   generateFileListProc 
307
#
384
#
308
# Description     : A fileList has not been found in the target package
385
# Description     : A fileList has not been found in the target package
309
#                   Perhaps the package was not created by the build system
386
#                   Perhaps the package was not created by the build system
Line 372... Line 449...
372
        $type = 'link';
449
        $type = 'link';
373
    }
450
    }
374
    elsif ( -f $source)
451
    elsif ( -f $source)
375
    {
452
    {
376
        $type = 'file';
453
        $type = 'file';
377
        Verbose2("Calculate MD5 Digest: $source");
454
        $md5sum = genMd5Sum($source);
378
        open(my $fh , $source) or Error ("Can't open '$source': $!");
-
 
379
        binmode $fh, ':crlf';
-
 
380
        $md5sum = Digest::MD5->new->addfile($fh)->hexdigest;
-
 
381
        close $fh;
-
 
382
    }
455
    }
383
 
456
 
384
    #
457
    #
385
    #   Convert from iso-8859-1 into utf-8
458
    #   Convert from iso-8859-1 into utf-8
386
    #
459
    #
Line 405... Line 478...
405
    $data{fullname} = $target;
478
    $data{fullname} = $target;
406
    $data{type} = $type;
479
    $data{type} = $type;
407
    $data{machtype} = 'unknown';
480
    $data{machtype} = 'unknown';
408
    $data{host} = $GBE_HOSTNAME;
481
    $data{host} = $GBE_HOSTNAME;
409
 
482
 
410
    # Put a nice '/' on the end of the patch elements
483
    # Put a nice '/' on the end of the path elements
411
    $data{path} .= '/'
484
    $data{path} .= '/'
412
        if ( exists ($data{path}) && length($data{path}) > 0);
485
        if ( exists ($data{path}) && length($data{path}) > 0);
413
 
486
 
414
    push @generateFileListData, \%data;
487
    push @generateFileListData, \%data;
415
}
488
}
416
 
489
 
417
#-------------------------------------------------------------------------------
490
#-------------------------------------------------------------------------------
-
 
491
# Function        : genMd5Sum 
-
 
492
#
-
 
493
# Description     : Generate the MD5SUM of a specified file
-
 
494
#
-
 
495
# Inputs          : $source - Full path to file 
-
 
496
#
-
 
497
# Returns         : md5sum of the file
-
 
498
#                   Will not return on error 
-
 
499
#
-
 
500
sub genMd5Sum
-
 
501
{
-
 
502
    my ($source) = @_;
-
 
503
    my $md5sum;
-
 
504
 
-
 
505
    Verbose2("Calculate MD5 Digest: $source");
-
 
506
    open(my $fh , $source) or Error ("Can't open '$source': $!");
-
 
507
    binmode $fh, ':crlf';
-
 
508
    $md5sum = Digest::MD5->new->addfile($fh)->hexdigest;
-
 
509
    close $fh;
-
 
510
 
-
 
511
    return $md5sum;
-
 
512
}
-
 
513
 
-
 
514
#-------------------------------------------------------------------------------
418
# Function        : updateRmFiles 
515
# Function        : updateRmFiles 
419
#
516
#
420
# Description     : 
517
# Description     : 
421
#
518
#
422
# Inputs          : 
519
# Inputs          : $genFileData            - Data for generated files [Optional] 
423
#
520
#
424
# Returns         : 
521
# Returns         : 
425
#
522
#
426
my $RM_DB;
523
my $RM_DB;
427
my  $updateRmFilesData;
524
my  $updateRmFilesData;
428
sub updateRmFiles
525
sub updateRmFiles
429
{
526
{
-
 
527
    my ($genFileData) = @_;
430
    my $eCount = 0;
528
    my $eCount = 0;
431
    #
529
    #
432
    #   If in use the the autobuilder - which it should be, then
530
    #   If in use the the autobuilder - which it should be, then
433
    #   modify the user name to access RM with a proxy user. This is the
531
    #   modify the user name to access RM with a proxy user. This is the
434
    #   same method used in the 'buildtool'
532
    #   same method used in the 'buildtool'
Line 491... Line 589...
491
    Error("Sanity Check Failure. Name") unless($opt_pname eq $xml->{package}{name});
589
    Error("Sanity Check Failure. Name") unless($opt_pname eq $xml->{package}{name});
492
    Error("Sanity Check Failure. Version") unless($opt_pversion eq $xml->{package}{version});
590
    Error("Sanity Check Failure. Version") unless($opt_pversion eq $xml->{package}{version});
493
    Error("Sanity Check Failure. File Section") unless(exists $xml->{file});
591
    Error("Sanity Check Failure. File Section") unless(exists $xml->{file});
494
 
592
 
495
    #
593
    #
-
 
594
    #   Append any additional file data
-
 
595
    #       This will be the doc/ doc/release_note.xml and doc/RELEASE_NOTES.....html
-
 
596
    #
-
 
597
    if ($genFileData) {
-
 
598
        foreach ( @{$genFileData}) {
-
 
599
            push @{$xml->{file}}, $_;
-
 
600
        }
-
 
601
    }
-
 
602
 
-
 
603
    #
496
    #   Delete any existing entry(s)
604
    #   Delete any existing entry(s)
497
    #
605
    #
498
    updateRmFilesDelete();
606
    updateRmFilesDelete();
499
 
607
 
500
    #
608
    #
Line 632... Line 740...
632
sub executeRmQuery
740
sub executeRmQuery
633
{
741
{
634
    my ($fname, $m_sqlstr) = @_;
742
    my ($fname, $m_sqlstr) = @_;
635
 
743
 
636
    #
744
    #
-
 
745
    #   Testing only
-
 
746
    #   Display the Database access commands - don't execute them
-
 
747
    #
-
 
748
    if ($opt_noRM) {
-
 
749
        Debug0("$fname", $m_sqlstr);
-
 
750
        return;
-
 
751
    }
-
 
752
 
-
 
753
    #
637
    #   Connect to the Database - once
754
    #   Connect to the Database - once
638
    #
755
    #
639
    connectRM(\$RM_DB, 0) unless $RM_DB;
756
    connectRM(\$RM_DB, 0) unless $RM_DB;
640
 
757
 
641
    Verbose2('ExecuteQuery:', $fname);
758
    Verbose2('ExecuteQuery:', $fname);
Line 684... Line 801...
684
    -verbose           - Display additional progress messages
801
    -verbose           - Display additional progress messages
685
    -outfile=name      - [Optional] Name of the output XML file
802
    -outfile=name      - [Optional] Name of the output XML file
686
    -archive=name      - [Optional] Name package archive
803
    -archive=name      - [Optional] Name package archive
687
    -releasenote=path  - Path to the Release Note Data
804
    -releasenote=path  - Path to the Release Note Data
688
    -UpdateRmFiles     - Update the Files list in Release Manager
805
    -UpdateRmFiles     - Update the Files list in Release Manager
-
 
806
    -WorkDir=path      - [Test] Path to work area
-
 
807
    -NoRM              - [Test] No RM present
689
    
808
    
690
 
809
 
691
=head1 OPTIONS
810
=head1 OPTIONS
692
 
811
 
693
=over 8
812
=over 8
Line 725... Line 844...
725
 
844
 
726
The existing file list will be replaced by the one within the package.
845
The existing file list will be replaced by the one within the package.
727
 
846
 
728
Note: Write Access to Release Manager is required.
847
Note: Write Access to Release Manager is required.
729
 
848
 
-
 
849
=item B<-WorkDir=Path>
-
 
850
 
-
 
851
This option is provided to aid in testing of this tool. 
-
 
852
 
-
 
853
If provided the tool will use the specified path when creating files.
-
 
854
 
-
 
855
=item B<-NoRM>
-
 
856
 
-
 
857
This option is provided to aid in testing of this tool. 
-
 
858
 
-
 
859
When provided, this option will supress access to the Release Manager database. Instead the
-
 
860
SQL commands will be displayed.
-
 
861
 
730
=back
862
=back
731
 
863
 
732
=head1 DESCRIPTION
864
=head1 DESCRIPTION
733
 
865
 
734
This utility program is used to extract sufficient information from Release Manager and other
866
This utility program is used to extract sufficient information from Release Manager and other