check-dotconfig.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python3
  2. # This scripts check that all lines present in the defconfig are
  3. # still present in the .config
  4. import sys
  5. def main():
  6. if not (len(sys.argv) == 3):
  7. print("Error: incorrect number of arguments")
  8. print("""Usage: check-dotconfig <configfile> <defconfig>""")
  9. sys.exit(1)
  10. configfile = sys.argv[1]
  11. defconfig = sys.argv[2]
  12. # strip() to get rid of trailing \n
  13. with open(configfile) as configf:
  14. configlines = [l.strip() for l in configf.readlines()]
  15. defconfiglines = []
  16. with open(defconfig) as defconfigf:
  17. # strip() to get rid of trailing \n
  18. for line in (line.strip() for line in defconfigf.readlines()):
  19. if line.startswith("BR2_"):
  20. defconfiglines.append(line)
  21. elif line.startswith('# BR2_') and line.endswith(' is not set'):
  22. defconfiglines.append(line)
  23. # Check that all the defconfig lines are still present
  24. missing = [line for line in defconfiglines if line not in configlines]
  25. if missing:
  26. print("WARN: defconfig {} can't be used:".format(defconfig))
  27. for m in missing:
  28. print(" Missing: {}".format(m))
  29. sys.exit(1)
  30. if __name__ == "__main__":
  31. main()