diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2015-05-24 12:01:06 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2015-05-24 12:06:55 +0200 |
| commit | bc34d530f4a21b5f06228d626f446c617b9c8876 (patch) | |
| tree | b0b8b0c486c479e6b423584344bcdc7bc8ceaff5 /examples/defconfig_oldconfig.py | |
| parent | ac56921681a723ccfe3f733fe0ea2d8349d99410 (diff) | |
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.
Diffstat (limited to 'examples/defconfig_oldconfig.py')
| -rw-r--r-- | examples/defconfig_oldconfig.py | 33 |
1 files changed, 33 insertions, 0 deletions
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") |
