]>
Commit | Line | Data |
---|---|---|
4c928ab7 MT |
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 | ||
2b86e6fb | 39 | printed_sections = [] |
4c928ab7 MT |
40 | section = None |
41 | for line in f.readlines(): | |
2b86e6fb MT |
42 | line = line.rstrip() |
43 | ||
44 | # Ignore some stuff | |
45 | if not line or line == "#": | |
46 | continue | |
47 | ||
48 | if line.startswith("# Automatically generated file;"): | |
49 | continue | |
50 | ||
51 | if line.endswith("Kernel Configuration"): | |
52 | continue | |
53 | ||
54 | # End of section | |
55 | m = re.match("# end of (.*)$", line) | |
4c928ab7 MT |
56 | if m: |
57 | _section = m.group(1) | |
2b86e6fb MT |
58 | |
59 | if _section in printed_sections: | |
60 | print "# end of %s" % _section | |
61 | ||
62 | continue | |
63 | ||
64 | # New section | |
65 | m = re.match("^# (.*)$", line) | |
66 | if m and not "CONFIG_" in line: | |
67 | section = m.group(1) | |
68 | continue | |
4c928ab7 MT |
69 | |
70 | option = None | |
71 | value = None | |
72 | ||
73 | m = re.match("^# (.*) is not set$", line) | |
74 | if m: | |
75 | option = m.group(1) | |
76 | value = "n" | |
77 | ||
78 | m = re.match("^(.*)=(.*)$", line) | |
79 | if m: | |
80 | option = m.group(1) | |
81 | value = m.group(2) | |
82 | ||
83 | if not option: | |
84 | continue | |
85 | ||
86 | # Ignore all options CONFIG_HAVE_ because we cannot | |
87 | # set them anyway. | |
88 | elif option.startswith("CONFIG_HAVE_"): | |
89 | continue | |
90 | ||
91 | option_value = "%s=%s" % (option, value) | |
92 | if not option_value in options: | |
2b86e6fb | 93 | if section and not section in printed_sections: |
4c928ab7 MT |
94 | |
95 | print "#" | |
96 | print "# %s" % section | |
97 | print "#" | |
2b86e6fb | 98 | printed_sections.append(section) |
4c928ab7 MT |
99 | |
100 | if value == "n": | |
101 | print "# %s is not set" % option | |
102 | else: | |
103 | print "%s=%s" % (option, value) | |
104 | ||
105 | f.close() |