kheaders: use `command -v` to test for existence of `cpio`

Commit 13e1df0928 ("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 9cc1df421f ("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.

Fixes: 13e1df0928 ("kheaders: explicitly validate existence of cpio command")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
Miguel Ojeda 2024-05-28 18:31:50 +02:00 committed by Masahiro Yamada
parent 3bd27a847a
commit 6e58e01735
1 changed files with 6 additions and 1 deletions

View File

@ -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.