summaryrefslogtreecommitdiff
path: root/examples/defconfig_oldconfig.py
blob: 84aa134ff468735202366a9151354c41aa7fda0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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.
#
# Usage:
#
#   $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/examples/defconfig_oldconfig.py

import kconfiglib
import sys

kconf = kconfiglib.Kconfig(sys.argv[1])

# Mirrors defconfig
kconf.load_config("arch/x86/configs/x86_64_defconfig")
kconf.write_config(".config")

# Mirrors the first oldconfig
kconf.load_config(".config")
kconf.syms["ETHERNET"].set_value(0)
kconf.write_config(".config")

# Mirrors the second oldconfig
kconf.load_config(".config")
kconf.syms["ETHERNET"].set_value(2)
for s in kconf.defined_syms:
    if s.user_value is None and 0 in s.assignable:
        s.set_value(0)

# Write the final configuration
kconf.write_config(".config")