summaryrefslogtreecommitdiffstats
path: root/meta/files/toolchain-shar-relocate.sh
diff options
context:
space:
mode:
Diffstat (limited to 'meta/files/toolchain-shar-relocate.sh')
-rw-r--r--meta/files/toolchain-shar-relocate.sh27
1 files changed, 16 insertions, 11 deletions
diff --git a/meta/files/toolchain-shar-relocate.sh b/meta/files/toolchain-shar-relocate.sh
index 5433741296..c7170349db 100644
--- a/meta/files/toolchain-shar-relocate.sh
+++ b/meta/files/toolchain-shar-relocate.sh
@@ -1,12 +1,15 @@
1if ! xargs --version > /dev/null 2>&1; then 1for cmd in xargs file; do
2 echo "xargs is required by the relocation script, please install it first. Abort!" 2 if ! command -v $cmd > /dev/null 2>&1; then
3 exit 1 3 echo "The command '$cmd' is required by the relocation script, please install it first. Abort!"
4fi 4 exit 1
5 fi
6done
5 7
6# fix dynamic loader paths in all ELF SDK binaries 8# fix dynamic loader paths in all ELF SDK binaries
9# allow symlinks to be accessed via the find command too
7native_sysroot=$($SUDO_EXEC cat $env_setup_script |grep 'OECORE_NATIVE_SYSROOT='|cut -d'=' -f2|tr -d '"') 10native_sysroot=$($SUDO_EXEC cat $env_setup_script |grep 'OECORE_NATIVE_SYSROOT='|cut -d'=' -f2|tr -d '"')
8dl_path=$($SUDO_EXEC find $native_sysroot/lib -name "ld-linux*") 11dl_paths=$($SUDO_EXEC find $native_sysroot/lib*/ -maxdepth 1 -name "ld-linux*")
9if [ "$dl_path" = "" ] ; then 12if [ "$dl_paths" = "" ] ; then
10 echo "SDK could not be set up. Relocate script unable to find ld-linux.so. Abort!" 13 echo "SDK could not be set up. Relocate script unable to find ld-linux.so. Abort!"
11 exit 1 14 exit 1
12fi 15fi
@@ -36,7 +39,9 @@ if [ x\${PYTHON} = "x" ]; then
36 echo "SDK could not be relocated. No python found." 39 echo "SDK could not be relocated. No python found."
37 exit 1 40 exit 1
38fi 41fi
39\${PYTHON} ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files 42for dl_path in \$(echo "$dl_paths"); do
43 \${PYTHON} ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir \$dl_path $executable_files
44done
40EOF 45EOF
41 46
42$SUDO_EXEC mv $tdir/relocate_sdk.sh ${env_setup_script%/*}/relocate_sdk.sh 47$SUDO_EXEC mv $tdir/relocate_sdk.sh ${env_setup_script%/*}/relocate_sdk.sh
@@ -54,14 +59,14 @@ fi
54# replace the host perl with SDK perl. 59# replace the host perl with SDK perl.
55for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"; do 60for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"; do
56 $SUDO_EXEC find $replace -type f 61 $SUDO_EXEC find $replace -type f
57done | xargs -n100 file | grep ":.*\(ASCII\|script\|source\).*text" | \ 62done | xargs -d '\n' -n100 file | \
58 awk -F': ' '{printf "\"%s\"\n", $1}' | \ 63 awk -F': ' '{if (match($2, ".*(ASCII|script|source).*text")) {printf "\"%s\"\n", $1}}' | \
59 grep -Fv -e "$target_sdk_dir/environment-setup-" \ 64 grep -Fv -e "$target_sdk_dir/environment-setup-" \
60 -e "$target_sdk_dir/relocate_sdk" \ 65 -e "$target_sdk_dir/relocate_sdk" \
61 -e "$target_sdk_dir/post-relocate-setup" \ 66 -e "$target_sdk_dir/post-relocate-setup" \
62 -e "$target_sdk_dir/${0##*/}" | \ 67 -e "$target_sdk_dir/${0##*/}" | \
63 xargs -n100 $SUDO_EXEC sed -i \ 68 xargs -n100 $SUDO_EXEC sed -i \
64 -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:g" \ 69 -e "s:$SDK_BUILD_PATH:$target_sdk_dir:g" \
65 -e "s:^#! */usr/bin/perl.*:#! /usr/bin/env perl:g" \ 70 -e "s:^#! */usr/bin/perl.*:#! /usr/bin/env perl:g" \
66 -e "s: /usr/bin/perl: /usr/bin/env perl:g" 71 -e "s: /usr/bin/perl: /usr/bin/env perl:g"
67 72
@@ -72,7 +77,7 @@ fi
72 77
73# change all symlinks pointing to @SDKPATH@ 78# change all symlinks pointing to @SDKPATH@
74for l in $($SUDO_EXEC find $native_sysroot -type l); do 79for l in $($SUDO_EXEC find $native_sysroot -type l); do
75 $SUDO_EXEC ln -sfn $(readlink $l|$SUDO_EXEC sed -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:") $l 80 $SUDO_EXEC ln -sfn $(readlink $l|$SUDO_EXEC sed -e "s:$SDK_BUILD_PATH:$target_sdk_dir:") $l
76 if [ $? -ne 0 ]; then 81 if [ $? -ne 0 ]; then
77 echo "Failed to setup symlinks. Relocate script failed. Abort!" 82 echo "Failed to setup symlinks. Relocate script failed. Abort!"
78 exit 1 83 exit 1