]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blob - kernel/scripts/configdiff.py
Merge remote-tracking branch 'arne_f/autoconf'
[people/arne_f/ipfire-3.x.git] / kernel / scripts / configdiff.py
1 #!/usr/bin/python
2 ###############################################################################
3 # IPFire.org - An Open Source Firewall Solution #
4 # Copyright (C) - IPFire Development Team <info@ipfire.org> #
5 ###############################################################################
6
7 import re
8 import sys
9
10 filelist = sys.argv[1:]
11
12 options = []
13
14 f = open(filelist[0])
15 for line in f.readlines():
16 # Strip newline.
17 line = line.rstrip()
18
19 option = value = None
20
21 m = re.match("^# (.*) is not set$", line)
22 if m:
23 option = m.group(1)
24 value = "n"
25
26 m = re.match("^(.*)=(.*)$", line)
27 if m:
28 option = m.group(1)
29 value = m.group(2)
30
31 if option:
32 option_value = "%s=%s" % (option, value or "")
33 options.append(option_value)
34
35 f.close()
36
37 f = open(filelist[1])
38
39 section = None
40 for line in f.readlines():
41 m = re.match("^# (.*)$", line)
42 if m:
43 _section = m.group(1)
44 if not _section.startswith("CONFIG_") and \
45 not _section.endswith("Kernel Configuration") and \
46 not _section.startswith("Automatically generated file;"):
47 section = _section
48
49 option = None
50 value = None
51
52 m = re.match("^# (.*) is not set$", line)
53 if m:
54 option = m.group(1)
55 value = "n"
56
57 m = re.match("^(.*)=(.*)$", line)
58 if m:
59 option = m.group(1)
60 value = m.group(2)
61
62 if not option:
63 continue
64
65 # Ignore all options CONFIG_HAVE_ because we cannot
66 # set them anyway.
67 elif option.startswith("CONFIG_HAVE_"):
68 continue
69
70 option_value = "%s=%s" % (option, value)
71 if not option_value in options:
72 if section:
73 print
74 print "#"
75 print "# %s" % section
76 print "#"
77 section = None
78
79 if value == "n":
80 print "# %s is not set" % option
81 else:
82 print "%s=%s" % (option, value)
83
84 f.close()