* [PATCH] kheaders: use `command -v` to test for existence of `cpio`
@ 2024-05-28 16:31 Miguel Ojeda
2024-05-29 9:42 ` Masahiro Yamada
0 siblings, 1 reply; 2+ messages in thread
From: Miguel Ojeda @ 2024-05-28 16:31 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Thomas Weißschuh, linux-kbuild, linux-kernel, patches,
Miguel Ojeda
Commit 13e1df09284d ("kheaders: explicitly validate existence of cpio
command") added an explicit check for `cpio` using `type`.
However, `type` in `dash` (which is used in some popular distributions
and base images as the shell script runner) prints the missing message
to standard output, and thus no error is printed:
$ bash -c 'type missing >/dev/null'
bash: line 1: type: missing: not found
$ dash -c 'type missing >/dev/null'
$
For instance, this issue may be seen by loongarch builders, given its
defconfig enables CONFIG_IKHEADERS since commit 9cc1df421f00 ("LoongArch:
Update Loongson-3 default config file").
Therefore, use `command -v` instead to have consistent behavior, and
take the chance to provide a more explicit error.
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
| 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--git a/kernel/gen_kheaders.sh b/kernel/gen_kheaders.sh
index 6d443ea22bb7..4ba5fd3d73ae 100755
--- a/kernel/gen_kheaders.sh
+++ b/kernel/gen_kheaders.sh
@@ -14,7 +14,12 @@ include/
arch/$SRCARCH/include/
"
-type cpio > /dev/null
+if ! command -v cpio >/dev/null; then
+ echo >&2 "***"
+ echo >&2 "*** 'cpio' could not be found."
+ echo >&2 "***"
+ exit 1
+fi
# Support incremental builds by skipping archive generation
# if timestamps of files being archived are not changed.
base-commit: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
--
2.45.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kheaders: use `command -v` to test for existence of `cpio`
2024-05-28 16:31 [PATCH] kheaders: use `command -v` to test for existence of `cpio` Miguel Ojeda
@ 2024-05-29 9:42 ` Masahiro Yamada
0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2024-05-29 9:42 UTC (permalink / raw)
To: Miguel Ojeda; +Cc: Thomas Weißschuh, linux-kbuild, linux-kernel, patches
On Wed, May 29, 2024 at 1:32 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Commit 13e1df09284d ("kheaders: explicitly validate existence of cpio
> command") added an explicit check for `cpio` using `type`.
>
> However, `type` in `dash` (which is used in some popular distributions
> and base images as the shell script runner) prints the missing message
> to standard output, and thus no error is printed:
>
> $ bash -c 'type missing >/dev/null'
> bash: line 1: type: missing: not found
> $ dash -c 'type missing >/dev/null'
> $
>
> For instance, this issue may be seen by loongarch builders, given its
> defconfig enables CONFIG_IKHEADERS since commit 9cc1df421f00 ("LoongArch:
> Update Loongson-3 default config file").
>
> Therefore, use `command -v` instead to have consistent behavior, and
> take the chance to provide a more explicit error.
>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> kernel/gen_kheaders.sh | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/gen_kheaders.sh b/kernel/gen_kheaders.sh
> index 6d443ea22bb7..4ba5fd3d73ae 100755
> --- a/kernel/gen_kheaders.sh
> +++ b/kernel/gen_kheaders.sh
> @@ -14,7 +14,12 @@ include/
> arch/$SRCARCH/include/
> "
>
> -type cpio > /dev/null
> +if ! command -v cpio >/dev/null; then
> + echo >&2 "***"
> + echo >&2 "*** 'cpio' could not be found."
> + echo >&2 "***"
> + exit 1
> +fi
>
> # Support incremental builds by skipping archive generation
> # if timestamps of files being archived are not changed.
>
> base-commit: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
> --
> 2.45.1
>
Ah, right.
'command -v' is more portable.
Applied to linux-kbuild.
Thanks!
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-29 9:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-28 16:31 [PATCH] kheaders: use `command -v` to test for existence of `cpio` Miguel Ojeda
2024-05-29 9:42 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox