#! /bin/sh # Copyright (C) 2006 Randy Dunlap # License: GPLv2 only. # # usage: setkconfig symbol y/m/n, or p/empty to print current value; ### symbol should be entered without the leading "CONFIG_" string; # run 'make oldconfig' after this; dir=$1 symbol=$2 value=$3 if [ "$symbol" == "" ]; then echo "usage: setkconfig config_dir symbol value(y/m/n) or (default:) p to print current value" exit 1 fi # no CONFIG_ used in print/search; # it's also a "loose/fuzzy" search, finding more than just CONFIG_$symbol; if [ "$value" == "p" ] || [ "$value" == "" ]; then grep "$symbol" $dir/.config exit 0 fi if [ "$value" != "y" ] && [ "$value" != "m" ] && [ "$value" != "n" ]; then echo "config symbol value must be one of y/m/n" exit 1 fi if [ "${symbol:0:7}" == "CONFIG_" ]; then echo "usage: don't use CONFIG_ prefix; that's done for you" exit 1 fi cp -a $dir/.config $dir/.config.pre if grep -sq "CONFIG_$symbol=[ymn]" $dir/.config ; then sed -e "s/CONFIG_$symbol=[ymn]/CONFIG_$symbol=$value/" $dir/.config.pre > $dir/.config else # "$symbol=[ymn]" not found: sed -e "s/^# CONFIG_$symbol is not set/CONFIG_$symbol=$value/" $dir/.config.pre > $dir/.config ##sed -e "s/^\# CONFIG_$symbol.*$//" .config.pre >.config # but $symbol may not be found in .config at all (may be (NEW), # so be safe and also append it at end of file: echo "CONFIG_$symbol=$value" >> $dir/.config fi