-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Add config subcommand to generate a kernel config from a set of fragments like the ones in here.
The generated config should include configuration to boot the vm with the configured debian features.
The command should check that all requested config items are set accordingly similar to this:
#!/usr/bin/env python3
import argparse
import re
import sys
from itertools import combinations
parser = argparse.ArgumentParser()
parser.add_argument("--config", type=argparse.FileType('rt'))
parser.add_argument("fragments", metavar='FRAGMENT', type=argparse.FileType('rt'), nargs="+")
args = parser.parse_args()
input_fragments = dict()
output_configs = dict()
matcher = re.compile(r"""^(CONFIG_\w+)=([nym])""")
def get_configs(file):
configs = dict()
for line in file.readlines():
matches = matcher.match(line)
if matches:
configs[matches.group(1)] = matches.group(2)
return configs
for fragment in args.fragments:
input_fragments[fragment.name] = get_configs(fragment)
ok = True
for (key_a, key_b) in combinations(input_fragments.keys(), 2):
fragment_a = input_fragments[key_a]
fragment_b = input_fragments[key_b]
common_configs = set(fragment_a.keys()).intersection(set(fragment_b.keys()))
for config in common_configs:
value_a = fragment_a[config]
value_b = fragment_b[config]
if value_a != value_b:
print(f"ERROR: {config} has conflicting values {key_a}:{value_a} and {key_b}:{value_b}")
ok = False
output_configs |= get_configs(args.config)
input_configs = dict()
for fragment_name,configs in input_fragments.items():
input_configs |= configs
for key,value in input_configs.items():
check_failed = \
(value != 'n' \
and output_configs.get(key) != value) or \
(value == 'n' \
and key in output_configs and output_configs.get(key) != value)
if check_failed:
ok = False
print(f"ERROR: {key}={value}")
if not ok:
sys.exit(-1)Metadata
Metadata
Assignees
Labels
No labels