diff options
author | Randy Witt <randy.e.witt@linux.intel.com> | 2015-02-23 17:00:40 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-02-24 17:41:43 +0000 |
commit | 01c9f3b390b32315f10d0ccc21f86ef5ffd3b318 (patch) | |
tree | 97dfc1a8c58d8d5ea5084a57c5d1acabb97b4f0c /meta/files/toolchain-shar-relocate.sh | |
parent | fe678e75ea7048bdbcc60022aaf2bc4b332c7538 (diff) | |
download | poky-01c9f3b390b32315f10d0ccc21f86ef5ffd3b318.tar.gz |
toolchain-shar-template.sh: Make relocation optional.
If the buildsystem is copied into the sdk and its toolchain is to
be used, then the relocation provided in toolchain-shar-template.sh
isn't needed and will actually fail.
So break the relocation aspect out and essentially make it another
SDK_POST_INSTALL_COMMAND script.
(From OE-Core rev: 9721378688a05cd8d8443c6ee4be823e5c0688f6)
Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/files/toolchain-shar-relocate.sh')
-rw-r--r-- | meta/files/toolchain-shar-relocate.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/meta/files/toolchain-shar-relocate.sh b/meta/files/toolchain-shar-relocate.sh new file mode 100644 index 0000000000..dfb8e16d7c --- /dev/null +++ b/meta/files/toolchain-shar-relocate.sh | |||
@@ -0,0 +1,50 @@ | |||
1 | # fix dynamic loader paths in all ELF SDK binaries | ||
2 | native_sysroot=$($SUDO_EXEC cat $env_setup_script |grep 'OECORE_NATIVE_SYSROOT='|cut -d'=' -f2|tr -d '"') | ||
3 | dl_path=$($SUDO_EXEC find $native_sysroot/lib -name "ld-linux*") | ||
4 | if [ "$dl_path" = "" ] ; then | ||
5 | echo "SDK could not be set up. Relocate script unable to find ld-linux.so. Abort!" | ||
6 | exit 1 | ||
7 | fi | ||
8 | executable_files=$($SUDO_EXEC find $native_sysroot -type f \ | ||
9 | \( -perm -0100 -o -perm -0010 -o -perm -0001 \) -printf "'%h/%f' ") | ||
10 | |||
11 | tdir=`mktemp -d` | ||
12 | if [ x$tdir = x ] ; then | ||
13 | echo "SDK relocate failed, could not create a temporary directory" | ||
14 | exit 1 | ||
15 | fi | ||
16 | echo "#!/bin/bash" > $tdir/relocate_sdk.sh | ||
17 | echo exec ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files >> $tdir/relocate_sdk.sh | ||
18 | $SUDO_EXEC mv $tdir/relocate_sdk.sh ${env_setup_script%/*}/relocate_sdk.sh | ||
19 | $SUDO_EXEC chmod 755 ${env_setup_script%/*}/relocate_sdk.sh | ||
20 | rm -rf $tdir | ||
21 | if [ $relocate = 1 ] ; then | ||
22 | $SUDO_EXEC ${env_setup_script%/*}/relocate_sdk.sh | ||
23 | if [ $? -ne 0 ]; then | ||
24 | echo "SDK could not be set up. Relocate script failed. Abort!" | ||
25 | exit 1 | ||
26 | fi | ||
27 | fi | ||
28 | |||
29 | # replace @SDKPATH@ with the new prefix in all text files: configs/scripts/etc | ||
30 | for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"; do | ||
31 | $SUDO_EXEC find $replace -type f -exec file '{}' \; | \ | ||
32 | grep ":.*\(ASCII\|script\|source\).*text" | \ | ||
33 | awk -F':' '{printf "\"%s\"\n", $1}' | \ | ||
34 | grep -v "$target_sdk_dir/environment-setup-*" | \ | ||
35 | $SUDO_EXEC xargs -n32 sed -i -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:g" | ||
36 | done | ||
37 | |||
38 | # change all symlinks pointing to @SDKPATH@ | ||
39 | for l in $($SUDO_EXEC find $native_sysroot -type l); do | ||
40 | $SUDO_EXEC ln -sfn $(readlink $l|$SUDO_EXEC sed -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:") $l | ||
41 | done | ||
42 | |||
43 | # find out all perl scripts in $native_sysroot and modify them replacing the | ||
44 | # host perl with SDK perl. | ||
45 | for perl_script in $($SUDO_EXEC find $native_sysroot -type f -exec grep -l "^#!.*perl" '{}' \;); do | ||
46 | $SUDO_EXEC sed -i -e "s:^#! */usr/bin/perl.*:#! /usr/bin/env perl:g" -e \ | ||
47 | "s: /usr/bin/perl: /usr/bin/env perl:g" $perl_script | ||
48 | done | ||
49 | |||
50 | echo done | ||