aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--maintenance/docmatcher.py135
1 files changed, 117 insertions, 18 deletions
diff --git a/maintenance/docmatcher.py b/maintenance/docmatcher.py
index deba941..0fb26bc 100644
--- a/maintenance/docmatcher.py
+++ b/maintenance/docmatcher.py
@@ -9,6 +9,18 @@ import sys
import os
+NON_VARIABLES = ('UTF', 'USE', 'TCP', 'SMP', 'PXE', 'PPC', 'MAC',
+ 'GTK', 'GNU', 'CPU', 'DOS', 'NIC', 'NFS', 'ISO', 'TIMEOUT',
+ 'TFTP', 'SYSTEM', 'SPARC', 'RAID', 'LABEL', 'PROMPT', 'KERNEL',
+ 'GRP', 'DOCTYPE', 'DHCP', 'DEFAULT', 'ATARAID', 'APPEND')
+
+EXTRA_VARIABLES = ['ARCH_OVERRIDE', 'BOOTLOADER', 'CLEAR_CACHE_DIR', 'DEFAULT_KERNEL_SOURCE', 'DISTDIR', 'GK_SHARE']
+for app in ('DEVICE_MAPPER', 'UNIONFS_FUSE', 'BUSYBOX', 'DMRAID', 'LVM', 'ISCSI', 'FUSE'):
+ for prop in ('DIR', 'SRCTAR', 'VER'):
+ EXTRA_VARIABLES.append('%s_%s' % (app, prop))
+EXTRA_VARIABLES = tuple(EXTRA_VARIABLES)
+
+
def exract_gen_cmdline_sh():
f = open('gen_cmdline.sh', 'r')
gen_cmdline_sh = f.read()
@@ -33,11 +45,22 @@ def exract_gen_cmdline_sh():
del gen_cmdline_sh
+ parsing_code = '\n'.join(parsing_lines)
+ del parsing_lines
+
gen_cmdline_sh_parsing_long_params = set()
- for match in re.finditer('--([a-z][a-z0-9-]+)', '\n'.join(parsing_lines)):
+ for match in re.finditer('--([a-z][a-z0-9-]+)', parsing_code):
para_name = match.group(1)
gen_cmdline_sh_parsing_long_params.add(para_name)
- del parsing_lines
+
+ gen_cmdline_sh_variables = set()
+ for match in re.finditer('^\s*([A-Z_]+)=', parsing_code, re.MULTILINE):
+ var_name = match.group(1)
+ if var_name.startswith('CMD_'):
+ continue
+ gen_cmdline_sh_variables.add(var_name)
+
+ del parsing_code
gen_cmdline_sh_usage_long_params = set()
@@ -45,8 +68,8 @@ def exract_gen_cmdline_sh():
para_name = match.group(1)
gen_cmdline_sh_usage_long_params.add(para_name)
del usage_lines
-
- return gen_cmdline_sh_parsing_long_params, gen_cmdline_sh_usage_long_params
+
+ return gen_cmdline_sh_parsing_long_params, gen_cmdline_sh_usage_long_params, gen_cmdline_sh_variables
def extract_genkernel_8():
@@ -62,7 +85,7 @@ def extract_genkernel_8():
genkernel_8_long_params = set()
for match in re.finditer('--((?:[a-z]|\\[no-\\])[a-z0-9-]+)', genkernel_8):
para_name = match.group(1)
-
+
# Black list
if para_name == 'no-':
continue
@@ -77,11 +100,11 @@ def extract_genkernel_8():
genkernel_8_long_params.add(para_name)
del genkernel_8
-
+
return genkernel_8_long_params
-def extract_genkernel_xml(genkernel_xml_path):
+def extract_genkernel_xml(genkernel_xml_path, variables_blacklist):
f = open(genkernel_xml_path, 'r')
genkernel_xml = f.read()
f.close()
@@ -94,8 +117,8 @@ def extract_genkernel_xml(genkernel_xml_path):
genkernel_xml_long_params = set()
for match in re.finditer('--([a-z][a-z0-9-]+)', genkernel_xml):
para_name = match.group(1)
-
- # Fix doc error "--no install"
+
+ # Fix doc error "--no install"
if para_name == 'no':
para_name = 'no-install'
@@ -108,9 +131,52 @@ def extract_genkernel_xml(genkernel_xml_path):
else:
genkernel_xml_long_params.add(para_name)
+ genkernel_xml_variables = set()
+ for match in re.finditer('[A-Z_]{3,}', genkernel_xml):
+ var_name = match.group(0)
+ if var_name in variables_blacklist:
+ continue
+ genkernel_xml_variables.add(var_name)
+
del genkernel_xml
-
- return genkernel_xml_long_params
+
+ return genkernel_xml_long_params, genkernel_xml_variables
+
+
+def extract_gen_determineargs_sh():
+ f = open('gen_determineargs.sh', 'r')
+ gen_determineargs_sh = f.read()
+ f.close()
+
+ gen_determineargs_sh_variables = set()
+ for match in re.finditer('set_config_with_override\s+[0-9]+\s+([A-Z_]+)', gen_determineargs_sh):
+ var_name = match.group(1)
+ gen_determineargs_sh_variables.add(var_name)
+
+ for match in re.finditer('([A-Z_]+)=`(?:arch|cache)_replace "\\$\\{\\1\\}"`', gen_determineargs_sh):
+ var_name = match.group(1)
+ gen_determineargs_sh_variables.add(var_name)
+
+ del gen_determineargs_sh
+
+ return gen_determineargs_sh_variables
+
+
+def extract_genkernel_conf(variables_blacklist):
+ f = open('genkernel.conf', 'r')
+ genkernel_conf = f.read()
+ f.close()
+
+ genkernel_conf_variables = set()
+ for match in re.finditer('^#*\\s*([A-Z_]{3,})', genkernel_conf, re.MULTILINE):
+ var_name = match.group(1)
+ if var_name in variables_blacklist:
+ continue
+ genkernel_conf_variables.add(var_name)
+
+ del genkernel_conf
+
+ return genkernel_conf_variables
def print_set(s):
@@ -130,25 +196,44 @@ def main():
usage()
sys.exit(1)
- gen_cmdline_sh_parsing_long_params, gen_cmdline_sh_usage_long_params = exract_gen_cmdline_sh()
+ gen_cmdline_sh_parsing_long_params, gen_cmdline_sh_usage_long_params, gen_cmdline_sh_variables = exract_gen_cmdline_sh()
genkernel_8_long_params = extract_genkernel_8()
- genkernel_xml_long_params = extract_genkernel_xml(sys.argv[1])
+ gen_determineargs_sh_variables = extract_gen_determineargs_sh()
+
+ variables_blacklist = set(NON_VARIABLES).difference(gen_determineargs_sh_variables)
+ known_variales = set(EXTRA_VARIABLES).union(gen_determineargs_sh_variables).union(gen_cmdline_sh_variables)
+
+ genkernel_xml_long_params, genkernel_xml_variables = extract_genkernel_xml(sys.argv[1], variables_blacklist)
+ genkernel_conf_variables = extract_genkernel_conf(variables_blacklist)
# Status quo
- print('Used by parser in *gen_cmdline.sh*:')
+ print('Options used by parser in *gen_cmdline.sh*:')
print_set(gen_cmdline_sh_parsing_long_params)
- print('Mentioned in usage of *gen_cmdline.sh*:')
+ print('Options mentioned in usage of *gen_cmdline.sh*:')
print_set(gen_cmdline_sh_usage_long_params)
-
- print('Mentioned in *man page*:')
+
+ print('Options mentioned in *man page*:')
print_set(genkernel_8_long_params)
- print('Mentioned in *web page*:')
+ print('Options mentioned in *web page*:')
print_set(genkernel_xml_long_params)
+ print('Variables set by *gen_cmdline.sh*:')
+ print_set(gen_cmdline_sh_variables)
+
+ print('Variables read by *gen_determineargs.sh*:')
+ print_set(gen_determineargs_sh_variables)
+
+ print('Variables mentioned in *web page*:')
+ print_set(genkernel_xml_variables)
+
+ print('Variables used in *genkernel.conf*:')
+ print_set(genkernel_conf_variables)
+
+
# Future work
print('Options missing from the *man page*:')
print_set(gen_cmdline_sh_parsing_long_params.difference(genkernel_8_long_params))
@@ -171,5 +256,19 @@ def main():
print_set(genkernel_xml_long_params.difference(gen_cmdline_sh_parsing_long_params))
+ print('Variables missing from *web page*:')
+ print_set(known_variales.difference(genkernel_xml_variables))
+
+ print('Removed variables still mentioned in *web page*:')
+ print_set(genkernel_xml_variables.difference(known_variales))
+
+
+ print('Variables missing from *genkernel.conf*:')
+ print_set(known_variales.difference(genkernel_conf_variables))
+
+ print('Removed variables still mentioned in *genkernel.conf*:')
+ print_set(genkernel_conf_variables.difference(known_variales))
+
+
if __name__ == '__main__':
main()