3 # @copyright Copyright (c) 2019 TOYOTA MOTOR CORPORATION.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 #Since xpath is slow, use sed as much as possible.
21 main_file=system_launcher_main.xml
22 body_file=system_launcher_body.xml
25 #check xmllint is exist
26 if ! which xmllint > /dev/null ; then
27 echo "It need xmllint. Please install it."
32 if ! which xpath > /dev/null ; then
33 echo "It need xpath Please install it."
38 if ! [[ "$infile" =~ .+\.xml ]] ;then
39 echo "$infile is not *.xml"
41 elif ! [ -e $infile ];then
42 echo "$infile not found"
46 cp -f `dirname $0`/$main_file `dirname $1`
47 cp -f $infile $body_file
50 if ! xmllint --noout --valid $main_file ;then
51 echo "XML is Invalid. "
55 #Format into xpath and read into memory
56 xmem=`xpath -q -e /system_launcher $main_file`
58 echo "# This file is created from $infile."
59 echo "# created date : `LANG=en date`"
60 echo "[ModulesLaunchConfig]"
63 group_num=`echo $xmem | xpath -e /system_launcher/group 2>&1 | grep Found | cut -d ' ' -f2`
67 until [ $cur_group -gt $group_num ];
70 group_text=`echo $xmem | xpath -q -e /system_launcher/group[$cur_group]` #ALL XML text for group
71 group_attr=`echo $group_text | sed 's/\(<group[^>]\+>\)\(.*\)/\1/g'`
73 g_name=`echo $group_attr | sed 's/\(.* name="\)\([^"]*\)\(.*\)/\2/g'`
74 g_wait_time=`echo $group_attr | sed 's/\(.* wait_time="\)\([^"]*\)\(.*\)/\2/g'`
75 g_trigger=`echo $group_attr | sed 's/\(.* trigger="\)\([^"]*\)\(.*\)/\2/g'`
77 # echo $g_name $g_wait_time $g_trigger
78 l_launch_num=`echo $xmem | xpath -e /system_launcher/group[$cur_group]/launch 2>&1 | grep Found | cut -d ' ' -f2`
81 until [ $cur_launch -gt $l_launch_num ]; do
82 launch_text=`echo $xmem | xpath -q -e /system_launcher/group[$cur_group]/launch[$cur_launch]`
84 l_attr="Launch${l_idx}=$g_name|$cur_group|$g_wait_time|$g_trigger"
85 l_attr+="|"`echo $launch_text | sed 's/\(.* name="\)\([^"]*\)\(.*\)/\2/g'`
86 l_attr+="|"`echo $launch_text | sed 's/\(.* path="\)\([^"]*\)\(.*\)/\2/g'`
87 l_attr+="|"`echo $launch_text | sed 's/\(.* priority="\)\([^"]*\)\(.*\)/\2/g'`
88 l_attr+="|"`echo $launch_text | sed 's/\(.* critical="\)\([^"]*\)\(.*\)/\2/g'`
89 l_attr+="|"`echo $launch_text | sed 's/\(.* retry_cnt="\)\([^"]*\)\(.*\)/\2/g'`
90 l_attr+="|"`echo $launch_text | sed 's/\(.* arguments="\)\([^"]*\)\(.*\)/\2/g'`
91 l_attr+="|"`echo $launch_text | sed 's/\(.* logging_mask="\)\([^"]*\)\(.*\)/\2/g'`
92 l_attr+="|"`echo $launch_text | sed 's/\(.* restart="\)\([^"]*\)\(.*\)/\2/g'`
93 l_attr+="|"`echo $launch_text | sed 's/\(.* is_start_required="\)\([^"]*\)\(.*\)/\2/g'`
94 l_attr+="|"`echo $launch_text | sed 's/\(.* shutdown_critical="\)\([^"]*\)\(.*\)/\2/g'`
95 l_attr+="|"`echo $launch_text | sed 's/\(.* shutdown_wait_time="\)\([^"]*\)\(.*\)/\2/g'`
96 l_attr+="|"`echo $launch_text | sed 's/\(.* fast_shutdown_wait_time="\)\([^"]*\)\(.*\)/\2/g'`
97 l_attr+="|"`echo $launch_text | sed 's/\(.* user_name="\)\([^"]*\)\(.*\)/\2/g'`
98 if echo "$launch_text" | grep -sq 'is_agl_unit=' ; then
99 l_attr+="|"`echo $launch_text | sed 's/\(.* is_agl_unit="\)\([^"]*\)\(.*\)/\2/g'`
103 if echo "$launch_text" | grep -sq 'disable_agl_resethistory=' ; then
104 l_attr+="|"`echo $launch_text | sed 's/\(.* disable_agl_resethistory="\)\([^"]*\)\(.*\)/\2/g'`
108 if echo "$launch_text" | grep -sq 'disable_nonagl_resethistory=' ; then
109 l_attr+="|"`echo $launch_text | sed 's/\(.* disable_nonagl_resethistory="\)\([^"]*\)\(.*\)/\2/g'`
113 if echo "$launch_text" | grep -sq 'env_cond=' ; then
114 l_attr+="|"`echo $launch_text | sed 's/\(.* env_cond="\)\([^"]*\)\(.*\)/\2/g'`
119 if echo "$launch_text" | grep -sq 'cpu_assign=' ; then
120 l_attr+="|"`echo $launch_text | sed 's/\(.* cpu_assign="\)\([^"]*\)\(.*\)/\2/g'`
127 cur_launch=$(($cur_launch+1))
131 cur_group=$(($cur_group+1))