Skip to content

Commit

Permalink
kheaders: use command -v to test for existence of cpio
Browse files Browse the repository at this point in the history
Commit 13e1df0 ("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 9cc1df4 ("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: 13e1df0 ("kheaders: explicitly validate existence of cpio command")
Signed-off-by: Miguel Ojeda <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
ojeda authored and masahir0y committed May 29, 2024
1 parent 3bd27a8 commit 6e58e01
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kernel/gen_kheaders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6e58e01

Please sign in to comment.