common/tools/csvToSysDef.pl
changeset 340 aee074ee2646
parent 335 15307a7772ea
child 341 2ba361491037
equal deleted inserted replaced
339:7297abc8565b 340:aee074ee2646
    50 # For each package in CSV...
    50 # For each package in CSV...
    51 foreach my $package (@packages)
    51 foreach my $package (@packages)
    52 {
    52 {
    53 	# If the sources.csv does not include a sys def for this package, it doesn't get built
    53 	# If the sources.csv does not include a sys def for this package, it doesn't get built
    54 	next unless $package->{sysdef};
    54 	next unless $package->{sysdef};
    55 	warn "Warning: Package $package->{dst} does not appear on the local system\n" unless -d $package->{dst};
    55 	# If it's in the "backup" location, use that one (ie our copy overrides the package's own copy)
    56 	# Look for the pkg defn in the root of the package tree
       
    57 	my $pkgDef = "$package->{dst}/$package->{sysdef}";
    56 	my $pkgDef = "$package->{dst}/$package->{sysdef}";
       
    57 	$pkgDef =~ s{^/sf/}{};
       
    58 	$pkgDef =~ s{/[^/]*$}{};
       
    59 	$pkgDef = "$backupBaseDir/$pkgDef/package_definition.xml";
    58 	if (!-f $pkgDef)
    60 	if (!-f $pkgDef)
    59 	{
    61 	{
    60 		# Not there, so try the "backup" location
    62 		# Not there, so look for the pkg defn in the root of the package tree
    61 		$pkgDef =~ s{^/sf/}{};
    63 		warn "Warning: Package $package->{dst} does not appear on the local system\n" unless -d $package->{dst};
    62 		$pkgDef =~ s{/[^/]*$}{};
    64 		$pkgDef = "$package->{dst}/$package->{sysdef}";
    63 		# TODO: Where will this be on the build machine?
       
    64 		$pkgDef = "$backupBaseDir/$pkgDef/package_definition.xml";
       
    65 	}
    65 	}
    66 	die "Unable to locate any package_definition at all for $package->{dst}" unless -f $pkgDef;
    66 	die "Unable to locate any package_definition at all for $package->{dst}" unless -f $pkgDef;
    67 
    67 
    68 	my $pkgTree = eval { $parser->parsefile($pkgDef) } or die "Failed to parse $pkgDef : $@";
    68 	my $pkgTree = eval { $parser->parsefile($pkgDef) } or die "Failed to parse $pkgDef : $@";
    69 	if (!$outTree)
    69 	if (!$outTree)
    79 }
    79 }
    80 
    80 
    81 #print Data::Dumper->Dump([$outTree->[0]], ["tree"]);
    81 #print Data::Dumper->Dump([$outTree->[0]], ["tree"]);
    82 
    82 
    83 # Output total tree
    83 # Output total tree
    84 print "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
    84 print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    85 printTree($outTree->[0]);
    85 printTree($outTree->[0]);
    86 print "\n";
    86 print "\n";
       
    87 
       
    88 exit;
    87 
    89 
    88 sub mergeTrees
    90 sub mergeTrees
    89 {
    91 {
    90 	my $baseTree = shift or die;
    92 	my $baseTree = shift or die;
    91 	my $extrasTree = shift or die;
    93 	my $extrasTree = shift or die;
   159 		return;
   161 		return;
   160 	}
   162 	}
   161 	
   163 	
   162 	print "<$tagName";
   164 	print "<$tagName";
   163 
   165 
   164 	foreach my $attr (grep { ! ref $tree->{$_} } keys %$tree)
   166 	foreach my $attr (
       
   167 		sort {
       
   168 			my $order = "name long-name tech_domain level span schema levels filter introduced deprecated purpose class plugin origin-model bldFile mrp version priority";
       
   169 			my $ixA = index $order, $a;
       
   170 			my $ixB = index $order, $b;
       
   171 			die "$a $b" if $ixA + $ixB == -2;
       
   172 			$ixA - $ixB;
       
   173 		}
       
   174 		grep {
       
   175 			! ref $tree->{$_}
       
   176 		}
       
   177 		keys %$tree)
   165 	{
   178 	{
   166 		print " $attr=\"$tree->{$attr}\"";
   179 		print " $attr=\"$tree->{$attr}\"";
   167 	}
   180 	}
   168 
   181 
   169 	my $children = $tree->{Kids};
   182 	my $children = $tree->{Kids};