Skip to contentSkip to conversation

toolchain-shar-relocate.sh: Add check for missing command 'file'

PATCH Superseded Tom Hochstein 2 participants 3 messages Mar 16, 2024 – Mar 21, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toolchain-shar-relocate.sh: Add check for missing command 'file'

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!
```
---
 meta/files/toolchain-shar-relocate.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
meta/files/toolchain-shar-relocate.sh +6 -4
index e8ab357717..3d55e38102 100644
@@ -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; 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
Signature · 1 line
2.25.1
#1 lore raw

Hello Tom,

Quoted 25 lines · Tom Hochstein

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!
```
---
 meta/files/toolchain-shar-relocate.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
meta/files/toolchain-shar-relocate.sh +0 -0
index e8ab357717..3d55e38102 100644

meta/files/toolchain-shar-relocate.sh line 2

Quoted 6 lines
meta/files/toolchain-shar-relocate.sh +2 -4
@@ -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; then

This fails on some of our builders:
https://autobuilder.yoctoproject.org/typhoon/#/builders/20/builds/9148/steps/12/logs/stdio

Quoted 20 lines
meta/files/toolchain-shar-relocate.sh +4 -0
+		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
Signature · 11 lines
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#197256): https://lists.openembedded.org/g/openembedded-core/message/197256
Mute This Topic: https://lists.openembedded.org/mt/104970783/3617179
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

Thanks Alexandre,

Quoted 23 lines · Alexandre Belloni

Hello Tom,

Quoted 20 lines · Tom Hochstein

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!
```
---
  meta/files/toolchain-shar-relocate.sh | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
Quoted 13 lines

meta/files/toolchain-shar-relocate.sh line 2

Quoted 11 lines
meta/files/toolchain-shar-relocate.sh +2 -4
index e8ab357717..3d55e38102 100644
@@ -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; then

This fails on some of our builders:
https://autobuilder.yoctoproject.org/typhoon/#/builders/20/builds/9148/steps/12/logs/stdio

Aha, looks like &> is a bashism. V2 coming.

Quoted 20 lines
Quoted 19 lines
meta/files/toolchain-shar-relocate.sh +4 -0
+		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
Signature · 9 lines
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#197256): https://lists.openembedded.org/g/openembedded-core/message/197256
Mute This Topic: https://lists.openembedded.org/mt/104970783/3617179
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-