-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfind-configs.sh
More file actions
executable file
·131 lines (112 loc) · 2.18 KB
/
find-configs.sh
File metadata and controls
executable file
·131 lines (112 loc) · 2.18 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
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
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
FILES="./Kconfig"
CONFIGS=
ARCHES="aarch64
ppc64le
s390x
x86_64"
usage()
{
echo "find-configs <arch> [-t|--toplevel] [-h|--help]"
}
validate_arch()
{
for a in $ARCHES; do
[ "$a" = "$arch" ] && return
done
echo "invalid arch: $arch"
echo "valid arches:" $ARCHES
usage && exit
}
set_vars()
{
local top=$(git rev-parse --show-toplevel)
local dir=$(pwd)
PREFIX=${dir#${top}/}
[ -z "$PREFIX" ] && echo "unable to determine PREFIX" && exit
CONFIG_FILE=$(ls ${top}/redhat/configs/kernel-*-${arch}.config 2>/dev/null)
[ -z "$CONFIG_FILE" ] && echo "unable to determine config file" && exit
}
find_files()
{
results=$(find . -name Kconfig | grep -vF "./Kconfig")
for result in $results; do
[ -z "$FILES" ] && FILES="$result" || FILES="$FILES $result"
done
}
parse_file_configs()
{
results=$(grep "^config\|^menuconfig" $1 | awk '{print $2}')
for result in $results; do
config="CONFIG_${result}"
[ -z "$CONFIGS" ] && CONFIGS="$config" || CONFIGS="$CONFIGS $config"
done
}
parse_files()
{
for file in $FILES; do
parse_file_configs $file
done
}
check_for_missing_file()
{
local file
for file in $FILES; do
[ "$1" = "$file" ] && return
done
# this should never happen :-)
echo "MISSING: $1"
exit
}
find_includes()
{
local result
local results=$(grep "^source" $1 | awk '{print $2}' | tr -d '"')
for result in $results; do
local path=${result#${PREFIX}}
path=".${path}"
check_for_missing_file $path
done
}
find_missing_files()
{
local file
for file in $FILES; do
find_includes $file
done;
}
check_configs()
{
for config in $CONFIGS; do
result=$(grep "$config \|$config\=" $CONFIG_FILE)
if [ -z "$result" ]; then
echo "$config does not exist"
else
echo "$result"
fi
done
}
arch=
search=true
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-h|--help)
usage && exit;
;;
-t|--toplevel)
search=false
;;
*)
[ ! -z "$arch" ] && usage && exit
arch=$key
;;
esac
shift
done
validate_arch
set_vars
[ "$search" = "true" ] && find_files
parse_files
[ "$search" = "true" ] && find_missing_files
check_configs