4 # Copyright (c) 2019-2020 TOYOTA MOTOR CORPORATION
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
19 #xpath is slow, so use sed as much as possible
23 main_file=system_launcher_main.xml
24 body_file=system_launcher_body.xml
27 #check xmllint is exist
28 if ! which xmllint > /dev/null ; then
29 echo "It need xmllint. Please install it."
34 if ! which xpath > /dev/null ; then
35 echo "It need xpath Please install it."
40 if ! [[ "$infile" =~ .+\.xml ]] ;then
41 echo "$infile is not *.xml"
43 elif ! [ -e $infile ];then
44 echo "$infile not found"
48 cp -f $infile $body_file
51 if ! xmllint --noout --valid $main_file ;then
52 echo "XML is Invalid. "
56 #Read into memory after shaping with xpath
57 xmem=`xpath -q -e /system_launcher $main_file`
59 echo "# This file is created from $infile."
60 echo "# created date : `LANG=en date`"
61 echo "[ModulesLaunchConfig]"
64 group_num=`echo $xmem | xpath -e /system_launcher/group 2>&1 | grep Found | cut -d ' ' -f2`
68 until [ $cur_group -gt $group_num ];
71 group_text=`echo $xmem | xpath -q -e /system_launcher/group[$cur_group]` #group full XML text
72 group_attr=`echo $group_text | sed 's/\(<group[^>]\+>\)\(.*\)/\1/g'`
74 g_name=`echo $group_attr | sed 's/\(.* name="\)\([^"]*\)\(.*\)/\2/g'`
75 g_wait_time=`echo $group_attr | sed 's/\(.* wait_time="\)\([^"]*\)\(.*\)/\2/g'`
76 g_trigger=`echo $group_attr | sed 's/\(.* trigger="\)\([^"]*\)\(.*\)/\2/g'`
78 # echo $g_name $g_wait_time $g_trigger
79 l_launch_num=`echo $xmem | xpath -e /system_launcher/group[$cur_group]/launch 2>&1 | grep Found | cut -d ' ' -f2`
82 until [ $cur_launch -gt $l_launch_num ]; do
83 launch_text=`echo $xmem | xpath -q -e /system_launcher/group[$cur_group]/launch[$cur_launch]`
85 l_attr="Launch${l_idx}=$g_name|$cur_group|$g_wait_time|$g_trigger"
86 l_attr+="|"`echo $launch_text | sed 's/\(.* name="\)\([^"]*\)\(.*\)/\2/g'`
87 l_attr+="|"`echo $launch_text | sed 's/\(.* path="\)\([^"]*\)\(.*\)/\2/g'`
88 l_attr+="|"`echo $launch_text | sed 's/\(.* priority="\)\([^"]*\)\(.*\)/\2/g'`
89 l_attr+="|"`echo $launch_text | sed 's/\(.* critical="\)\([^"]*\)\(.*\)/\2/g'`
90 l_attr+="|"`echo $launch_text | sed 's/\(.* retry_cnt="\)\([^"]*\)\(.*\)/\2/g'`
91 l_attr+="|"`echo $launch_text | sed 's/\(.* arguments="\)\([^"]*\)\(.*\)/\2/g'`
92 l_attr+="|"`echo $launch_text | sed 's/\(.* logging_mask="\)\([^"]*\)\(.*\)/\2/g'`
93 l_attr+="|"`echo $launch_text | sed 's/\(.* restart="\)\([^"]*\)\(.*\)/\2/g'`
94 l_attr+="|"`echo $launch_text | sed 's/\(.* is_start_required="\)\([^"]*\)\(.*\)/\2/g'`
95 l_attr+="|"`echo $launch_text | sed 's/\(.* shutdown_critical="\)\([^"]*\)\(.*\)/\2/g'`
96 l_attr+="|"`echo $launch_text | sed 's/\(.* shutdown_wait_time="\)\([^"]*\)\(.*\)/\2/g'`
97 l_attr+="|"`echo $launch_text | sed 's/\(.* fast_shutdown_wait_time="\)\([^"]*\)\(.*\)/\2/g'`
98 l_attr+="|"`echo $launch_text | sed 's/\(.* user_name="\)\([^"]*\)\(.*\)/\2/g'`
99 if echo "$launch_text" | grep -sq 'env_cond=' ; then
100 l_attr+="|"`echo $launch_text | sed 's/\(.* env_cond="\)\([^"]*\)\(.*\)/\2/g'`
107 cur_launch=$(($cur_launch+1))
111 cur_group=$(($cur_group+1))