From 566432224731c3d8fa7925ce07953701f536a666 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Sun, 14 Jun 2009 22:48:07 +0200 Subject: 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: Michal Marek Signed-off-by: Sam Ravnborg --- scripts/config | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'scripts/config') diff --git a/scripts/config b/scripts/config index db6084b78a10..30825a5677f6 100755 --- a/scripts/config +++ b/scripts/config @@ -26,8 +26,6 @@ options: config doesn't check the validity of the .config file. This is done at next 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 exit 1 } @@ -45,8 +43,18 @@ checkarg() { ARG="`echo $ARG | tr a-z A-Z`" } -replace() { - sed -i -e "$@" $FN +set_var() { + 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 @@ -70,20 +78,19 @@ while [ "$1" != "" ] ; do case "$CMD" in --enable|-e) checkarg "$1" - replace "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/" + set_var "CONFIG_$ARG" "CONFIG_$ARG=y" shift ;; --disable|-d) checkarg "$1" - replace "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/" + set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set" shift ;; --module|-m) checkarg "$1" - replace "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \ - -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/" + set_var "CONFIG_$ARG" "CONFIG_$ARG=m" shift ;; @@ -109,9 +116,7 @@ while [ "$1" != "" ] ; do A=$ARG checkarg "$2" B=$ARG - replace "/CONFIG_$A=[my]/aCONFIG_$B=y" \ - -e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=y" \ - -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/" + set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A" shift shift ;; @@ -121,9 +126,7 @@ while [ "$1" != "" ] ; do A=$ARG checkarg "$2" B=$ARG - replace "/CONFIG_$A=[my]/a# CONFIG_$B is not set" \ - -e "/# CONFIG_$ARG is not set/a/# CONFIG_$ARG is not set" \ - -e "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/" + set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A" shift shift ;; @@ -133,10 +136,7 @@ while [ "$1" != "" ] ; do A=$ARG checkarg "$2" B=$ARG - replace "/CONFIG_$A=[my]/aCONFIG_$B=m" \ - -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/" + set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A" shift shift ;; -- cgit v1.2.3 From 47312d2cfd9b769c1739738602c163c4c9814c7b Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Mon, 25 May 2009 16:43:25 +0200 Subject: kbuild: simplify argument loop in scripts/config Signed-off-by: Michal Marek Signed-off-by: Sam Ravnborg --- scripts/config | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'scripts/config') diff --git a/scripts/config b/scripts/config index 30825a5677f6..640c6fe4d644 100755 --- a/scripts/config +++ b/scripts/config @@ -62,8 +62,7 @@ if [ "$1" = "--file" ]; then if [ "$FN" = "" ] ; then usage fi - shift - shift + shift 2 else FN=.config fi @@ -76,26 +75,34 @@ while [ "$1" != "" ] ; do CMD="$1" shift case "$CMD" in - --enable|-e) + --refresh) + ;; + --*-after) + checkarg "$1" + A=$ARG + checkarg "$2" + B=$ARG + shift 2 + ;; + --*) checkarg "$1" - set_var "CONFIG_$ARG" "CONFIG_$ARG=y" shift ;; + esac + case "$CMD" in + --enable|-e) + set_var "CONFIG_$ARG" "CONFIG_$ARG=y" + ;; --disable|-d) - checkarg "$1" set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set" - shift ;; --module|-m) - checkarg "$1" set_var "CONFIG_$ARG" "CONFIG_$ARG=m" - shift ;; --state|-s) - checkarg "$1" if grep -q "# CONFIG_$ARG is not set" $FN ; then echo n else @@ -108,37 +115,18 @@ while [ "$1" != "" ] ; do echo "$V" fi fi - shift ;; --enable-after|-E) - checkarg "$1" - A=$ARG - checkarg "$2" - B=$ARG set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A" - shift - shift ;; --disable-after|-D) - checkarg "$1" - A=$ARG - checkarg "$2" - B=$ARG set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A" - shift - shift ;; --module-after|-M) - checkarg "$1" - A=$ARG - checkarg "$2" - B=$ARG set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A" - shift - shift ;; # undocumented because it ignores --file (fixme) -- cgit v1.2.3 From 1f990cf94559e0a7363d56aade1d5dc6c515b60b Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Mon, 25 May 2009 16:43:27 +0200 Subject: kbuild: add generic --set-str option to scripts/config Signed-off-by: Michal Marek Signed-off-by: Sam Ravnborg --- scripts/config | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'scripts/config') diff --git a/scripts/config b/scripts/config index 640c6fe4d644..608d7fdb13e8 100755 --- a/scripts/config +++ b/scripts/config @@ -9,8 +9,10 @@ config options command ... commands: --enable|-e option Enable option --disable|-d option Disable option - --module|-m option Turn option into a module - --state|-s option Print state of option (n,y,m,undef) + --module|-m option Turn option into a module + --set-str option value + Set option to "value" + --state|-s option Print state of option (n,y,m,undef) --enable-after|-E beforeopt option Enable option directly after other option @@ -102,6 +104,11 @@ while [ "$1" != "" ] ; do set_var "CONFIG_$ARG" "CONFIG_$ARG=m" ;; + --set-str) + set_var "CONFIG_$ARG" "CONFIG_$ARG=\"$1\"" + shift + ;; + --state|-s) if grep -q "# CONFIG_$ARG is not set" $FN ; then echo n -- cgit v1.2.3