summaryrefslogtreecommitdiffstats
path: root/meta/files/toolchain-shar-template.sh
diff options
context:
space:
mode:
Diffstat (limited to 'meta/files/toolchain-shar-template.sh')
-rw-r--r--meta/files/toolchain-shar-template.sh205
1 files changed, 0 insertions, 205 deletions
diff --git a/meta/files/toolchain-shar-template.sh b/meta/files/toolchain-shar-template.sh
deleted file mode 100644
index 151b973d35..0000000000
--- a/meta/files/toolchain-shar-template.sh
+++ /dev/null
@@ -1,205 +0,0 @@
1#!/bin/bash
2
3INST_ARCH=$(uname -m | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/")
4SDK_ARCH=$(echo @SDK_ARCH@ | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/")
5
6verlte () {
7 [ "$1" = "`printf "$1\n$2" | sort -V | head -n1`" ]
8}
9
10verlt() {
11 [ "$1" = "$2" ] && return 1 || verlte $1 $2
12}
13
14verlt `uname -r` @OLDEST_KERNEL@
15if [ $? = 0 ]; then
16 echo "Error: The SDK needs a kernel > @OLDEST_KERNEL@"
17 exit 1
18fi
19
20if [ "$INST_ARCH" != "$SDK_ARCH" ]; then
21 # Allow for installation of ix86 SDK on x86_64 host
22 if [ "$INST_ARCH" != x86_64 -o "$SDK_ARCH" != ix86 ]; then
23 echo "Error: Installation machine not supported!"
24 exit 1
25 fi
26fi
27
28DEFAULT_INSTALL_DIR="@SDKPATH@"
29SUDO_EXEC=""
30target_sdk_dir=""
31answer=""
32relocate=1
33savescripts=0
34verbose=0
35while getopts ":yd:DRS" OPT; do
36 case $OPT in
37 y)
38 answer="Y"
39 [ "$target_sdk_dir" = "" ] && target_sdk_dir=$DEFAULT_INSTALL_DIR
40 ;;
41 d)
42 target_sdk_dir=$OPTARG
43 ;;
44 D)
45 verbose=1
46 ;;
47 R)
48 relocate=0
49 savescripts=1
50 ;;
51 S)
52 savescripts=1
53 ;;
54 *)
55 echo "Usage: $(basename $0) [-y] [-d <dir>]"
56 echo " -y Automatic yes to all prompts"
57 echo " -d <dir> Install the SDK to <dir>"
58 echo "======== Advanced DEBUGGING ONLY OPTIONS ========"
59 echo " -S Save relocation scripts"
60 echo " -R Do not relocate executables"
61 echo " -D use set -x to see what is going on"
62 exit 1
63 ;;
64 esac
65done
66
67if [ $verbose = 1 ] ; then
68 set -x
69fi
70
71if [ "$target_sdk_dir" = "" ]; then
72 read -e -p "Enter target directory for SDK (default: $DEFAULT_INSTALL_DIR): " target_sdk_dir
73 [ "$target_sdk_dir" = "" ] && target_sdk_dir=$DEFAULT_INSTALL_DIR
74fi
75
76eval target_sdk_dir=$(echo "$target_sdk_dir"|sed 's/ /\\ /g')
77if [ -d "$target_sdk_dir" ]; then
78 target_sdk_dir=$(cd "$target_sdk_dir"; pwd)
79else
80 target_sdk_dir=$(readlink -m "$target_sdk_dir")
81fi
82
83if [ -n "$(echo $target_sdk_dir|grep ' ')" ]; then
84 echo "The target directory path ($target_sdk_dir) contains spaces. Abort!"
85 exit 1
86fi
87
88if [ -e "$target_sdk_dir/environment-setup-@REAL_MULTIMACH_TARGET_SYS@" ]; then
89 echo "The directory \"$target_sdk_dir\" already contains a SDK for this architecture."
90 printf "If you continue, existing files will be overwritten! Proceed[y/N]?"
91
92 default_answer="n"
93else
94 printf "You are about to install the SDK to \"$target_sdk_dir\". Proceed[Y/n]?"
95
96 default_answer="y"
97fi
98
99if [ "$answer" = "" ]; then
100 read answer
101 [ "$answer" = "" ] && answer="$default_answer"
102else
103 echo $answer
104fi
105
106if [ "$answer" != "Y" -a "$answer" != "y" ]; then
107 echo "Installation aborted!"
108 exit 1
109fi
110
111# Try to create the directory (this will not succeed if user doesn't have rights)
112mkdir -p $target_sdk_dir >/dev/null 2>&1
113
114# if don't have the right to access dir, gain by sudo
115if [ ! -x $target_sdk_dir -o ! -w $target_sdk_dir -o ! -r $target_sdk_dir ]; then
116 SUDO_EXEC=$(which "sudo")
117 if [ -z $SUDO_EXEC ]; then
118 echo "No command 'sudo' found, please install sudo first. Abort!"
119 exit 1
120 fi
121
122 # test sudo could gain root right
123 $SUDO_EXEC pwd >/dev/null 2>&1
124 [ $? -ne 0 ] && echo "Sorry, you are not allowed to execute as root." && exit 1
125
126 # now that we have sudo rights, create the directory
127 $SUDO_EXEC mkdir -p $target_sdk_dir >/dev/null 2>&1
128fi
129
130payload_offset=$(($(grep -na -m1 "^MARKER:$" $0|cut -d':' -f1) + 1))
131
132printf "Extracting SDK..."
133tail -n +$payload_offset $0| $SUDO_EXEC tar xj -C $target_sdk_dir
134echo "done"
135
136printf "Setting it up..."
137# fix environment paths
138for 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
140done
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@
194
195# delete the relocating script, so that user is forced to re-run the installer
196# if he/she wants another location for the sdk
197if [ $savescripts = 0 ] ; then
198 $SUDO_EXEC rm ${env_setup_script%/*}/relocate_sdk.py ${env_setup_script%/*}/relocate_sdk.sh
199fi
200
201echo "SDK has been successfully set up and is ready to be used."
202
203exit 0
204
205MARKER: