[elbe-devel] [PATCH v3] build_sdk toolchain-shar-extract.sk.mako: only try to reloc ELF executables

Torben Hohn torben.hohn at linutronix.de
Wed Apr 24 15:40:52 CEST 2019


scripts are marked executable, but are not suposed to be relocated using
patchelf. Trying to get patchelf to relocate a script yields an error,
and stops the rlocation process.

Use file to check whether the executables are actually elf files.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/makofiles/toolchain-shar-extract.sh.mako | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/elbepack/makofiles/toolchain-shar-extract.sh.mako b/elbepack/makofiles/toolchain-shar-extract.sh.mako
index 96810aad..6951dbc3 100644
--- a/elbepack/makofiles/toolchain-shar-extract.sh.mako
+++ b/elbepack/makofiles/toolchain-shar-extract.sh.mako
@@ -280,7 +280,10 @@ if [ "$dl_path" = "" ] ; then
         exit 1
 fi
 executable_files=$($SUDO_EXEC find $native_sysroot -type f \
-        \( -perm -0100 -o -perm -0010 -o -perm -0001 \) -printf "'%h/%f' ")
+	\( -perm -0100 -o -perm -0010 -o -perm -0001 \) \
+	-exec sh -c "file {} | grep -Pi ': elf (32|64)-bit' > /dev/null" \; \
+	-printf "'%h/%f' ")
+
 if [ "x$executable_files" = "x" ]; then
    echo "SDK relocate failed, could not get executalbe files"
    exit 1
@@ -301,6 +304,14 @@ if [ x\$PATCHELF = "x"  ]; then
         exit 1
 fi
 
+FILECMD=\`which file 2>/dev/null\`
+
+if [ x\$FILECMD = "x"  ]; then
+	echo "SDK could not be relocated. No file command found."
+        echo "use 'sudo apt install file' on Debian"
+        exit 1
+fi
+
 for exe in $executable_files; do
         if [ \`readlink -f \$exe\` == \`readlink -f $dl_path\` ]; then
             echo SKIP \$exe
-- 
2.11.0




More information about the elbe-devel mailing list