Subversion Repositories DevTools

Rev

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

Rev 6116 Rev 6383
Line 30... Line 30...
30
use Pod::Usage;
30
use Pod::Usage;
31
use Getopt::Long;
31
use Getopt::Long;
32
use XML::Simple;
32
use XML::Simple;
33
use File::Path;
33
use File::Path;
34
use File::Copy;
34
use File::Copy;
35
use XML::Simple;
35
use XML::LibXML;
36
use Digest::MD5;
36
use Digest::MD5;
37
use File::Find;
37
use File::Find;
38
use FindBin;                                # Determine the current directory
38
use FindBin;                                # Determine the current directory
39
use Encode qw(decode encode);
39
use Encode qw(decode encode);
40
 
40
 
Line 274... Line 274...
274
#
274
#
275
# Returns         : Populates global variables 
275
# Returns         : Populates global variables 
276
#
276
#
277
sub processReleaseNote
277
sub processReleaseNote
278
{
278
{
279
    my $xml = XMLin($opt_release_note);
-
 
280
 
-
 
281
    foreach my $item ( qw (name version pvid) ) {
-
 
282
        Error("Unexpected ReleaseNote format: package $item")
-
 
283
            unless (exists $xml->{package}{$item});
-
 
284
    }
-
 
285
 
279
 
-
 
280
    #
-
 
281
    #   Extract essential information
-
 
282
    #   
-
 
283
    my $xml;
-
 
284
    my $parser = XML::LibXML->new();
-
 
285
    my $doc    = $parser->parse_file($opt_release_note);
-
 
286
 
-
 
287
    #
-
 
288
    #   Extract the 'package' data
-
 
289
    #   Only expect one of them
-
 
290
    #   
-
 
291
    my @nodes = $doc->findnodes('/package_data/package');
-
 
292
    my $node = $nodes[0];
-
 
293
    Error ("Package section not found in $opt_release_note") unless defined $node;
-
 
294
 
286
    $opt_pname = $xml->{package}{name};
295
    $opt_pname    = $node->getAttribute( 'name' );
287
    $opt_pversion = $xml->{package}{version};
296
    $opt_pversion = $node->getAttribute( 'version' );
288
    $opt_pvid = $xml->{package}{pvid};
297
    $opt_pvid     = $node->getAttribute( 'pvid' );
289
    
298
    
290
    Verbose("Package Name: $opt_pname") ;
299
    Verbose("Package Name: $opt_pname") ;
291
    Verbose("Package Version: $opt_pversion") ;
300
    Verbose("Package Version: $opt_pversion") ;
292
    Verbose("Package Pvid: $opt_pvid") ;
301
    Verbose("Package Pvid: $opt_pvid") ;
293
}
302
}
Line 436... Line 445...
436
    my $rnDataBase = catdir($DPKG_DOC, 'release_note.xml');
445
    my $rnDataBase = catdir($DPKG_DOC, 'release_note.xml');
437
    if (! -f $rnDataBase )
446
    if (! -f $rnDataBase )
438
    {
447
    {
439
        Error("Release Note XML database not found: $!", $rnDataBase);
448
        Error("Release Note XML database not found: $!", $rnDataBase);
440
    }
449
    }
-
 
450
 
-
 
451
    #
-
 
452
    #   Extract essential information
-
 
453
    #   Don't use a simple parser - its gets it wrong
-
 
454
    #   
-
 
455
    my $xml;
441
    my $xml = XMLin($rnDataBase);
456
    my $parser = XML::LibXML->new();
-
 
457
    my $doc    = $parser->parse_file($rnDataBase);
-
 
458
 
-
 
459
    #
-
 
460
    #   Extract the 'package' data
-
 
461
    #   Only expect one of them
-
 
462
 
-
 
463
    my @nodes = $doc->findnodes('/package_data/package');
-
 
464
    my $node = $nodes[0];
-
 
465
    Error ("Package section not found in $rnDataBase") unless defined $node;
-
 
466
 
-
 
467
    my %eldata;
-
 
468
    foreach my $atr ($node->findnodes( "./@*")) {     
-
 
469
        Debug("Package Data:" .  $atr->nodeName() . ":" . $atr->value);
-
 
470
        $xml->{package}{$atr->nodeName} = $atr->value;
-
 
471
    }
-
 
472
 
-
 
473
    #
-
 
