mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +00:00
scripts: Add script to split kernel config files
This script is slightly modified from the ChromiumOS splitconfig It takes a number of kernel config files and prints the common on specific kernel config options to seperate files. Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
119cc56fcf
commit
c3b9972b32
44
scripts/kconfig-split.py
Executable file
44
scripts/kconfig-split.py
Executable file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This is a slightly modified version of ChromiumOS' splitconfig
|
||||
# https://chromium.googlesource.com/chromiumos/third_party/kernel/+/stabilize-5899.B-chromeos-3.14/chromeos/scripts/splitconfig
|
||||
|
||||
"""See this page for more details:
|
||||
http://dev.chromium.org/chromium-os/how-tos-and-troubleshooting/kernel-configuration
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
allconfigs = {}
|
||||
|
||||
# Parse config files
|
||||
for config in sys.argv[1:]:
|
||||
|
||||
allconfigs[config] = set()
|
||||
|
||||
for line in open(config):
|
||||
m = re.match("#*\s*CONFIG_(\w+)[\s=](.*)$", line)
|
||||
if not m:
|
||||
continue
|
||||
option, value = m.groups()
|
||||
allconfigs[config].add((option, value))
|
||||
|
||||
# Split out common config options
|
||||
common = allconfigs.values()[0].copy()
|
||||
for config in allconfigs.keys():
|
||||
common &= allconfigs[config]
|
||||
for config in allconfigs.keys():
|
||||
allconfigs[config] -= common
|
||||
|
||||
allconfigs["common"] = common
|
||||
|
||||
# Generate new splitconfigs
|
||||
for config in allconfigs.keys():
|
||||
f = open("split-" + config, "w")
|
||||
for option, value in sorted(list(allconfigs[config])):
|
||||
if value == "is not set":
|
||||
print >>f, "# CONFIG_%s %s" % (option, value)
|
||||
else:
|
||||
print >>f, "CONFIG_%s=%s" % (option, value)
|
||||
f.close()
|
Loading…
Reference in New Issue
Block a user