blob: 4ef29271712133bddf2bc825d18881380edc53a0 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# fix dynamic loader paths in all ELF SDK binaries
2native_sysroot=$($SUDO_EXEC cat $env_setup_script |grep 'OECORE_NATIVE_SYSROOT='|cut -d'=' -f2|tr -d '"')
3dl_path=$($SUDO_EXEC find $native_sysroot/lib -name "ld-linux*")
4if [ "$dl_path" = "" ] ; then
5 echo "SDK could not be set up. Relocate script unable to find ld-linux.so. Abort!"
6 exit 1
7fi
8executable_files=$($SUDO_EXEC find $native_sysroot -type f \
9 \( -perm -0100 -o -perm -0010 -o -perm -0001 \) -printf "'%h/%f' ")
10
11tdir=`mktemp -d`
12if [ x$tdir = x ] ; then
13 echo "SDK relocate failed, could not create a temporary directory"
14 exit 1
15fi
16echo "#!/bin/bash" > $tdir/relocate_sdk.sh
17echo 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
20rm -rf $tdir
21if [ $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
27fi
28
Patrick Williamsf1e5d692016-03-30 15:21:19 -050029# replace @SDKPATH@ with the new prefix in all text files: configs/scripts/etc.
30# replace the host perl with SDK perl.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"; do
Patrick Williamsf1e5d692016-03-30 15:21:19 -050032 $SUDO_EXEC find $replace -type f
33done | xargs -n100 file | grep ":.*\(ASCII\|script\|source\).*text" | \
34 awk -F':' '{printf "\"%s\"\n", $1}' | \
35 grep -v "$target_sdk_dir/environment-setup-*" | \
36 xargs -n100 $SUDO_EXEC sed -i \
37 -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:g" \
38 -e "s:^#! */usr/bin/perl.*:#! /usr/bin/env perl:g" \
39 -e "s: /usr/bin/perl: /usr/bin/env perl:g"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050040
41# change all symlinks pointing to @SDKPATH@
42for l in $($SUDO_EXEC find $native_sysroot -type l); do
43 $SUDO_EXEC ln -sfn $(readlink $l|$SUDO_EXEC sed -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:") $l
44done
45
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046echo done