Skip to content

Commit 6683e16

Browse files
committed
[check-config] Search possible files in dir
If we give a dir as argument for check-config, it will treat the dir as a config file, and grep config contents from the dir, and get wrong result, as: | # script/check-config.sh /linux | info: reading kernel config from /linux ... | | Generally Necessary: | - cgroup hierarchy: properly mounted [/sys/fs/cgroup] | - CONFIG_NAMESPACES: missing | - CONFIG_NET_NS: missing | - CONFIG_PID_NS: missing | - CONFIG_IPC_NS: missing | - CONFIG_UTS_NS: missing | - CONFIG_CGROUPS: missing | - CONFIG_CGROUP_CPUACCT: missing | - CONFIG_CGROUP_DEVICE: missing | - CONFIG_CGROUP_FREEZER: missing | - CONFIG_CGROUP_SCHED: missing | ... We can search possible config files in the dir, after patch: | # script/check-config.sh /linux | warning: /linux seems not a kernel config, searching other paths for kernel config ... | info: reading kernel config from /linux/.config ... | | Generally Necessary: | - cgroup hierarchy: properly mounted [/sys/fs/cgroup] | - CONFIG_NAMESPACES: enabled | - CONFIG_NET_NS: enabled | - CONFIG_PID_NS: enabled | - CONFIG_IPC_NS: enabled | - CONFIG_UTS_NS: enabled | - CONFIG_CGROUPS: enabled | - CONFIG_CGROUP_CPUACCT: enabled | - CONFIG_CGROUP_DEVICE: enabled | - CONFIG_CGROUP_FREEZER: enabled | - CONFIG_CGROUP_SCHED: enabled | ... Signed-off-by: Zhao Lei <[email protected]>
1 parent 7b0b628 commit 6683e16

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

script/check-config.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ possibleConfigs=(
1010
"/usr/src/linux-$(uname -r)/.config"
1111
'/usr/src/linux/.config'
1212
)
13-
13+
possibleConfigFiles=(
14+
'config.gz'
15+
"config-$(uname -r)"
16+
'.config'
17+
)
18+
1419
if [ $# -gt 0 ]; then
1520
CONFIG="$1"
1621
else
@@ -110,15 +115,23 @@ check_distro_userns() {
110115
fi
111116
}
112117

113-
if [ ! -e "$CONFIG" ]; then
114-
wrap_warning "warning: $CONFIG does not exist, searching other paths for kernel config ..."
115-
for tryConfig in "${possibleConfigs[@]}"; do
116-
if [ -e "$tryConfig" ]; then
118+
if [ ! -f "$CONFIG" ]; then
119+
wrap_warning "warning: $CONFIG seems not a kernel config, searching other paths for kernel config ..."
120+
for tryConfig in "$CONFIG" "${possibleConfigs[@]}"; do
121+
[[ -d "$tryConfig" ]] && {
122+
for tryFile in "${possibleConfigFiles[@]}"; do
123+
[[ -f "$tryConfig/$tryFile" ]] && {
124+
tryConfig+="/$tryFile"
125+
break
126+
}
127+
done
128+
}
129+
[[ -f "$tryConfig" ]] && {
117130
CONFIG="$tryConfig"
118131
break
119-
fi
132+
}
120133
done
121-
if [ ! -e "$CONFIG" ]; then
134+
if [ ! -f "$CONFIG" ]; then
122135
wrap_warning "error: cannot find kernel config"
123136
wrap_warning " try running this script again, specifying the kernel config:"
124137
wrap_warning " CONFIG=/path/to/kernel/.config $0 or $0 /path/to/kernel/.config"

0 commit comments

Comments
 (0)