configinit.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. #
  3. # Usage: configinit.sh config-spec-file build-output-dir results-dir
  4. #
  5. # Create a .config file from the spec file. Run from the kernel source tree.
  6. # Exits with 0 if all went well, with 1 if all went well but the config
  7. # did not match, and some other number for other failures.
  8. #
  9. # The first argument is the .config specification file, which contains
  10. # desired settings, for example, "CONFIG_NO_HZ=y". For best results,
  11. # this should be a full pathname.
  12. #
  13. # The second argument is a optional path to a build output directory,
  14. # for example, "O=/tmp/foo". If this argument is omitted, the .config
  15. # file will be generated directly in the current directory.
  16. #
  17. # This program is free software; you can redistribute it and/or modify
  18. # it under the terms of the GNU General Public License as published by
  19. # the Free Software Foundation; either version 2 of the License, or
  20. # (at your option) any later version.
  21. #
  22. # This program is distributed in the hope that it will be useful,
  23. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. # GNU General Public License for more details.
  26. #
  27. # You should have received a copy of the GNU General Public License
  28. # along with this program; if not, you can access it online at
  29. # http://www.gnu.org/licenses/gpl-2.0.html.
  30. #
  31. # Copyright (C) IBM Corporation, 2013
  32. #
  33. # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
  34. T=${TMPDIR-/tmp}/configinit.sh.$$
  35. trap 'rm -rf $T' 0
  36. mkdir $T
  37. # Capture config spec file.
  38. c=$1
  39. buildloc=$2
  40. resdir=$3
  41. builddir=
  42. if echo $buildloc | grep -q '^O='
  43. then
  44. builddir=`echo $buildloc | sed -e 's/^O=//'`
  45. if test ! -d $builddir
  46. then
  47. mkdir $builddir
  48. fi
  49. else
  50. echo Bad build directory: \"$buildloc\"
  51. exit 2
  52. fi
  53. sed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh
  54. sed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh
  55. grep '^grep' < $T/u.sh > $T/upd.sh
  56. echo "cat - $c" >> $T/upd.sh
  57. make mrproper
  58. make $buildloc distclean > $resdir/Make.distclean 2>&1
  59. make $buildloc $TORTURE_DEFCONFIG > $resdir/Make.defconfig.out 2>&1
  60. mv $builddir/.config $builddir/.config.sav
  61. sh $T/upd.sh < $builddir/.config.sav > $builddir/.config
  62. cp $builddir/.config $builddir/.config.new
  63. yes '' | make $buildloc oldconfig > $resdir/Make.oldconfig.out 2> $resdir/Make.oldconfig.err
  64. # verify new config matches specification.
  65. configcheck.sh $builddir/.config $c
  66. exit 0