7 my $main_file="launch_order_main.xml";
8 my $body_file="launch_order_body.xml";
12 print STDERR "USAGE:$0 *.order *.cfg\n"
19 my $ret=system("which xmllint > /dev/null");
21 print STDERR "It need xmllint. Please install it.\n";
31 my $launchfile=$ARGV[1];
35 if($infile !~ /.+\.order$/){
36 print STDERR "$infile is not *.order\n";
39 print "$infile not found\n";
44 if($launchfile !~ /.+\.cfg$/){
45 print STDERR "$launchfile is not *.cfg\n";
47 }elsif(! -e $launchfile){
48 print "$launchfile not found\n";
54 system("cp -f $infile $body_file");
57 $ret=system("xmllint --noout --valid $main_file");
59 print STDERR "XML is Invalid. \n";
63 my $date=`LANG=en date`;
64 print "# This file is created from $infile and $launchfile\n";
65 print "# created date : $date\n";
70 open(FIN,"<$launchfile") or die("error :$!");
71 while (my $line = <FIN>){
72 if($line =~ /^Launch/){
73 $line =~ s/^[^|]+=//g;
74 my @args = split(/\|/,$line);
75 $gnamemap{$args[0]}=$args[1];
76 $gidmap{$args[1]}=$args[0];
81 foreach my $key (sort{$a <=> $b} keys(%gidmap)){
82 print "#$key:$gidmap{$key}\n";
86 my $xml = XML::XPath->new(filename=>$main_file);
88 my $orders = $xml->find('/launch_order/order');
89 foreach my $order ($orders->get_nodelist) {
90 my $groups = $order->find('./group');
92 my $oname=$order->findvalue('@oname');
93 my $fixed_group=$order->findvalue('@fixed_group');
98 my %l_gidmap = %gidmap;
101 if($fixed_group ne "NULL"){
102 if(! exists $gnamemap{$fixed_group}){
103 die("$fixed_group not found");
105 foreach my $gid (sort{$a <=> $b} keys(%l_gidmap)){
108 my $str=$l_gidmap{$gid};
109 delete $l_gidmap{$gid};
110 if($str eq $fixed_group){
116 # re-order group via *.order
118 foreach my $group ($groups->get_nodelist) {
119 my $gname=$group->findvalue('@gname');
120 my $waittime=XML::XPath::Number::value($group->findvalue('@waittime'));
122 my $gid=$gnamemap{$gname};
124 if(! exists $gnamemap{$gname}){
125 die("$oname:$gname is not defined");
128 if(! exists $l_gidmap{$gid}){
129 die("$oname:$gname is multiple defined");
134 delete $l_gidmap{$gid};
137 $waitow{$gname} = $waittime;
141 # Output waittime configuration
144 foreach my $gid (sort{$a <=> $b} keys(%l_gidmap)){
150 if(keys(%waitow) > 0 ){
153 foreach my $owgroup ( keys(%waitow)) {
154 print "${sep}oww_${owgroup}";
159 foreach my $owgroup ( keys(%waitow)) {
160 print "oww_${owgroup}=$waitow{$owgroup}\n";