-
Notifications
You must be signed in to change notification settings - Fork 4
/
xcommon.sh
executable file
·121 lines (101 loc) · 2.37 KB
/
xcommon.sh
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
XSUPPORTEDVER=23
XREPOADDR=https://github.com/openwrt-xiaomi
XDEFBRANCH=xq-23.05.0
logmsg() {
echo "$@"
}
logerr() {
echo "ERROR: $@" >&2
}
die() {
logerr $@
exit 1
}
#[ ! -d "$XDIR" ] && die "Base directory not defined"
function sed_adapt
{
local str=$( ( echo $1|sed -r 's/([\$\.\*\/\[\\^])/\\\1/g'|sed 's/[]]/\\]/g' )>&1 )
echo "$str"
}
is_nss_repo() {
local FN=$1/package/kernel/mac80211/Makefile
if [ ! -f "$FN" ]; then
return $(false)
fi
if [ $( grep -q "kmod-qca-nss-drv" $FN >/dev/null; echo "$?" ) != "0" ]; then
return $(false)
fi
return $(true)
}
get_cfg_inc_lst() {
local cfg=$1
local k=$( grep -o -P '(?<=^#include ).*' "$cfg" 2> /dev/null )
echo "$k"
}
get_cfg_feed_lst() {
local cfg=$1
local k=$( grep -o -P '(?<=^CONFIG_FEED_).*(?==[y|m])' "$cfg" 2> /dev/null )
echo "$k"
}
get_cfg_feed_url() {
local cfg=$1
local name=$2
local k=$( grep -o -P "(?<=^#GIT_FEED $name=).*" "$cfg" 2> /dev/null )
echo "$k"
}
get_cfg_expkg_lst() {
local cfg=$1
local k=$( grep -o -P '(?<=^#GIT_PACKAGE ).*(?==)' "$cfg" 2> /dev/null )
echo "$k"
}
get_cfg_expkg_url() {
local cfg=$1
local name=$2
local k=$( grep -o -P "(?<=^#GIT_PACKAGE $name=).*" "$cfg" 2> /dev/null )
echo "$k"
}
get_cfg_dis_svc_lst() {
local cfg=$1
local k=$( grep -o -P '(?<=^#DISABLED_SVC=).*' "$cfg" 2> /dev/null )
echo "$k"
}
get_cfg_board() {
local cfg=$1
local k=$( grep -o -P "(?<=^CONFIG_TARGET_)[a-z0-9]+(?==y)" "$cfg" 2> /dev/null )
[ $( echo "$k" | wc -l ) != 1 ] && { echo ""; return 0; }
echo "$k"
}
get_cfg_subtarget() {
local cfg=$1
local board=$2
local k=$( grep -o -P "(?<=^CONFIG_TARGET_"$board"_)[a-z0-9]+(?==y)" "$cfg" 2> /dev/null )
[ $( echo "$k" | wc -l ) != 1 ] && { echo ""; return 0; }
echo "$k"
}
get_cfg_dev_lst() {
local cfg=$1
local board=$2
local subtarget=$3
local k=$( grep -o -P "(?<=^CONFIG_TARGET_"$board"_"$subtarget"_DEVICE_).*(?==y)" "$cfg" 2> /dev/null )
[ $( echo "$k" | wc -l ) != 1 ] && { echo ""; return 0; }
echo "$k"
}
get_cfg_pkg_flag() {
local cfg=$1
local name=$2
local k=$( grep -o -P "(?<=^CONFIG_PACKAGE_$name=).*" "$cfg" 2> /dev/null )
echo "$k"
}
get_cfg_opt_flag() {
local cfg=$1
local name=$2
local k=$( grep -o -P "(?<=^CONFIG_$name=).*" "$cfg" 2> /dev/null )
echo "$k"
}
get_cfg_opt_value() {
local cfg=$1
local name=$2
local k=$( grep -o -P '(?<=^CONFIG_'$name'=").*(?=")' "$cfg" 2> /dev/null )
echo "$k"
}