diff options
Diffstat (limited to 'meta/files/toolchain-shar-relocate.sh')
-rw-r--r-- | meta/files/toolchain-shar-relocate.sh | 27 |
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 @@ | |||
1 | if ! xargs --version > /dev/null 2>&1; then | 1 | for 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!" |
4 | fi | 4 | exit 1 |
5 | fi | ||
6 | done | ||
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 | ||
7 | native_sysroot=$($SUDO_EXEC cat $env_setup_script |grep 'OECORE_NATIVE_SYSROOT='|cut -d'=' -f2|tr -d '"') | 10 | native_sysroot=$($SUDO_EXEC cat $env_setup_script |grep 'OECORE_NATIVE_SYSROOT='|cut -d'=' -f2|tr -d '"') |
8 | dl_path=$($SUDO_EXEC find $native_sysroot/lib -name "ld-linux*") | 11 | dl_paths=$($SUDO_EXEC find $native_sysroot/lib*/ -maxdepth 1 -name "ld-linux*") |
9 | if [ "$dl_path" = "" ] ; then | 12 | if [ "$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 |
12 | fi | 15 | fi |
@@ -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 |
38 | fi | 41 | fi |
39 | \${PYTHON} ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files | 42 | for dl_path in \$(echo "$dl_paths"); do |
43 | \${PYTHON} ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir \$dl_path $executable_files | ||
44 | done | ||
40 | EOF | 45 | EOF |
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. |
55 | for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"; do | 60 | for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"; do |
56 | $SUDO_EXEC find $replace -type f | 61 | $SUDO_EXEC find $replace -type f |
57 | done | xargs -n100 file | grep ":.*\(ASCII\|script\|source\).*text" | \ | 62 | done | 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@ |
74 | for l in $($SUDO_EXEC find $native_sysroot -type l); do | 79 | for 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 |