]>
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 | ||
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 | |
5e856224 MT |
48 | elif not line: |
49 | section = None | |
4c928ab7 MT |
50 | |
51 | option = None | |
52 | value = None | |
53 | ||
54 | m = re.match("^# (.*) is not set$", line) | |
55 | if m: | |
56 | option = m.group(1) | |
57 | value = "n" | |
58 | ||
59 | m = re.match("^(.*)=(.*)$", line) | |
60 | if m: | |
61 | option = m.group(1) | |
62 | value = m.group(2) | |
63 | ||
64 | if not option: | |
65 | continue | |
66 | ||
67 | # Ignore all options CONFIG_HAVE_ because we cannot | |
68 | # set them anyway. | |
69 | elif option.startswith("CONFIG_HAVE_"): | |
70 | continue | |
71 | ||
72 | option_value = "%s=%s" % (option, value) | |
73 | if not option_value in options: | |
74 | if section: | |
75 | ||
76 | print "#" | |
77 | print "# %s" % section | |
78 | print "#" | |
79 | section = None | |
80 | ||
81 | if value == "n": | |
82 | print "# %s is not set" % option | |
83 | else: | |
84 | print "%s=%s" % (option, value) | |
85 | ||
86 | f.close() |