miniconfig.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. # miniconfig.sh copyright 2005 by Rob Landley <rob@landley.net>
  3. # Licensed under the GNU General Public License version 2.
  4. #
  5. # This script aids in building a mini.config from a fully fledged kernel
  6. # config. To do so, change into the kernel source directory and call this
  7. # script with the full config as first parameter. The output will be written to
  8. # a file named 'mini.config' in the same directory.
  9. #
  10. # Beware: This runs for a long time and the output might not be optimal. When
  11. # using it, bring some beer but don't drink too much so you're still able to
  12. # manually review the output in the end.
  13. if [ $# -ne 1 ] || [ ! -f "$1" ]; then
  14. echo "Usage: miniconfig.sh configfile"
  15. exit 1
  16. fi
  17. if [ "$1" == ".config" ]; then
  18. echo "It overwrites .config, rename it and try again."
  19. exit 1
  20. fi
  21. cp $1 mini.config
  22. echo "Calculating mini.config..."
  23. LENGTH=`cat $1 | wc -l`
  24. # Loop through all lines in the file
  25. I=1
  26. while true; do
  27. if [ $I -gt $LENGTH ]; then
  28. exit
  29. fi
  30. sed -n "${I}!p" mini.config > .config.test
  31. # Do a config with this file
  32. make allnoconfig KCONFIG_ALLCONFIG=.config.test > /dev/null
  33. # Compare. The date changes so expect a small difference each time.
  34. D=`diff .config $1 | wc -l`
  35. if [ $D -eq 4 ]; then
  36. mv .config.test mini.config
  37. LENGTH=$[$LENGTH-1]
  38. else
  39. I=$[$I + 1]
  40. fi
  41. echo -n -e $I/$LENGTH lines `cat mini.config | wc -c` bytes "\r"
  42. done
  43. echo