474
    #   Extract the file data
-
 
475
    #   Tricky - needs to be an array
-
 
476
    #
-
 
477
    foreach my $element ($doc->findnodes('/package_data/files/file')) {
-
 
478
       my %eldata;
-
 
479
       foreach my $node ($element->findnodes( "./@*")) {     
-
 
480
           Debug("File:" .  $node->nodeName() . ":" . $node->value);
-
 
481
           $eldata{$node->nodeName} = $node->value;
-
 
482
       }
-
 
483
       push @{$xml->{file}}, \%eldata;
-
 
484
    }
-
 
485
    #DebugDumpData("XML DATA", $xml);
442
 
486
 
443
    #
487
    #
444
    #   Sanity Test the data
488
    #   Sanity Test the data
445
    #
489
    #
446
    Error("Sanity Check Failure. PVID") unless($opt_pvid eq $xml->{package}{pvid});
490
    Error("Sanity Check Failure. PVID") unless($opt_pvid eq $xml->{package}{pvid});
447
    Error("Sanity Check Failure. Name") unless($opt_pname eq $xml->{package}{name});
491
    Error("Sanity Check Failure. Name") unless($opt_pname eq $xml->{package}{name});
448
    Error("Sanity Check Failure. Version") unless($opt_pversion eq $xml->{package}{version});
492
    Error("Sanity Check Failure. Version") unless($opt_pversion eq $xml->{package}{version});
449
    Error("Sanity Check Failure. File Section") unless(exists $xml->{files}{file});
493
    Error("Sanity Check Failure. File Section") unless(exists $xml->{file});
450
    #DebugDumpData("XML DATA", \$xml);
-
 
451
 
494
 
452
    #
495
    #
453
    #   Delete any existing entry(s)
496
    #   Delete any existing entry(s)
454
    #
497
    #
455
    updateRmFilesDelete();
498
    updateRmFilesDelete();
456
 
499
 
457
    #
500
    #
458
    #   Scan each entry and pump required data into the RM Database
-
 
459
    #   The {files}{file} may be either an array or a hash XMLin appears to
-
 
460
    #   make some decision as to which it will be, and I can't control it
-
 
461
    #
-
 
462
    #   If its a HASH, then it may be a HASH of HASH or a single entry
-
 
463
    #
-
 
464
    #   When it does happen the hash key is the 'name' element
-
 
465
    #
-
 
466
    if (ref($xml->{files}{file}) eq 'HASH')
-
 
467
    {
-
 
468
        Verbose("Convert file hash to an array");
-
 
469
        my @nowArray;
-
 
470
        foreach my $name ( keys %{$xml->{files}{file}})
-
 
471
        {
-
 
472
            my $entry = $xml->{files}{file}{$name};
-
 
473
            if (ref($entry) eq 'HASH')
-
 
474
            {
-
 
475
                $entry->{name} = $name;
-
 
476
                push @nowArray, $entry;
-
 
477
            }
-
 
478
            else
-
 
479
            {
-
 
480
                # Its a single entry, not a HASH of entries
-
 
481
                push @nowArray, $xml->{files}{file};
-
 
482
                last; 
-
 
483
            }
-
 
484
        }
-
 
485
        $xml->{files}{file} = \@nowArray
-
 
486
    }
-
 
487
    Error("Sanity Check Failure. File Section not an ARRAY") unless(ref($xml->{files}{file}) eq 'ARRAY');
-
 
488
 
-
 
489
    #
-
 
490
    #   Release Manager Database will barf if there are duplicate entries
501
    #   Release Manager Database will barf if there are duplicate entries
491
    #   Maintain a hash of items processed, and only process each once
502
    #   Maintain a hash of items processed, and only process each once
492
    #
503
    #
493
    my %fullNameSeen;
504
    my %fullNameSeen;
494
 
505
 
495
    $updateRmFilesData = ""; 
506
    $updateRmFilesData = "";
496
    foreach my $entry (@{$xml->{files}{file}})
507
    foreach my $entry (@{$xml->{file}})
497
    {
508
    {
498
        #
509
        #
499
        #   Ignore 'merge' entries
510
        #   Ignore 'merge' entries
500
        #
511
        #
501
        next if ((exists $entry->{type}) && ($entry->{type} eq 'merge'));
512
        next if ((exists $entry->{type}) && ($entry->{type} eq 'merge'));