From 681b12820b50b95e45cbd9bb27dfc96af3812b9b Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sat, 25 Jul 2015 23:08:44 +0200 Subject: scripts: add miniconfig.sh to aid in mini.config creation Signed-off-by: Phil Sutter --- scripts/miniconfig.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 scripts/miniconfig.sh (limited to 'scripts') diff --git a/scripts/miniconfig.sh b/scripts/miniconfig.sh new file mode 100644 index 000000000..0e4ccf777 --- /dev/null +++ b/scripts/miniconfig.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +# miniconfig.sh copyright 2005 by Rob Landley +# Licensed under the GNU General Public License version 2. +# +# This script aids in building a mini.config from a fully fledged kernel +# config. To do so, change into the kernel source directory and call this +# script with the full config as first parameter. The output will be written to +# a file named 'mini.config' in the same directory. +# +# Beware: This runs for a long time and the output might not be optimal. When +# using it, bring some beer but don't drink too much so you're still able to +# manually review the output in the end. + +if [ $# -ne 1 ] || [ ! -f "$1" ]; then + echo "Usage: miniconfig.sh configfile" + exit 1 +fi + +if [ "$1" == ".config" ]; then + echo "It overwrites .config, rename it and try again." + exit 1 +fi + +cp $1 mini.config +echo "Calculating mini.config..." + +LENGTH=`cat $1 | wc -l` + +# Loop through all lines in the file +I=1 +while true; do + if [ $I -gt $LENGTH ]; then + exit + fi + sed -n "${I}!p" mini.config > .config.test + # Do a config with this file + make allnoconfig KCONFIG_ALLCONFIG=.config.test > /dev/null + + # Compare. The date changes so expect a small difference each time. + D=`diff .config $1 | wc -l` + if [ $D -eq 4 ]; then + mv .config.test mini.config + LENGTH=$[$LENGTH-1] + else + I=$[$I + 1] + fi + echo -n -e $I/$LENGTH lines `cat mini.config | wc -c` bytes "\r" +done +echo -- cgit v1.2.3