releaseAutomation/packageComparison.pl
changeset 106 be1e3961af1c
parent 105 1350a673dd5f
child 109 8d399d7a7b6b
equal deleted inserted replaced
105:1350a673dd5f 106:be1e3961af1c
    14 # Description:
    14 # Description:
    15 # Automates the creation of part of the PDK Release Notes: "Mercurial Comparison with PDK XXXXX"
    15 # Automates the creation of part of the PDK Release Notes: "Mercurial Comparison with PDK XXXXX"
    16 
    16 
    17 use strict;
    17 use strict;
    18 use XML::Parser;
    18 use XML::Parser;
    19 
    19 use Getopt::Long;
    20 my $sourcesCsv = shift or die "First argument must be sources.csv file for build being built/released\n";
    20 
    21 my $sysDef = shift or die  "Second argument must be system definition file\n";
    21 my $sourcesCsv;		# sources.csv file for this build
    22 my $previousPdkLabel = shift or die "Third argument must be hg tag to compare against\n";
    22 my $sysDef;		# system definition file for this build
    23 defined shift and die "No more than three arguments please\n";
    23 my $previousPdkLabel;	# hg tag to compare against
       
    24 my $prevSourcesCsv;	# sources.csv file for baseline build, if different to this build
       
    25 my $prevSysDef;		# system definition file for baseline build, if different to this build
       
    26 
       
    27 GetOptions((
       
    28 	'sources=s' => \$sourcesCsv,
       
    29 	'sysdef=s' => \$sysDef,
       
    30 	'baseline=s' => \$previousPdkLabel,
       
    31 	'prevSources=s' => \$prevSourcesCsv,
       
    32 	'prevSysdef=s' => \$prevSysDef,
       
    33 ));
       
    34 
       
    35 if (!$sourcesCsv || !$sysDef || !$previousPdkLabel)
       
    36 {
       
    37 	warn "Necessary argument(s) not supplied\n\n";
       
    38 	usage();
       
    39 	exit (1);
       
    40 }
       
    41 
       
    42 if (@ARGV)
       
    43 {
       
    44 	warn "Don't know what to do with these arguments: @ARGV\n\n";
       
    45 	usage();
       
    46 	exit (1);
       
    47 }
       
    48 
       
    49 $prevSourcesCsv ||= $sourcesCsv;
       
    50 $prevSysDef ||= $sysDef;
    24 
    51 
    25 my $packages = { current => {}, previous => {} };
    52 my $packages = { current => {}, previous => {} };
    26 
    53 
    27 # Load current manifest
    54 # Load current manifest
    28 open(my $manifest, "<", $sourcesCsv) or die;
    55 open(my $manifest, "<", $sourcesCsv) or die;
    29 my @manifest = <$manifest>;
    56 my @manifest = <$manifest>;
    30 close $manifest;
    57 close $manifest;
    31 populate($packages->{current}, @manifest);
    58 populate($packages->{current}, @manifest);
    32 
    59 
    33 # Load prev manifest
    60 # Load prev manifest
    34 @manifest = `hg cat -r $previousPdkLabel $sourcesCsv`;
    61 @manifest = `hg cat -r $previousPdkLabel $prevSourcesCsv`;
    35 populate($packages->{previous}, @manifest);
    62 populate($packages->{previous}, @manifest);
    36 
    63 
    37 my $xml = XML::Parser->new(Style => "Objects") or die;
    64 my $xml = XML::Parser->new(Style => "Objects") or die;
    38 # Load current names from current system definition
    65 # Load current names from current system definition
    39 my $tree = $xml->parsefile($sysDef);
    66 my $tree = $xml->parsefile($sysDef);
    40 populateNames($packages->{current}, $tree);
    67 populateNames($packages->{current}, $tree);
    41 # Load previous names from previous system definition
    68 # Load previous names from previous system definition
    42 eval { $tree = $xml->parsestring(scalar `hg cat -r $previousPdkLabel $sysDef`) } or die $!;
    69 eval { $tree = $xml->parsestring(scalar `hg cat -r $previousPdkLabel $prevSysDef`) } or die $!;
    43 populateNames($packages->{previous}, $tree);
    70 populateNames($packages->{previous}, $tree);
    44 
    71 
    45 # Output release note info...
    72 # Output release note info...
    46 
    73 
    47 my $currPackageCount = scalar keys %{$packages->{current}};
    74 my $currPackageCount = scalar keys %{$packages->{current}};
   203 {
   230 {
   204 	my $details = shift;
   231 	my $details = shift;
   205 	$details->{$a}->{sortKey} cmp $details->{$b}->{sortKey};
   232 	$details->{$a}->{sortKey} cmp $details->{$b}->{sortKey};
   206 }
   233 }
   207 
   234 
   208 
   235 sub usage
       
   236 {
       
   237 	warn <<EOT;
       
   238 Generates release notes detail about packages and FCLs used.
       
   239 
       
   240 packageComparison.pl -sources=<SOURCES.CSV> -sysdef=<SYSTEM_DEFINITION.XML> -baseline=<PDK RELEASE LABEL> [-prevSources=<PREV SOURCES.CSV>] [-prevSysdef=<PREV>]
       
   241 
       
   242 EOT
       
   243 }