public inbox for buildroot@busybox.net
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] support/scripts: add check-dotconfig.py
@ 2020-04-20  9:17 Romain Naour
  2020-04-20  9:17 ` [Buildroot] [PATCH 2/2] gitlab-ci: check generated config files Romain Naour
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Romain Naour @ 2020-04-20  9:17 UTC (permalink / raw)
  To: buildroot

For the same reason as for 50b747f212be2c9c0f7cf10c674ed488d042715c,
we need to check if the generated configuration file (.config)
contains all symbols present in the defconfig file.

If not there is an issue with the defconfig.

This script will be used in .gitlab-ci.yml.

Inspired by is_toolchain_usable() function from genrandconfig:
https://git.busybox.net/buildroot/tree/utils/genrandconfig?h=2020.02#n164

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 support/scripts/check-dotconfig.py | 37 ++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100755 support/scripts/check-dotconfig.py

diff --git a/support/scripts/check-dotconfig.py b/support/scripts/check-dotconfig.py
new file mode 100755
index 0000000000..9e60810c1d
--- /dev/null
+++ b/support/scripts/check-dotconfig.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+
+# This script check if the .config is contains all lines present in the defconfig.
+
+import sys
+
+
+def main():
+    if not (len(sys.argv) == 3):
+        print("Error: incorrect number of arguments")
+        print("""Usage: check-dotconfig <configfile> <defconfig>""")
+        sys.exit(1)
+
+    configfile = sys.argv[1]
+    defconfig = sys.argv[2]
+
+    with open(configfile) as configf:
+        configlines = configf.readlines()
+
+    defconfiglines = []
+    with open(defconfig) as defconfigf:
+        for line in defconfigf.readlines():
+            if line.startswith("BR2_"):
+                defconfiglines.append(line)
+
+    # Check that all the defconfig lines are still present
+    for defconfigline in defconfiglines:
+        if defconfigline not in configlines:
+            print("WARN: defconfig can't be used\n")
+            print("      Missing: %s\n" % defconfigline.strip())
+            return False
+
+    return True
+
+
+if __name__ == "__main__":
+    main()
-- 
2.25.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-20 13:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-20  9:17 [Buildroot] [PATCH 1/2] support/scripts: add check-dotconfig.py Romain Naour
2020-04-20  9:17 ` [Buildroot] [PATCH 2/2] gitlab-ci: check generated config files Romain Naour
2020-04-20 11:52 ` [Buildroot] [PATCH 1/2] support/scripts: add check-dotconfig.py Thomas Petazzoni
2020-04-20 12:19   ` Romain Naour
2020-04-20 12:38     ` Thomas Petazzoni
2020-04-20 13:06 ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox