[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 <zhaolei@cn.fujitsu.com>
This commit is contained in:
parent
7b0b628a9b
commit
6683e16c03
|
@ -10,7 +10,12 @@ possibleConfigs=(
|
||||||
"/usr/src/linux-$(uname -r)/.config"
|
"/usr/src/linux-$(uname -r)/.config"
|
||||||
'/usr/src/linux/.config'
|
'/usr/src/linux/.config'
|
||||||
)
|
)
|
||||||
|
possibleConfigFiles=(
|
||||||
|
'config.gz'
|
||||||
|
"config-$(uname -r)"
|
||||||
|
'.config'
|
||||||
|
)
|
||||||
|
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
CONFIG="$1"
|
CONFIG="$1"
|
||||||
else
|
else
|
||||||
|
@ -110,15 +115,23 @@ check_distro_userns() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -e "$CONFIG" ]; then
|
if [ ! -f "$CONFIG" ]; then
|
||||||
wrap_warning "warning: $CONFIG does not exist, searching other paths for kernel config ..."
|
wrap_warning "warning: $CONFIG seems not a kernel config, searching other paths for kernel config ..."
|
||||||
for tryConfig in "${possibleConfigs[@]}"; do
|
for tryConfig in "$CONFIG" "${possibleConfigs[@]}"; do
|
||||||
if [ -e "$tryConfig" ]; then
|
[[ -d "$tryConfig" ]] && {
|
||||||
|
for tryFile in "${possibleConfigFiles[@]}"; do
|
||||||
|
[[ -f "$tryConfig/$tryFile" ]] && {
|
||||||
|
tryConfig+="/$tryFile"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
[[ -f "$tryConfig" ]] && {
|
||||||
CONFIG="$tryConfig"
|
CONFIG="$tryConfig"
|
||||||
break
|
break
|
||||||
fi
|
}
|
||||||
done
|
done
|
||||||
if [ ! -e "$CONFIG" ]; then
|
if [ ! -f "$CONFIG" ]; then
|
||||||
wrap_warning "error: cannot find kernel config"
|
wrap_warning "error: cannot find kernel config"
|
||||||
wrap_warning " try running this script again, specifying the kernel config:"
|
wrap_warning " try running this script again, specifying the kernel config:"
|
||||||
wrap_warning " CONFIG=/path/to/kernel/.config $0 or $0 /path/to/kernel/.config"
|
wrap_warning " CONFIG=/path/to/kernel/.config $0 or $0 /path/to/kernel/.config"
|
||||||
|
|
Loading…
Reference in New Issue