summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/populate_sdk_base.bbclass10
-rw-r--r--meta/files/toolchain-shar-extract.sh (renamed from meta/files/toolchain-shar-template.sh)53
-rw-r--r--meta/files/toolchain-shar-relocate.sh50
3 files changed, 59 insertions, 54 deletions
diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass
index e3adacb2c9..5c0769373a 100644
--- a/meta/classes/populate_sdk_base.bbclass
+++ b/meta/classes/populate_sdk_base.bbclass
@@ -52,6 +52,7 @@ EXCLUDE_FROM_WORLD = "1"
52 52
53SDK_PACKAGING_FUNC ?= "create_shar" 53SDK_PACKAGING_FUNC ?= "create_shar"
54SDK_POST_INSTALL_COMMAND ?= "" 54SDK_POST_INSTALL_COMMAND ?= ""
55SDK_RELOCATE_AFTER_INSTALL ?= "1"
55 56
56SDK_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.manifest" 57SDK_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.manifest"
57python write_target_sdk_manifest () { 58python write_target_sdk_manifest () {
@@ -116,9 +117,14 @@ fakeroot tar_sdk() {
116 117
117fakeroot create_shar() { 118fakeroot create_shar() {
118 # copy in the template shar extractor script 119 # copy in the template shar extractor script
119 cp ${COREBASE}/meta/files/toolchain-shar-template.sh ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh 120 cp ${COREBASE}/meta/files/toolchain-shar-extract.sh ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh
120 121
121 cat << "EOF" > ${T}/post_install_command 122 rm -f ${T}/post_install_command
123
124 if [ ${SDK_RELOCATE_AFTER_INSTALL} -eq 1 ] ; then
125 cp ${COREBASE}/meta/files/toolchain-shar-relocate.sh ${T}/post_install_command
126 fi
127 cat << "EOF" >> ${T}/post_install_command
122${SDK_POST_INSTALL_COMMAND} 128${SDK_POST_INSTALL_COMMAND}
123EOF 129EOF
124 sed -i -e '/@SDK_POST_INSTALL_COMMAND@/r ${T}/post_install_command' ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh 130 sed -i -e '/@SDK_POST_INSTALL_COMMAND@/r ${T}/post_install_command' ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh
diff --git a/meta/files/toolchain-shar-template.sh b/meta/files/toolchain-shar-extract.sh
index 151b973d35..516aa3a142 100644
--- a/meta/files/toolchain-shar-template.sh
+++ b/meta/files/toolchain-shar-extract.sh
@@ -139,63 +139,12 @@ for env_setup_script in `ls $target_sdk_dir/environment-setup-*`; do
139 $SUDO_EXEC sed -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:g" -i $env_setup_script 139 $SUDO_EXEC sed -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:g" -i $env_setup_script
140done 140done
141 141
142# fix dynamic loader paths in all ELF SDK binaries
143native_sysroot=$($SUDO_EXEC cat $env_setup_script |grep 'OECORE_NATIVE_SYSROOT='|cut -d'=' -f2|tr -d '"')
144dl_path=$($SUDO_EXEC find $native_sysroot/lib -name "ld-linux*")
145if [ "$dl_path" = "" ] ; then
146 echo "SDK could not be set up. Relocate script unable to find ld-linux.so. Abort!"
147 exit 1
148fi
149executable_files=$($SUDO_EXEC find $native_sysroot -type f \
150 \( -perm -0100 -o -perm -0010 -o -perm -0001 \) -printf "'%h/%f' ")
151
152tdir=`mktemp -d`
153if [ x$tdir = x ] ; then
154 echo "SDK relocate failed, could not create a temporary directory"
155 exit 1
156fi
157echo "#!/bin/bash" > $tdir/relocate_sdk.sh
158echo exec ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files >> $tdir/relocate_sdk.sh
159$SUDO_EXEC mv $tdir/relocate_sdk.sh ${env_setup_script%/*}/relocate_sdk.sh
160$SUDO_EXEC chmod 755 ${env_setup_script%/*}/relocate_sdk.sh
161rm -rf $tdir
162if [ $relocate = 1 ] ; then
163 $SUDO_EXEC ${env_setup_script%/*}/relocate_sdk.sh
164 if [ $? -ne 0 ]; then
165 echo "SDK could not be set up. Relocate script failed. Abort!"
166 exit 1
167 fi
168fi
169
170# replace @SDKPATH@ with the new prefix in all text files: configs/scripts/etc
171for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"; do
172 $SUDO_EXEC find $replace -type f -exec file '{}' \; | \
173 grep ":.*\(ASCII\|script\|source\).*text" | \
174 awk -F':' '{printf "\"%s\"\n", $1}' | \
175 grep -v "$target_sdk_dir/environment-setup-*" | \
176 $SUDO_EXEC xargs -n32 sed -i -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:g"
177done
178
179# change all symlinks pointing to @SDKPATH@
180for l in $($SUDO_EXEC find $native_sysroot -type l); do
181 $SUDO_EXEC ln -sfn $(readlink $l|$SUDO_EXEC sed -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:") $l
182done
183
184# find out all perl scripts in $native_sysroot and modify them replacing the
185# host perl with SDK perl.
186for perl_script in $($SUDO_EXEC find $native_sysroot -type f -exec grep -l "^#!.*perl" '{}' \;); do
187 $SUDO_EXEC sed -i -e "s:^#! */usr/bin/perl.*:#! /usr/bin/env perl:g" -e \
188 "s: /usr/bin/perl: /usr/bin/env perl:g" $perl_script
189done
190
191echo done
192
193@SDK_POST_INSTALL_COMMAND@ 142@SDK_POST_INSTALL_COMMAND@
194 143
195# delete the relocating script, so that user is forced to re-run the installer 144# delete the relocating script, so that user is forced to re-run the installer
196# if he/she wants another location for the sdk 145# if he/she wants another location for the sdk
197if [ $savescripts = 0 ] ; then 146if [ $savescripts = 0 ] ; then
198 $SUDO_EXEC rm ${env_setup_script%/*}/relocate_sdk.py ${env_setup_script%/*}/relocate_sdk.sh 147 $SUDO_EXEC rm -f ${env_setup_script%/*}/relocate_sdk.py ${env_setup_script%/*}/relocate_sdk.sh
199fi 148fi
200 149
201echo "SDK has been successfully set up and is ready to be used." 150echo "SDK has been successfully set up and is ready to be used."
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
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
29# replace @SDKPATH@ with the new prefix in all text files: configs/scripts/etc
30for 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"
36done
37
38# change all symlinks pointing to @SDKPATH@
39for 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
41done
42
43# find out all perl scripts in $native_sysroot and modify them replacing the
44# host perl with SDK perl.
45for 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
48done
49
50echo done