-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.sh
More file actions
executable file
·47 lines (40 loc) · 1.4 KB
/
parser.sh
File metadata and controls
executable file
·47 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# read input file and get only content of "script_run"
while read line; do
if [[ $line =~ "script_run" ]]; then
cmd=$(echo $line | grep -v sub | sed 's/\s*\(script_run\|assert_script_run\|assert_script_run_qemu\)\s*//g;s/\(\s\)\s*/\1/g'| sed 's/;$//g' | tr -d "'\"()")
cmd_array=("${cmd_array[@]}" "$cmd")
fi
done < $1
array_size=${#cmd_array[@]}
# discount one, so shell does not return empty position
let array_size--
# get only cmds, not parameters
for j in $(seq 0 $array_size); do
if [[ ${cmd_array[$j]} =~ ";" ]]; then
temp=$(echo ${cmd_array[@]} | tr ";" "\n" | sed 's/^ //g' | cut -d " " -f 1 | grep [a-zA-Z])
for entry in $temp; do
temp_list=("${temp_list[@]}" "$entry")
done
else
temp=$(echo ${cmd_array[j]} | sed 's/^ //g' | cut -d " " -f 1 | grep [a-zA-Z])
temp_list=("${temp_list[@]}" "$temp")
fi
done
# need more smart way to do this
for v in ${temp_list[@]}; do
if [[ ! ${final_list[@]} =~ "$v" ]]; then
final_list=("${final_list[@]}" "$v")
fi
done
# refresh repo
zypper ref
# install scout to determine app path
if ! test -x /usr/bin/scout; then
zypper --non-interactive install -y scout
fi
for cmd in ${final_list[@]}; do
exe=$(scout bin $cmd | cut -d "|" -f 2 | grep -v package | grep [a-zA-Z] | tr -d " " | uniq)
exe_list=("${exe_list[@]}" "$cmd:$exe")
done
echo ${exe_list[@]}