mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 18:11:35 +00:00
projects: be more clever about merging kernel config
In particular, let's start with a defconfig and edit it, rather than try to generate the config entirely from our own diff. Signed-off-by: Tycho Andersen <tycho@docker.com>
This commit is contained in:
parent
e60f9d3946
commit
ee4d74aca6
@ -6,33 +6,43 @@ ARCH=$1
|
|||||||
KERNEL_SERIES=$2
|
KERNEL_SERIES=$2
|
||||||
DEBUG=$3
|
DEBUG=$3
|
||||||
|
|
||||||
defconfig=defconfig
|
cd /linux && make defconfig
|
||||||
if [ "${ARCH}" == "x86" ]; then
|
|
||||||
defconfig=x86_64_defconfig
|
|
||||||
fi
|
|
||||||
configpath="/linux/arch/${ARCH}/configs/${defconfig}"
|
|
||||||
|
|
||||||
cp /config/kernel_config.base "$configpath"
|
function merge_config()
|
||||||
|
|
||||||
function append_config()
|
|
||||||
{
|
{
|
||||||
config=$1
|
config=$1
|
||||||
|
if [ ! -f "$config" ]; then
|
||||||
if [ -f "$config" ]; then
|
return
|
||||||
cat "$config" >> "$configpath"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# A slightly more intelligent merge algorithm: rather than just catting
|
||||||
|
# files together (and getting random results), let's explicitly delete the
|
||||||
|
# old setting, and then insert our new one.
|
||||||
|
while read line; do
|
||||||
|
if echo ${line} | grep "is not set" >/dev/null; then
|
||||||
|
cfg=$(echo ${line/ is not set/} | cut -c3-)
|
||||||
|
else
|
||||||
|
cfg=$(echo ${line} | cut -f1 -d=)
|
||||||
|
fi
|
||||||
|
|
||||||
|
sed -i -e "/${cfg} is not set/d" -e "/${cfg}=/d" /linux/.config
|
||||||
|
echo ${line} >> /linux/.config
|
||||||
|
done < "$config"
|
||||||
}
|
}
|
||||||
|
|
||||||
append_config "/config/kernel_config.${ARCH}"
|
cd /linux && make defconfig && make oldconfig
|
||||||
append_config "/config/kernel_config.${KERNEL_SERIES}"
|
|
||||||
append_config "/config/kernel_config.${ARCH}.${KERNEL_SERIES}"
|
merge_config "/config/kernel_config.base"
|
||||||
|
merge_config "/config/kernel_config.${ARCH}"
|
||||||
|
merge_config "/config/kernel_config.${KERNEL_SERIES}"
|
||||||
|
merge_config "/config/kernel_config.${ARCH}.${KERNEL_SERIES}"
|
||||||
|
|
||||||
if [ -n "${DEBUG}" ]; then
|
if [ -n "${DEBUG}" ]; then
|
||||||
sed -i sed -i 's/CONFIG_PANIC_ON_OOPS=y/# CONFIG_PANIC_ON_OOPS is not set/' /linux/arch/x86/configs/x86_64_defconfig
|
sed -i sed -i 's/CONFIG_PANIC_ON_OOPS=y/# CONFIG_PANIC_ON_OOPS is not set/' /linux/arch/x86/configs/x86_64_defconfig
|
||||||
append_config "/config/kernel_config.debug"
|
append_config "/config/kernel_config.debug"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /linux && make defconfig && make oldconfig
|
cd /linux && make oldconfig
|
||||||
|
|
||||||
# Let's make sure things are the way we want, i.e. every option we explicitly
|
# Let's make sure things are the way we want, i.e. every option we explicitly
|
||||||
# set is set the same way in the resulting config.
|
# set is set the same way in the resulting config.
|
||||||
@ -42,7 +52,18 @@ function check_config()
|
|||||||
|
|
||||||
while read line; do
|
while read line; do
|
||||||
if [ -n "${DEBUG}" ] && [ "$line" == "CONFIG_PANIC_ON_OOPS=y" ]; then continue; fi
|
if [ -n "${DEBUG}" ] && [ "$line" == "CONFIG_PANIC_ON_OOPS=y" ]; then continue; fi
|
||||||
grep "^${line}$" /linux/.config >/dev/null || (echo "$line set incorrectly" && false)
|
value="$(grep "^${line}$" /linux/.config || true)"
|
||||||
|
|
||||||
|
# It's okay to for the merging script to have simply not listed values we
|
||||||
|
# require to be unset.
|
||||||
|
if echo "${line}" | grep "is not set" >/dev/null && [ "$value" = "" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [ "${value}" = "${line}" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$line set incorrectly" && false
|
||||||
done < $1
|
done < $1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user