From bc34d530f4a21b5f06228d626f446c617b9c8876 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sun, 24 May 2015 12:01:06 +0200 Subject: Add example that mirrors defconfig and oldconfig. From https://github.com/ulfalizer/Kconfiglib/issues/15. Getting the output to match up exactly requires emulating each step, due to Kconfig subtleties related to which symbols have been assigned values by the user. The output might differ with other approaches, but this is not a bug. --- examples/defconfig_oldconfig.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/defconfig_oldconfig.py (limited to 'examples') diff --git a/examples/defconfig_oldconfig.py b/examples/defconfig_oldconfig.py new file mode 100644 index 0000000..9a85440 --- /dev/null +++ b/examples/defconfig_oldconfig.py @@ -0,0 +1,33 @@ +# Produces exactly the same output as the following script: +# +# make defconfig +# echo CONFIG_ETHERNET=n >> .config +# make oldconfig +# echo CONFIG_ETHERNET=y >> .config +# yes n | make oldconfig +# +# This came up in https://github.com/ulfalizer/Kconfiglib/issues/15. + +import kconfiglib +import sys + +conf = kconfiglib.Config(sys.argv[1]) + +# Mirrors defconfig +conf.load_config("arch/x86/configs/x86_64_defconfig") +conf.write_config(".config") + +# Mirrors the first oldconfig +conf.load_config(".config") +conf["ETHERNET"].set_user_value('n') +conf.write_config(".config") + +# Mirrors the second oldconfig +conf.load_config(".config") +conf["ETHERNET"].set_user_value('y') +for s in conf: + if s.get_user_value() is None and 'n' in s.get_assignable_values(): + s.set_user_value('n') + +# Write the final configuration +conf.write_config(".config") -- cgit v1.2.3