2
2
# process_server.sh 事件处理方法
3
3
#
4
4
5
- #
5
+ # ############################################################################
6
6
# 所有平台都有external_product.txt文件,文件内容特殊 5个字段有顺序,特殊处理
7
7
# inside_model=PRODUCT_MANUFACTURER=product_company=product_hotline=product_email
8
8
#
9
9
# @RET :@1->更新并正常写入文件 @0->已是最新版本无需更新
10
10
#
11
11
# XXX:此方法是在文档中明确说明各个字段为必填选项情况下成立, 而且txt中的顺序不变的情况。这是external_product.txt文件设计的缺陷
12
- #
12
+ # 如果txt的字段增加或者顺序有变,将external_product数组修改即可
13
+ # ############################################################################
13
14
function process_external_product()
14
15
{
15
16
debug_func " process_external_product"
@@ -19,13 +20,16 @@ function process_external_product()
19
20
# 根据内部机型属性从manifest获取对应的键值
20
21
local key_index=" inside_model"
21
22
local key_tmp=$( awk -v var=" $key_index " ' ($2==var){print $1}' $DEVICE_REGISTER_PATH )
22
- local inside_model_value =${manifestmap["$key_tmp"]}
23
- if [ -z " $inside_model_value " ]; then
23
+ local key =${manifestmap["$key_tmp"]}
24
+ if [ -z " $key " ]; then
24
25
debug_error " not exsit 'inside_model'...please ask manifest"
25
26
exit -1
26
27
fi
27
28
28
- local external_product_file=$( awk -v mindex=" $key_index " ' ($2==mindex){print $3}' $DEVICE_REGISTER_PATH )
29
+ local path=$( awk -v mindex=" $key_index " ' ($2==mindex){print $3}' $DEVICE_REGISTER_PATH )
30
+ if [[ -f " $path " ]]; then
31
+ debug_warn " the file->$path is invalid"
32
+ fi
29
33
30
34
# 取第一个字段在manifest查询到的value做为key, 其余字段在manifest中的查询结果拼接后作为为value
31
35
# 两个for,一个是先找到manifest定义的字段,er个然后通过该字段找到对应的value,并使用 = 拼接成一个value
@@ -43,10 +47,10 @@ function process_external_product()
43
47
for var in " ${external_product_tmp[@]} " ; do
44
48
if [[ -n " $var " ]]; then
45
49
if [[ $first -eq 1 ]]; then
46
- local use_var =${manifestmap["$var"]}
50
+ local value =${manifestmap["$var"]}
47
51
first=0
48
52
else
49
- use_var =" ${use_var } =${manifestmap["$var"]} "
53
+ value =" ${value } =${manifestmap["$var"]} "
50
54
fi
51
55
else
52
56
debug_error " is null ?! kidding me ? This is a must write data, please ask manifest"
@@ -55,20 +59,23 @@ function process_external_product()
55
59
done
56
60
57
61
local retep=0
58
- write_txt_file " $external_product_file " " $inside_model_value " " $use_var "
62
+ write_txt_file " $path " " $key " " $value "
59
63
retep=$?
60
- [ $retep -eq 1 ] && git add $path || git checkout $path 2>&1 1> /dev/null
64
+ if [[ -f " $path " ]]; then
65
+ [ $retep -eq 1 ] && git add $path || git checkout $path 2>&1 1> /dev/null
66
+ fi
61
67
62
68
return $retep
63
69
}
64
70
65
- #
71
+ # ############################################################################
66
72
# @PARAM: TODO
67
73
#
74
+ # ############################################################################
68
75
function process_keyboard_layout()
69
76
{
70
- debug_func " process_keyboard_layout"
71
- debug_info $*
77
+ debug_func " process_keyboard_layout $* "
78
+
72
79
if [ -z $1 ] || [ $# -ne 2 ]; then
73
80
debug_error " param is wrong, exit(-1)"
74
81
exit -1
@@ -101,16 +108,16 @@ function process_keyboard_layout()
101
108
return $retkl
102
109
}
103
110
104
- #
111
+ # ############################################################################
105
112
# @RET :@1->更新并正常写入文件 @0->已是最新版本无需更新 @出错处理:直接exit -1退出当前shell进程
106
113
# @FUNC :两点-> 1.检测本地原始配置是否需要更新,满足更新条件则写入文件;2.修改后的本地配置和manifest中的是否达成一致
107
114
#
108
115
# 处理流程 TODO
109
116
#
110
- #
111
- function call_process_server ()
117
+ # ############################################################################
118
+ function process_manifest_event ()
112
119
{
113
- debug_func " call_process_server >>>>>"
120
+ debug_func " process_manifest_event >>>>>"
114
121
115
122
if [[ ! -f " $DEVICE_REGISTER_PATH " ]]; then
116
123
debug_error " $DEVICE_REGISTER_PATH is not exsit, please run 'config_register_path' first, exit (-1)"
@@ -119,21 +126,21 @@ function call_process_server()
119
126
120
127
121
128
122
- # ################################################################################################################################################ #
129
+ # ************************************************************************************************************************************************ #
123
130
# 要兼容一些特殊情况 :1.特殊属性的特殊处理 :如external_product.txt文件内容的格式定义的很独特,特殊处理
124
131
# 2.不同平台下的特殊处理 :如红外遥控配置的kl文件的命名方式有不同,有些兼容android通用平台,有些平台厂商有自定义的命名处理规则
125
132
# 3.等待以后遇到添加
126
133
#
127
134
# 其它共性情况统一处理 :如mk文件的操作等是具有简单的key-value对应填写关系的
128
135
#
129
136
# 另外注意返回值的判定 :bash 不支持位运算,仅支持逻辑运算; 此处使用0+0+0+0==0方式判定最后的累计结果
130
- # ################################################################################################################################################ #
137
+ # ************************************************************************************************************************************************ #
131
138
132
139
133
140
134
141
local retflag=0
135
142
136
- # #---external product----#
143
+ # #---1. external product----#
137
144
process_external_product
138
145
let retflag=retflag+$?
139
146
@@ -154,7 +161,7 @@ function call_process_server()
154
161
debug_warn " Not yet register this '$key ' in 'DEVICE_REGISTER_PATH'"
155
162
fi
156
163
157
- # #---keyboad layout---#
164
+ # #---2. keyboad layout---#
158
165
if [[ " $prop " == " customer_code" ]]; then
159
166
continue
160
167
elif [[ " ${key: 0: 2} " == " 0x" ]]; then
@@ -165,7 +172,7 @@ function call_process_server()
165
172
continue
166
173
fi
167
174
168
- # #---如果还有例外事件,add the Exception Event Function here ---#
175
+ # #---3. 如果还有例外事件 XXX ,add the Exception Event Function Here, and add a black list Below ---#
169
176
170
177
171
178
# ---black list---#
@@ -179,7 +186,7 @@ function call_process_server()
179
186
continue
180
187
fi
181
188
182
- # #---normal event---#
189
+ # #---n. normal event---#
183
190
local path=$( echo " $pp " | awk ' {print $2}' )
184
191
local value=${manifestmap["$key"]}
185
192
debug_import " $key " , " $prop , $path " , " 是[ ${path##* .} ]类型文件"
@@ -201,19 +208,18 @@ function call_process_server()
201
208
if [[ -f " $path " ]]; then
202
209
[ $retnormal -eq 1 ] && git add $path || git checkout $path
203
210
else
204
- debug_warn " the '$key ' de path->$path is not exsit"
211
+ debug_warn " the '$key '\` s path->$path is not exsit"
205
212
fi
206
213
207
214
let retflag=retflag+$retnormal
208
215
done
209
216
210
- debug_func " call_process_server <<<<<"
217
+ debug_func " process_manifest_event <<<<<"
211
218
212
219
[ $retflag -eq 0 ] && return 0 || return 1
213
220
}
214
-
215
221
# 测试用例
216
222
# #!/bin/bash
217
223
# . ./include.sh
218
224
# . ./edit_util.sh
219
- # call_process_server
225
+ # process_manifest_event
0 commit comments