]> git.ipfire.org Git - ipfire-3.x.git/blame - kernel/scripts/configcommon.py
json-c: Update to version 0.17-20230812
[ipfire-3.x.git] / kernel / scripts / configcommon.py
CommitLineData
e42c2c0b 1#!/usr/bin/python3
4c928ab7
MT
2###############################################################################
3# IPFire.org - An Open Source Firewall Solution #
4# Copyright (C) - IPFire Development Team <info@ipfire.org> #
5###############################################################################
6
7import re
8import sys
9
10filelist = sys.argv[1:]
11
12lines = []
13options_state = {}
14options_counter = {}
15
16first_file = True
17for filename in filelist:
18 f = open(filename)
19
20 for line in f.readlines():
21 # Strip newline.
22 line = line.rstrip()
23
24 if line.startswith("# Automatically generated file;"):
25 continue
26
27 if line.endswith("Kernel Configuration"):
28 continue
29
58640b55
MT
30 if line.startswith("# Compiler:"):
31 continue
32
4c928ab7
MT
33 option = value = None
34
35 m = re.match("^# (.*) is not set$", line)
36 if m:
37 option = m.group(1)
38 value = "n"
39
40 m = re.match("^(.*)=(.*)$", line)
41 if m:
42 option = m.group(1)
43 value = m.group(2)
44
45 if option:
46 option_value = "%s=%s" % (option, value or "")
47
48 try:
49 options_counter[option_value] += 1
50 continue
51
52 except KeyError:
53 options_counter[option_value] = 1
54
55 if first_file:
56 lines.append(line)
57
58 f.close()
59 first_file = False
60
61for line in lines:
62 m = re.match("^# (.*) is not set$", line)
63 if m:
64 if options_counter.get("%s=n" % m.group(1), 0) == len(filelist):
e42c2c0b 65 print("# %s is not set" % m.group(1))
4c928ab7
MT
66
67 continue
68
69 m = re.match("^(.*)=(.*)$", line)
70 if m:
71 if options_counter.get(m.group(0), 0) == len(filelist):
e42c2c0b 72 print(m.group(0))
4c928ab7
MT
73
74 continue
75
e42c2c0b 76 print(line)