Last active
March 30, 2023 05:26
-
-
Save erfanoabdi/ff6821a017fc52a6a9f950b9e6a375e2 to your computer and use it in GitHub Desktop.
kernel defconfig compatibility matrix checker script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as ET | |
# Parse the compatibility matrix XML | |
compatibility_matrix = ET.parse('<path to compatibility_matrix xml>') | |
# Extract the kernel version and required configs from the XML | |
kernel_version = '4.19.191' | |
required_configs = [] | |
for kernel in compatibility_matrix.findall('.//kernel'): | |
if kernel.attrib['version'] == kernel_version: | |
for config in kernel.findall('config'): | |
value = config.find('value').text | |
if value == 'y': | |
required_configs.append(config.find('key').text) | |
# Load the defconfig file | |
defconfig_file = '<path to defconfig>' | |
with open(defconfig_file, 'r') as f: | |
defconfig = f.read() | |
# Check for configs in conditions | |
for kernel in compatibility_matrix.findall('.//kernel'): | |
if kernel.attrib['version'] == kernel_version: | |
has_condition = False | |
for condition in kernel.findall('conditions/config'): | |
key = condition.find('key').text | |
value = condition.find('value').text | |
if value == "n" : | |
if f'{config}=y' not in defconfig and f'{config}=m' not in defconfig: | |
has_condition = True | |
else: | |
if f'{key}={value}' in defconfig: | |
has_condition = True | |
if has_condition: | |
for config in kernel.findall('config'): | |
value = config.find('value').text | |
if value == 'y': | |
required_configs.append(config.find('key').text) | |
# Check for missing configs | |
missing_configs = [] | |
for config in required_configs: | |
if f'{config}=y' not in defconfig and f'{config}=m' not in defconfig: | |
missing_configs.append(config) | |
# Print the results | |
if missing_configs: | |
print('Missing configs:') | |
for config in missing_configs: | |
print(config) | |
else: | |
print('All required configs are present') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment