Commit 56643222 authored by Michal Marek's avatar Michal Marek Committed by Sam Ravnborg

kbuild: handle non-existing options in scripts/config

If an option does not exist in .config, set it at the end of the file.
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
parent 17b1f0de
...@@ -26,8 +26,6 @@ options: ...@@ -26,8 +26,6 @@ options:
config doesn't check the validity of the .config file. This is done at next config doesn't check the validity of the .config file. This is done at next
make time. make time.
The options need to be already in the file before they can be changed,
but sometimes you can cheat with the --*-after options.
EOL EOL
exit 1 exit 1
} }
...@@ -45,8 +43,18 @@ checkarg() { ...@@ -45,8 +43,18 @@ checkarg() {
ARG="`echo $ARG | tr a-z A-Z`" ARG="`echo $ARG | tr a-z A-Z`"
} }
replace() { set_var() {
sed -i -e "$@" $FN local name=$1 new=$2 before=$3
name_re="^($name=|# $name is not set)"
before_re="^($before=|# $before is not set)"
if test -n "$before" && grep -Eq "$before_re" "$FN"; then
sed -ri "/$before_re/a $new" "$FN"
elif grep -Eq "$name_re" "$FN"; then
sed -ri "s:$name_re.*:$new:" "$FN"
else
echo "$new" >>"$FN"
fi
} }
if [ "$1" = "--file" ]; then if [ "$1" = "--file" ]; then
...@@ -70,20 +78,19 @@ while [ "$1" != "" ] ; do ...@@ -70,20 +78,19 @@ while [ "$1" != "" ] ; do
case "$CMD" in case "$CMD" in
--enable|-e) --enable|-e)
checkarg "$1" checkarg "$1"
replace "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/" set_var "CONFIG_$ARG" "CONFIG_$ARG=y"
shift shift
;; ;;
--disable|-d) --disable|-d)
checkarg "$1" checkarg "$1"
replace "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/" set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set"
shift shift
;; ;;
--module|-m) --module|-m)
checkarg "$1" checkarg "$1"
replace "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \ set_var "CONFIG_$ARG" "CONFIG_$ARG=m"
-e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/"
shift shift
;; ;;
...@@ -109,9 +116,7 @@ while [ "$1" != "" ] ; do ...@@ -109,9 +116,7 @@ while [ "$1" != "" ] ; do
A=$ARG A=$ARG
checkarg "$2" checkarg "$2"
B=$ARG B=$ARG
replace "/CONFIG_$A=[my]/aCONFIG_$B=y" \ set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A"
-e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=y" \
-e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/"
shift shift
shift shift
;; ;;
...@@ -121,9 +126,7 @@ while [ "$1" != "" ] ; do ...@@ -121,9 +126,7 @@ while [ "$1" != "" ] ; do
A=$ARG A=$ARG
checkarg "$2" checkarg "$2"
B=$ARG B=$ARG
replace "/CONFIG_$A=[my]/a# CONFIG_$B is not set" \ set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A"
-e "/# CONFIG_$ARG is not set/a/# CONFIG_$ARG is not set" \
-e "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/"
shift shift
shift shift
;; ;;
...@@ -133,10 +136,7 @@ while [ "$1" != "" ] ; do ...@@ -133,10 +136,7 @@ while [ "$1" != "" ] ; do
A=$ARG A=$ARG
checkarg "$2" checkarg "$2"
B=$ARG B=$ARG
replace "/CONFIG_$A=[my]/aCONFIG_$B=m" \ set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A"
-e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=m" \
-e "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \
-e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/"
shift shift
shift shift
;; ;;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment