diff mbox series

[[PATCH,v2] ] toolchain-shar-relocate.sh: Add check for missing command 'file'

Message ID 20240321174251.495391-1-tom.hochstein@nxp.com
State New
Headers show
Series [[PATCH,v2] ] toolchain-shar-relocate.sh: Add check for missing command 'file' | expand

Commit Message

Tom Hochstein March 21, 2024, 5:42 p.m. UTC
On a machine without the file command, the SDK install fails with a
cryptic error message.

```
xargs: file: No such file or directory
sed: no input files
Failed to replace perl. Relocate script failed. Abort!
```

Add a test for 'file' to print a clear error message.

```
The command 'file' is required by the relocation script, please install it first. Abort!
```

Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
---
 meta/files/toolchain-shar-relocate.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/meta/files/toolchain-shar-relocate.sh b/meta/files/toolchain-shar-relocate.sh
index e8ab357717..b017714df0 100644
--- a/meta/files/toolchain-shar-relocate.sh
+++ b/meta/files/toolchain-shar-relocate.sh
@@ -1,7 +1,9 @@ 
-if ! xargs --version > /dev/null 2>&1; then
-	echo "xargs is required by the relocation script, please install it first. Abort!"
-	exit 1
-fi
+for cmd in xargs file; do
+	if ! command -v $cmd > /dev/null 2>&1; then
+		echo "The command '$cmd' is required by the relocation script, please install it first. Abort!"
+		exit 1
+	fi
+done
 
 # fix dynamic loader paths in all ELF SDK binaries
 # allow symlinks to be accessed via the find command too