* [PATCH] scripts/config: allow "O=config-dir" option
@ 2021-10-31 6:33 Randy Dunlap
2021-11-02 15:38 ` Nicolas Schier
0 siblings, 1 reply; 3+ messages in thread
From: Randy Dunlap @ 2021-10-31 6:33 UTC (permalink / raw)
To: linux-kernel
Cc: Randy Dunlap, Masahiro Yamada, Nick Desaulniers, linux-kbuild,
Andi Kleen
Support "O=config-dir" as the location of the .config file
like (some) other kernel build (make) tools do.
Someone asked for this "feature" a few months ago but I don't
recall who it was.
Also check for the existence of the config-dir/config-file
and report if there is no such file instead of letting grep
report that there is no such file.
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: linux-kbuild@vger.kernel.org
Cc: Andi Kleen <ak@linux.intel.com>
---
scripts/config | 44 +++++++++++++++++++++++++++++++++++++++-----
1 file changed, 39 insertions(+), 5 deletions(-)
--- linux-next-20211029.orig/scripts/config
+++ linux-next-20211029/scripts/config
@@ -37,6 +37,7 @@ commands:
options:
--file config-file .config file to change (default .config)
+ O=config-dir Specify the directory location of the config-file
--keep-case|-k Keep next symbols' case (dont' upper-case it)
$myname doesn't check the validity of the .config file. This is done at next
@@ -124,15 +125,48 @@ undef_var() {
txt_delete "^# $name is not set" "$FN"
}
-if [ "$1" = "--file" ]; then
- FN="$2"
- if [ "$FN" = "" ] ; then
+DIR=
+FN=
+
+while [ "$DIR" = "" -o "$FN" = "" ]; do
+
+ if [ "$1" = "" ] ; then
usage
fi
- shift 2
-else
+ if [ "$1" = "--file" ]; then
+ FN="$2"
+ if [ "$FN" = "" ] ; then
+ usage
+ fi
+ shift 2
+ continue
+ fi
+
+ optn=$1
+ optnlen=${#optn}
+ if [ $optnlen -gt 1 ] && [ ${optn:0:2} = "O=" ]; then
+ DIR=${optn:2}
+ shift
+ if [ "$DIR" = "" ]; then
+ usage
+ fi
+ continue
+ fi
+ break # something other than --file or O=dir
+done
+
+if [ "$FN" = "" ]; then
FN=.config
fi
+if [ "$DIR" != "" ]; then
+ DIR=$DIR"/"
+fi
+FN="$DIR""$FN"
+
+if [ ! -r $FN ]; then
+ echo "No such config file: $FN"
+ exit
+fi
if [ "$1" = "" ] ; then
usage
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scripts/config: allow "O=config-dir" option
2021-10-31 6:33 [PATCH] scripts/config: allow "O=config-dir" option Randy Dunlap
@ 2021-11-02 15:38 ` Nicolas Schier
2021-11-02 22:38 ` Randy Dunlap
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Schier @ 2021-11-02 15:38 UTC (permalink / raw)
To: Randy Dunlap
Cc: linux-kernel, Masahiro Yamada, Nick Desaulniers, linux-kbuild,
Andi Kleen
On Sat, Oct 30, 2021 at 11:33:22PM -0700, Randy Dunlap wrote:
> Support "O=config-dir" as the location of the .config file
> like (some) other kernel build (make) tools do.
>
> Someone asked for this "feature" a few months ago but I don't
> recall who it was.
>
> Also check for the existence of the config-dir/config-file
> and report if there is no such file instead of letting grep
> report that there is no such file.
>
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Masahiro Yamada <masahiroy@kernel.org>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> Cc: linux-kbuild@vger.kernel.org
> Cc: Andi Kleen <ak@linux.intel.com>
> ---
> scripts/config | 44 +++++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 39 insertions(+), 5 deletions(-)
>
> --- linux-next-20211029.orig/scripts/config
> +++ linux-next-20211029/scripts/config
> @@ -37,6 +37,7 @@ commands:
>
> options:
> --file config-file .config file to change (default .config)
> + O=config-dir Specify the directory location of the config-file
> --keep-case|-k Keep next symbols' case (dont' upper-case it)
>
> $myname doesn't check the validity of the .config file. This is done at next
> @@ -124,15 +125,48 @@ undef_var() {
> txt_delete "^# $name is not set" "$FN"
> }
>
> -if [ "$1" = "--file" ]; then
> - FN="$2"
> - if [ "$FN" = "" ] ; then
> +DIR=
> +FN=
> +
> +while [ "$DIR" = "" -o "$FN" = "" ]; do
shellcheck recommends to use [ .. ] || [ .. ] instead of [ .. -o .. ].
> +
> + if [ "$1" = "" ] ; then
> usage
> fi
> - shift 2
> -else
> + if [ "$1" = "--file" ]; then
> + FN="$2"
> + if [ "$FN" = "" ] ; then
> + usage
> + fi
> + shift 2
> + continue
> + fi
> +
> + optn=$1
> + optnlen=${#optn}
> + if [ $optnlen -gt 1 ] && [ ${optn:0:2} = "O=" ]; then
> + DIR=${optn:2}
> + shift
> + if [ "$DIR" = "" ]; then
> + usage
> + fi
> + continue
> + fi
> + break # something other than --file or O=dir
> +done
> +
> +if [ "$FN" = "" ]; then
> FN=.config
> fi
> +if [ "$DIR" != "" ]; then
> + DIR=$DIR"/"
> +fi
> +FN="$DIR""$FN"
A bike shed colour thing: I'd prefer quotes around the complete right
hand side, e.g. "${DIR}/${FN}".
> +
> +if [ ! -r $FN ]; then
^^^
$FN needs quotes, otherwise it may lead to syntax errors, e.g. if FN
contains spaces or other syntactical things.
I do like that feature!
With quotes round $FN:
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
> + echo "No such config file: $FN"
> + exit
> +fi
>
> if [ "$1" = "" ] ; then
> usage
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scripts/config: allow "O=config-dir" option
2021-11-02 15:38 ` Nicolas Schier
@ 2021-11-02 22:38 ` Randy Dunlap
0 siblings, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2021-11-02 22:38 UTC (permalink / raw)
To: Nicolas Schier
Cc: linux-kernel, Masahiro Yamada, Nick Desaulniers, linux-kbuild,
Andi Kleen
On 11/2/21 8:38 AM, Nicolas Schier wrote:
> On Sat, Oct 30, 2021 at 11:33:22PM -0700, Randy Dunlap wrote:
>> Support "O=config-dir" as the location of the .config file
>> like (some) other kernel build (make) tools do.
>>
>> Someone asked for this "feature" a few months ago but I don't
>> recall who it was.
>>
>> Also check for the existence of the config-dir/config-file
>> and report if there is no such file instead of letting grep
>> report that there is no such file.
>>
>> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
>> Cc: Masahiro Yamada <masahiroy@kernel.org>
>> Cc: Nick Desaulniers <ndesaulniers@google.com>
>> Cc: linux-kbuild@vger.kernel.org
>> Cc: Andi Kleen <ak@linux.intel.com>
>> ---
>> scripts/config | 44 +++++++++++++++++++++++++++++++++++++++-----
>> 1 file changed, 39 insertions(+), 5 deletions(-)
>>
> I do like that feature!
>
> With quotes round $FN:
> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
Thanks, I'll do those changes and resend it.
--
~Randy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-02 22:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-31 6:33 [PATCH] scripts/config: allow "O=config-dir" option Randy Dunlap
2021-11-02 15:38 ` Nicolas Schier
2021-11-02 22:38 ` Randy Dunlap
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.