configcheck.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. # Usage: configcheck.sh .config .config-template
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, you can access it online at
  16. # http://www.gnu.org/licenses/gpl-2.0.html.
  17. #
  18. # Copyright (C) IBM Corporation, 2011
  19. #
  20. # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
  21. T=/tmp/abat-chk-config.sh.$$
  22. trap 'rm -rf $T' 0
  23. mkdir $T
  24. cat $1 > $T/.config
  25. cat $2 | sed -e 's/\(.*\)=n/# \1 is not set/' -e 's/^#CHECK#//' |
  26. awk '
  27. BEGIN {
  28. print "if grep -q \"" $0 "\" < '"$T/.config"'";
  29. print "then";
  30. print "\t:";
  31. print "else";
  32. if ($1 == "#") {
  33. print "\tif grep -q \"" $2 "\" < '"$T/.config"'";
  34. print "\tthen";
  35. print "\t\tif test \"$firsttime\" = \"\""
  36. print "\t\tthen"
  37. print "\t\t\tfirsttime=1"
  38. print "\t\tfi"
  39. print "\t\techo \":" $2 ": improperly set\"";
  40. print "\telse";
  41. print "\t\t:";
  42. print "\tfi";
  43. } else {
  44. print "\tif test \"$firsttime\" = \"\""
  45. print "\tthen"
  46. print "\t\tfirsttime=1"
  47. print "\tfi"
  48. print "\techo \":" $0 ": improperly set\"";
  49. }
  50. print "fi";
  51. }' | sh