summaryrefslogtreecommitdiffstats
path: root/systemservice/config/library/system_manager_config/order
diff options
context:
space:
mode:
Diffstat (limited to 'systemservice/config/library/system_manager_config/order')
-rw-r--r--systemservice/config/library/system_manager_config/order/Makefile64
-rw-r--r--systemservice/config/library/system_manager_config/order/launch_order_body.xml0
-rw-r--r--systemservice/config/library/system_manager_config/order/launch_order_main.xml23
-rwxr-xr-xsystemservice/config/library/system_manager_config/order/launch_order_xml2cfg.pl171
-rw-r--r--systemservice/config/library/system_manager_config/order/system_launcher_main.order.cfg3
-rw-r--r--systemservice/config/library/system_manager_config/order/system_launcher_main.xml36
6 files changed, 297 insertions, 0 deletions
diff --git a/systemservice/config/library/system_manager_config/order/Makefile b/systemservice/config/library/system_manager_config/order/Makefile
new file mode 100644
index 00000000..38af0ee2
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/order/Makefile
@@ -0,0 +1,64 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#HOST TOOLS
+HOST_CPP = cpp
+HOST_ORDER_XML2CFG = ./launch_order_xml2cfg.pl
+
+CONF_DIR = $(SDKTARGETSYSROOT)/usr/agl/conf
+CONF_WON_H = $(SDKTARGETSYSROOT)/usr/agl/include/agl_wakeup_order.h
+
+LAUNCH_XMLFILES = $(shell cd $(CONF_DIR)/sm_launch; ls *.xml)
+ORDER_XMLFILES = $(LAUNCH_XMLFILES:%.xml=%.order)
+ORDER_CFGFILES = $(ORDER_XMLFILES:%.order=%.order.cfg)
+
+INST_CONFDIR = $(SDKTARGETSYSROOT)/usr/agl/conf/systemmanager
+
+CLEAN_FILES = launch_order_body.xml $(ORDER_CFGFILES)
+
+VPATH = $(CONF_DIR)/sm_launch
+VPATH += ../xml
+
+install:install-pre install-cfg
+
+install-pre:
+ install -m 644 -t $(DESTDIR)/usr/agl/conf/sm_launch system_launcher_main.xml
+
+install-cfg:$(ORDER_CFGFILES)
+ set -e ;\
+ install -d -m 775 $(INST_CONFDIR) ;\
+ for cfgfile in $(ORDER_CFGFILES);do \
+ install -m 644 -t $(INST_CONFDIR) $$cfgfile;\
+ done ;\
+
+#Create CFG file
+%.order.cfg:%.order %.cfg
+ echo $@
+ set -e; \
+ $(HOST_CPP) $(CPPFLAGS) -P -include $(CONF_WON_H) $< > launch_in.order; \
+ $(HOST_ORDER_XML2CFG) launch_in.order $(filter %.cfg,$+) > $@ ; \
+ rm -fr launch_in.order;
+
+%.order:
+ echo $@
+ set -e; \
+ if [ ! -e $@ ] ; then \
+ touch $@ ; \
+ fi
+
+PHONY:install-cfg
+
+include ../../../../system_service.mk
diff --git a/systemservice/config/library/system_manager_config/order/launch_order_body.xml b/systemservice/config/library/system_manager_config/order/launch_order_body.xml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/order/launch_order_body.xml
diff --git a/systemservice/config/library/system_manager_config/order/launch_order_main.xml b/systemservice/config/library/system_manager_config/order/launch_order_main.xml
new file mode 100644
index 00000000..ee226464
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/order/launch_order_main.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" ?>
+
+<!DOCTYPE launch_order [
+ <!ELEMENT launch_order (order*) >
+
+ <!ELEMENT order (group+) >
+ <!ATTLIST order
+ oname ID #REQUIRED
+ fixed_group CDATA "NULL"
+ >
+
+ <!ELEMENT group EMPTY >
+ <!ATTLIST group
+ gname CDATA #REQUIRED
+ waittime CDATA "0"
+ >
+
+ <!ENTITY launch_order_body SYSTEM "launch_order_body.xml">
+]>
+
+<launch_order>
+ &launch_order_body;
+</launch_order>
diff --git a/systemservice/config/library/system_manager_config/order/launch_order_xml2cfg.pl b/systemservice/config/library/system_manager_config/order/launch_order_xml2cfg.pl
new file mode 100755
index 00000000..10601074
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/order/launch_order_xml2cfg.pl
@@ -0,0 +1,171 @@
+#!/usr/bin/perl -w
+use strict;
+
+use XML::XPath;
+use File::Copy;
+
+my $main_file="launch_order_main.xml";
+my $body_file="launch_order_body.xml";
+
+
+sub usage(){
+ print STDERR "USAGE:$0 *.order *.cfg\n"
+}
+
+
+
+
+#=== MAIN ===
+my $ret=system("which xmllint > /dev/null");
+if($ret != 0){
+ print STDERR "It need xmllint. Please install it.\n";
+ exit 1;
+}
+
+if(2 != @ARGV){
+ usage();
+ exit 1;
+}
+
+my $infile=$ARGV[0];
+my $launchfile=$ARGV[1];
+
+
+#ARG CHECK
+if($infile !~ /.+\.order$/){
+ print STDERR "$infile is not *.order\n";
+ exit 1;
+}elsif(! -e $infile){
+ print "$infile not found\n";
+ usage();
+ exit 1;
+}
+
+if($launchfile !~ /.+\.cfg$/){
+ print STDERR "$launchfile is not *.cfg\n";
+ exit 1;
+}elsif(! -e $launchfile){
+ print "$launchfile not found\n";
+ usage();
+ exit 1;
+}
+
+
+system("cp -f $infile $body_file");
+
+#check xml vaild
+$ret=system("xmllint --noout --valid $main_file");
+if($ret != 0){
+ print STDERR "XML is Invalid. \n";
+ exit 1;
+}
+
+my $date=`LANG=en date`;
+print "# This file is created from $infile and $launchfile\n";
+print "# created date : $date\n";
+
+my %gnamemap;
+my %gidmap;
+
+open(FIN,"<$launchfile") or die("error :$!");
+while (my $line = <FIN>){
+ if($line =~ /^Launch/){
+ $line =~ s/^[^|]+=//g;
+ my @args = split(/\|/,$line);
+ $gnamemap{$args[0]}=$args[1];
+ $gidmap{$args[1]}=$args[0];
+ }
+}
+close(FIN);
+
+foreach my $key (sort{$a <=> $b} keys(%gidmap)){
+ print "#$key:$gidmap{$key}\n";
+}
+
+
+my $xml = XML::XPath->new(filename=>$main_file);
+
+my $orders = $xml->find('/launch_order/order');
+foreach my $order ($orders->get_nodelist) {
+ my $groups = $order->find('./group');
+
+ my $oname=$order->findvalue('@oname');
+ my $fixed_group=$order->findvalue('@fixed_group');
+
+ print "[$oname]\n";
+ print "order=";
+
+ my %l_gidmap = %gidmap;
+ my $sep="";
+ #fix groups
+ if($fixed_group ne "NULL"){
+ if(! exists $gnamemap{$fixed_group}){
+ die("$fixed_group not found");
+ }
+ foreach my $gid (sort{$a <=> $b} keys(%l_gidmap)){
+ print "$sep$gid";
+ $sep="|";
+ my $str=$l_gidmap{$gid};
+ delete $l_gidmap{$gid};
+ if($str eq $fixed_group){
+ last;
+ }
+ }
+ }
+
+ # re-order group via *.order
+ my %waitow;
+ foreach my $group ($groups->get_nodelist) {
+ my $gname=$group->findvalue('@gname');
+ my $waittime=XML::XPath::Number::value($group->findvalue('@waittime'));
+
+ my $gid=$gnamemap{$gname};
+
+ if(! exists $gnamemap{$gname}){
+ die("$oname:$gname is not defined");
+ }
+
+ if(! exists $l_gidmap{$gid}){
+ die("$oname:$gname is multiple defined");
+ }
+
+ print "$sep$gid";
+ $sep="|";
+ delete $l_gidmap{$gid};
+
+ if($waittime > 0){
+ $waitow{$gname} = $waittime;
+ }
+ }
+
+# Output waittime configuration
+
+ #out rest groups
+ foreach my $gid (sort{$a <=> $b} keys(%l_gidmap)){
+ print "$sep$gid";
+ $sep="|";
+ }
+
+ print "\n";
+ if(keys(%waitow) > 0 ){
+ print "owlist=";
+ $sep="";
+ foreach my $owgroup ( keys(%waitow)) {
+ print "${sep}oww_${owgroup}";
+ $sep="|";
+ }
+ print "\n";
+
+ foreach my $owgroup ( keys(%waitow)) {
+ print "oww_${owgroup}=$waitow{$owgroup}\n";
+ }
+
+
+ }
+ print "\n";
+}
+
+
+
+
+
diff --git a/systemservice/config/library/system_manager_config/order/system_launcher_main.order.cfg b/systemservice/config/library/system_manager_config/order/system_launcher_main.order.cfg
new file mode 100644
index 00000000..dc49cd70
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/order/system_launcher_main.order.cfg
@@ -0,0 +1,3 @@
+# This file is created from launch_in.order and system_launcher_main.cfg
+# created date : Tue Aug 29 13:45:54 JST 2017
+
diff --git a/systemservice/config/library/system_manager_config/order/system_launcher_main.xml b/systemservice/config/library/system_manager_config/order/system_launcher_main.xml
new file mode 100644
index 00000000..2dd97d97
--- /dev/null
+++ b/systemservice/config/library/system_manager_config/order/system_launcher_main.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" ?>
+
+<!DOCTYPE system_launcher [
+ <!ELEMENT system_launcher (group+) >
+
+ <!ELEMENT group (launch+) >
+ <!ATTLIST group
+ name CDATA #REQUIRED
+ wait_time CDATA #REQUIRED
+ trigger (True|False) #REQUIRED
+ >
+
+ <!ELEMENT launch EMPTY >
+ <!ATTLIST launch
+ name CDATA #REQUIRED
+ path CDATA #REQUIRED
+ priority CDATA #REQUIRED
+ critical CDATA #REQUIRED
+ retry_cnt CDATA #REQUIRED
+ arguments CDATA #REQUIRED
+ logging_mask CDATA "NULL"
+ restart (me|NULL) #REQUIRED
+ is_start_required (True|False) #REQUIRED
+ shutdown_critical CDATA #REQUIRED
+ shutdown_wait_time CDATA #REQUIRED
+ fast_shutdown_wait_time CDATA #REQUIRED
+ user_name CDATA #REQUIRED
+ env_cond CDATA #IMPLIED
+ >
+
+ <!ENTITY system_launcher_body SYSTEM "system_launcher_body.xml">
+]>
+
+<system_launcher>
+ &system_launcher_body;
+</system_launcher>