common/tools/csvToSysDef.pl
changeset 331 f7c6fc4239ac
parent 330 f2e8947e085a
child 333 7b0a774a0c87
equal deleted inserted replaced
330:f2e8947e085a 331:f7c6fc4239ac
     1 #!perl -w
     1 #!perl -w
     2 
     2 
     3 use strict;
     3 use strict;
       
     4 
       
     5 use FindBin;
       
     6 use lib "$FindBin::Bin/lib";
     4 
     7 
     5 use XML::Parser;
     8 use XML::Parser;
     6 use Data::Dumper;
     9 use Data::Dumper;
     7 use Text::CSV;
    10 use Text::CSV;
     8 
    11 
     9 my $sourcesCSV = shift or die "First arg must be source csv file";
    12 my $sourcesCSV = shift or die "First arg must be source csv file";
    10 shift and die "No more than one argument please";
    13 my $backupBaseDir = shift or die "Second arg must be path to tree of package_definitions to use if not found in the source packages";
       
    14 shift and die "No more than two arguments please";
    11 
    15 
    12 # Load CSV
    16 # Load CSV
    13 open my $csvText, "<", $sourcesCSV or die;
    17 open my $csvText, "<", $sourcesCSV or die;
    14 my $csv = Text::CSV->new();
    18 my $csv = Text::CSV->new();
    15 my @keys;
    19 my @keys;
    53 	{
    57 	{
    54 		# Not there, so try the "backup" location
    58 		# Not there, so try the "backup" location
    55 		$pkgDef =~ s{^/sf/}{};
    59 		$pkgDef =~ s{^/sf/}{};
    56 		$pkgDef =~ s{/[^/]*$}{};
    60 		$pkgDef =~ s{/[^/]*$}{};
    57 		# TODO: Where will this be on the build machine?
    61 		# TODO: Where will this be on the build machine?
    58 		$pkgDef = "../../packages/3k/$pkgDef/package_definition.xml";
    62 		$pkgDef = "$backupBaseDir/$pkgDef/package_definition.xml";
    59 	}
    63 	}
    60 	die unless -f $pkgDef;
    64 	die unless -f $pkgDef;
    61 
    65 
    62 	my $pkgTree = $parser->parsefile($pkgDef) or die;
    66 	my $pkgTree = $parser->parsefile($pkgDef) or die;
    63 	if (!$outTree)
    67 	if (!$outTree)