forked from openwrt-xiaomi/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xcommon.sh
executable file
·85 lines (69 loc) · 1.64 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
#!/bin/bash
XSUPPORTEDVER=21
XREPOADDR=https://github.com/openwrt-xiaomi
XDEFBRANCH=xq-21.02.3
logmsg() {
echo "$@"
}
logerr() {
echo "ERROR: $@" >&2
}
die() {
logerr $@
exit 1
}
#[ ! -d "$XDIR" ] && die "Base directory not defined"
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_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"
}