]> git.sur5r.net Git - kconfig-frontends/commitdiff
utils/tweak: use ./configured config prefix
authorYann E. MORIN" <yann.morin.1998@free.fr>
Sun, 3 Jun 2012 20:06:04 +0000 (22:06 +0200)
committerYann E. MORIN" <yann.morin.1998@free.fr>
Sun, 3 Jun 2012 20:06:04 +0000 (22:06 +0200)
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
.hgignore
scripts/ksync.list
utils/Makefile.am
utils/tweak [deleted file]
utils/tweak.in [new file with mode: 0644]
utils/tweak.in.patch [new file with mode: 0644]
utils/tweak.patch [deleted file]

index b2a8e12a978fb3f9c7b120ad02236da754060ce1..66f8316b7cfba3544ad40895a68e3e4c83603e30 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -25,6 +25,7 @@ libs/images/images.h
 libs/parser/?conf.c
 libs/*/.libs
 
+utils/tweak
 utils/gettext
 utils/*-gettext
 utils/.libs
index 4908efe28ece22bcb6ad0b43b8f6622e78be3431..45f19dc8ec8c9a89b01891c7d2c9ce4dace73b0a 100644 (file)
@@ -27,7 +27,7 @@ scripts/kconfig/menu.c                            -->  libs/parser/menu.c
 scripts/kconfig/symbol.c                          -->  libs/parser/symbol.c
 scripts/kconfig/util.c                            -->  libs/parser/util.c
 scripts/kconfig/zconf.y                           -->  libs/parser/yconf.y
-scripts/config                                    -->  utils/tweak
+scripts/config                                    -->  utils/tweak.in
 scripts/diffconfig                                -->  utils/diff
 scripts/kconfig/merge_config.sh                   -->  utils/merge
 scripts/kconfig/streamline_config.pl              -->  utils/streamline
index 843c696f6a7850d72adcb51ad6f05892dd0b5e78..b5cab00db6c880f28bfbf484cade8e0b688d0b33 100644 (file)
@@ -1,5 +1,5 @@
-dist_bin_SCRIPTS =  tweak diff merge
-dist_bin_SCRIPTS += streamline
+bin_SCRIPTS =  tweak
+dist_bin_SCRIPTS = diff merge streamline
 
 if COND_utils_gettext
     MAYBE_utils_gettext = gettext
@@ -12,3 +12,10 @@ gettext_CPPFLAGS = $(AM_CPPFLAGS)   \
 gettext_CFLAGS = $(AM_CFLAGS) $(kf_CFLAGS)
 gettext_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la    \
                 $(intl_LIBS)
+CLEANFILES = tweak
+EXTRA_DIST = tweak.in tweak.in.patch
+
+tweak: tweak.in
+       $(AM_V_GEN)$(SED) -r -e "s/@CONFIG_@/$(config_prefix)/g"    \
+                         $< >$@
+       @chmod +x $@
diff --git a/utils/tweak b/utils/tweak
deleted file mode 100755 (executable)
index 80d29a1..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-#!/bin/bash
-# Manipulate options in a .config file from the command line
-
-usage() {
-       cat >&2 <<EOL
-Manipulate options in a .config file from the command line.
-Usage:
-config options command ...
-commands:
-       --enable|-e option   Enable option
-       --disable|-d option  Disable option
-       --module|-m option   Turn option into a module
-       --set-str option string
-                            Set option to "string"
-       --set-val 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
-       --disable-after|-D beforeopt option
-                             Disable option directly after other option
-       --module-after|-M beforeopt option
-                             Turn option into module directly after other option
-
-       commands can be repeated multiple times
-
-options:
-       --file .config file to change (default .config)
-
-config doesn't check the validity of the .config file. This is done at next
- make time.
-EOL
-       exit 1
-}
-
-checkarg() {
-       ARG="$1"
-       if [ "$ARG" = "" ] ; then
-               usage
-       fi
-       case "$ARG" in
-       CONFIG_*)
-               ARG="${ARG/CONFIG_/}"
-               ;;
-       esac
-}
-
-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
-       FN="$2"
-       if [ "$FN" = "" ] ; then
-               usage
-       fi
-       shift 2
-else
-       FN=.config
-fi
-
-if [ "$1" = "" ] ; then
-       usage
-fi
-
-while [ "$1" != "" ] ; do
-       CMD="$1"
-       shift
-       case "$CMD" in
-       --refresh)
-               ;;
-       --*-after)
-               checkarg "$1"
-               A=$ARG
-               checkarg "$2"
-               B=$ARG
-               shift 2
-               ;;
-       -*)
-               checkarg "$1"
-               shift
-               ;;
-       esac
-       case "$CMD" in
-       --enable|-e)
-               set_var "CONFIG_$ARG" "CONFIG_$ARG=y"
-               ;;
-
-       --disable|-d)
-               set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set"
-               ;;
-
-       --module|-m)
-               set_var "CONFIG_$ARG" "CONFIG_$ARG=m"
-               ;;
-
-       --set-str)
-               # sed swallows one level of escaping, so we need double-escaping
-               set_var "CONFIG_$ARG" "CONFIG_$ARG=\"${1//\"/\\\\\"}\""
-               shift
-               ;;
-
-       --set-val)
-               set_var "CONFIG_$ARG" "CONFIG_$ARG=$1"
-               shift
-               ;;
-
-       --state|-s)
-               if grep -q "# CONFIG_$ARG is not set" $FN ; then
-                       echo n
-               else
-                       V="$(grep "^CONFIG_$ARG=" $FN)"
-                       if [ $? != 0 ] ; then
-                               echo undef
-                       else
-                               V="${V/#CONFIG_$ARG=/}"
-                               V="${V/#\"/}"
-                               V="${V/%\"/}"
-                               V="${V/\\\"/\"}"
-                               echo "${V}"
-                       fi
-               fi
-               ;;
-
-       --enable-after|-E)
-               set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A"
-               ;;
-
-       --disable-after|-D)
-               set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A"
-               ;;
-
-       --module-after|-M)
-               set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A"
-               ;;
-
-       # undocumented because it ignores --file (fixme)
-       --refresh)
-               yes "" | make oldconfig
-               ;;
-
-       *)
-               usage
-               ;;
-       esac
-done
-
diff --git a/utils/tweak.in b/utils/tweak.in
new file mode 100644 (file)
index 0000000..ef7a64a
--- /dev/null
@@ -0,0 +1,160 @@
+#!/bin/bash
+# Manipulate options in a .config file from the command line
+
+CONFIG_="@CONFIG_@"
+
+usage() {
+       cat >&2 <<EOL
+Manipulate options in a .config file from the command line.
+Usage:
+config options command ...
+commands:
+       --enable|-e option   Enable option
+       --disable|-d option  Disable option
+       --module|-m option   Turn option into a module
+       --set-str option string
+                            Set option to "string"
+       --set-val 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
+       --disable-after|-D beforeopt option
+                             Disable option directly after other option
+       --module-after|-M beforeopt option
+                             Turn option into module directly after other option
+
+       commands can be repeated multiple times
+
+options:
+       --file .config file to change (default .config)
+
+config doesn't check the validity of the .config file. This is done at next
+ make time.
+EOL
+       exit 1
+}
+
+checkarg() {
+       ARG="$1"
+       if [ "$ARG" = "" ] ; then
+               usage
+       fi
+       case "$ARG" in
+       ${CONFIG_}*)
+               ARG="${ARG/${CONFIG_}/}"
+               ;;
+       esac
+}
+
+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
+       FN="$2"
+       if [ "$FN" = "" ] ; then
+               usage
+       fi
+       shift 2
+else
+       FN=.config
+fi
+
+if [ "$1" = "" ] ; then
+       usage
+fi
+
+while [ "$1" != "" ] ; do
+       CMD="$1"
+       shift
+       case "$CMD" in
+       --refresh)
+               ;;
+       --*-after)
+               checkarg "$1"
+               A=$ARG
+               checkarg "$2"
+               B=$ARG
+               shift 2
+               ;;
+       -*)
+               checkarg "$1"
+               shift
+               ;;
+       esac
+       case "$CMD" in
+       --enable|-e)
+               set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
+               ;;
+
+       --disable|-d)
+               set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
+               ;;
+
+       --module|-m)
+               set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
+               ;;
+
+       --set-str)
+               # sed swallows one level of escaping, so we need double-escaping
+               set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
+               shift
+               ;;
+
+       --set-val)
+               set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
+               shift
+               ;;
+
+       --state|-s)
+               if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
+                       echo n
+               else
+                       V="$(grep "^${CONFIG_}$ARG=" $FN)"
+                       if [ $? != 0 ] ; then
+                               echo undef
+                       else
+                               V="${V/#${CONFIG_}$ARG=/}"
+                               V="${V/#\"/}"
+                               V="${V/%\"/}"
+                               V="${V/\\\"/\"}"
+                               echo "${V}"
+                       fi
+               fi
+               ;;
+
+       --enable-after|-E)
+               set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
+               ;;
+
+       --disable-after|-D)
+               set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A"
+               ;;
+
+       --module-after|-M)
+               set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
+               ;;
+
+       # undocumented because it ignores --file (fixme)
+       --refresh)
+               yes "" | make oldconfig
+               ;;
+
+       *)
+               usage
+               ;;
+       esac
+done
+
diff --git a/utils/tweak.in.patch b/utils/tweak.in.patch
new file mode 100644 (file)
index 0000000..fe8ca68
--- /dev/null
@@ -0,0 +1,90 @@
+--- a/utils/tweak.in   2012-06-03 22:13:16.901125538 +0200
++++ b/utils/tweak.in   2012-06-03 22:12:59.024523108 +0200
+@@ -1,6 +1,8 @@
+ #!/bin/bash
+ # Manipulate options in a .config file from the command line
++CONFIG_="@CONFIG_@"
++
+ usage() {
+       cat >&2 <<EOL
+ Manipulate options in a .config file from the command line.
+@@ -40,11 +43,10 @@
+               usage
+       fi
+       case "$ARG" in
+-      CONFIG_*)
+-              ARG="${ARG/CONFIG_/}"
++      ${CONFIG_}*)
++              ARG="${ARG/${CONFIG_}/}"
+               ;;
+       esac
+-      ARG="`echo $ARG | tr a-z A-Z`"
+ }
+ set_var() {
+@@ -95,37 +97,37 @@
+       esac
+       case "$CMD" in
+       --enable|-e)
+-              set_var "CONFIG_$ARG" "CONFIG_$ARG=y"
++              set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
+               ;;
+       --disable|-d)
+-              set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set"
++              set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
+               ;;
+       --module|-m)
+-              set_var "CONFIG_$ARG" "CONFIG_$ARG=m"
++              set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
+               ;;
+       --set-str)
+               # sed swallows one level of escaping, so we need double-escaping
+-              set_var "CONFIG_$ARG" "CONFIG_$ARG=\"${1//\"/\\\\\"}\""
++              set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
+               shift
+               ;;
+       --set-val)
+-              set_var "CONFIG_$ARG" "CONFIG_$ARG=$1"
++              set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
+               shift
+               ;;
+       --state|-s)
+-              if grep -q "# CONFIG_$ARG is not set" $FN ; then
++              if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
+                       echo n
+               else
+-                      V="$(grep "^CONFIG_$ARG=" $FN)"
++                      V="$(grep "^${CONFIG_}$ARG=" $FN)"
+                       if [ $? != 0 ] ; then
+                               echo undef
+                       else
+-                              V="${V/#CONFIG_$ARG=/}"
++                              V="${V/#${CONFIG_}$ARG=/}"
+                               V="${V/#\"/}"
+                               V="${V/%\"/}"
+                               V="${V/\\\"/\"}"
+@@ -135,15 +137,15 @@
+               ;;
+       --enable-after|-E)
+-              set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A"
++              set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
+               ;;
+       --disable-after|-D)
+-              set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A"
++              set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A"
+               ;;
+       --module-after|-M)
+-              set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A"
++              set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
+               ;;
+       # undocumented because it ignores --file (fixme)
diff --git a/utils/tweak.patch b/utils/tweak.patch
deleted file mode 100644 (file)
index 6e29190..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-diff --git a/utils/tweak b/utils/tweak
---- a/utils/tweak
-+++ b/utils/tweak
-@@ -44,7 +44,6 @@
-               ARG="${ARG/CONFIG_/}"
-               ;;
-       esac
--      ARG="`echo $ARG | tr a-z A-Z`"
- }
- set_var() {