summaryrefslogtreecommitdiffstats
path: root/meta/files/toolchain-shar-extract.sh
diff options
context:
space:
mode:
Diffstat (limited to 'meta/files/toolchain-shar-extract.sh')
-rw-r--r--meta/files/toolchain-shar-extract.sh44
1 files changed, 31 insertions, 13 deletions
diff --git a/meta/files/toolchain-shar-extract.sh b/meta/files/toolchain-shar-extract.sh
index dd9342758b..e2c617958a 100644
--- a/meta/files/toolchain-shar-extract.sh
+++ b/meta/files/toolchain-shar-extract.sh
@@ -1,9 +1,14 @@
1#!/bin/sh 1#!/bin/sh
2 2
3export LC_ALL=en_US.UTF-8 3export LC_ALL=en_US.UTF-8
4
5# The pipefail option is now part of POSIX (POSIX.1-2024) and available in more
6# and more shells. Enable it if available to make the SDK installer more robust.
7(set -o pipefail 2> /dev/null) && set -o pipefail
8
4#Make sure at least one python is installed 9#Make sure at least one python is installed
5INIT_PYTHON=$(which python3 2>/dev/null ) 10INIT_PYTHON=$(command -v python3 2>/dev/null )
6[ -z "$INIT_PYTHON" ] && INIT_PYTHON=$(which python2 2>/dev/null) 11[ -z "$INIT_PYTHON" ] && INIT_PYTHON=$(command -v python2 2>/dev/null)
7[ -z "$INIT_PYTHON" ] && echo "Error: The SDK needs a python installed" && exit 1 12[ -z "$INIT_PYTHON" ] && echo "Error: The SDK needs a python installed" && exit 1
8 13
9# Remove invalid PATH elements first (maybe from a previously setup toolchain now deleted 14# Remove invalid PATH elements first (maybe from a previously setup toolchain now deleted
@@ -26,9 +31,6 @@ tweakpath /sbin
26INST_ARCH=$(uname -m | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/") 31INST_ARCH=$(uname -m | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/")
27SDK_ARCH=$(echo @SDK_ARCH@ | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/") 32SDK_ARCH=$(echo @SDK_ARCH@ | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/")
28 33
29INST_GCC_VER=$(gcc --version 2>/dev/null | sed -ne 's/.* \([0-9]\+\.[0-9]\+\)\.[0-9]\+.*/\1/p')
30SDK_GCC_VER='@SDK_GCC_VER@'
31
32verlte () { 34verlte () {
33 [ "$1" = "`printf "$1\n$2" | sort -V | head -n1`" ] 35 [ "$1" = "`printf "$1\n$2" | sort -V | head -n1`" ]
34} 36}
@@ -56,7 +58,8 @@ if ! xz -V > /dev/null 2>&1; then
56 exit 1 58 exit 1
57fi 59fi
58 60
59DEFAULT_INSTALL_DIR="@SDKPATH@" 61SDK_BUILD_PATH="@SDKPATH@"
62DEFAULT_INSTALL_DIR="@SDKPATHINSTALL@"
60SUDO_EXEC="" 63SUDO_EXEC=""
61EXTRA_TAR_OPTIONS="" 64EXTRA_TAR_OPTIONS=""
62target_sdk_dir="" 65target_sdk_dir=""
@@ -139,11 +142,6 @@ fi
139# SDK_EXTENSIBLE is exposed from the SDK_PRE_INSTALL_COMMAND above 142# SDK_EXTENSIBLE is exposed from the SDK_PRE_INSTALL_COMMAND above
140if [ "$SDK_EXTENSIBLE" = "1" ]; then 143if [ "$SDK_EXTENSIBLE" = "1" ]; then
141 DEFAULT_INSTALL_DIR="@SDKEXTPATH@" 144 DEFAULT_INSTALL_DIR="@SDKEXTPATH@"
142 if [ "$INST_GCC_VER" = '4.8' -a "$SDK_GCC_VER" = '4.9' ] || [ "$INST_GCC_VER" = '4.8' -a "$SDK_GCC_VER" = '' ] || \
143 [ "$INST_GCC_VER" = '4.9' -a "$SDK_GCC_VER" = '' ]; then
144 echo "Error: Incompatible SDK installer! Your host gcc version is $INST_GCC_VER and this SDK was built by gcc higher version."
145 exit 1
146 fi
147fi 145fi
148 146
149if [ "$target_sdk_dir" = "" ]; then 147if [ "$target_sdk_dir" = "" ]; then
@@ -163,7 +161,9 @@ else
163fi 161fi
164 162
165# limit the length for target_sdk_dir, ensure the relocation behaviour in relocate_sdk.py has right result. 163# limit the length for target_sdk_dir, ensure the relocation behaviour in relocate_sdk.py has right result.
166if [ ${#target_sdk_dir} -gt 2048 ]; then 164# This is due to ELF interpreter being set to 'a'*1024 in
165# meta/recipes-core/meta/uninative-tarball.bb
166if [ ${#target_sdk_dir} -gt 1024 ]; then
167 echo "Error: The target directory path is too long!!!" 167 echo "Error: The target directory path is too long!!!"
168 exit 1 168 exit 1
169fi 169fi
@@ -226,7 +226,7 @@ if [ ! -x $target_sdk_dir -o ! -w $target_sdk_dir -o ! -r $target_sdk_dir ]; the
226 exit 1 226 exit 1
227 fi 227 fi
228 228
229 SUDO_EXEC=$(which "sudo") 229 SUDO_EXEC=$(command -v "sudo")
230 if [ -z $SUDO_EXEC ]; then 230 if [ -z $SUDO_EXEC ]; then
231 echo "No command 'sudo' found, please install sudo first. Abort!" 231 echo "No command 'sudo' found, please install sudo first. Abort!"
232 exit 1 232 exit 1
@@ -242,13 +242,27 @@ fi
242 242
243printf "Extracting SDK..." 243printf "Extracting SDK..."
244if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then 244if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then
245 if [ -z "$(command -v unzip)" ]; then
246 echo "Aborted, unzip is required to extract the SDK archive, please make sure it's installed on your system!"
247 exit 1
248 fi
245 tail -n +$payload_offset "$0" > sdk.zip 249 tail -n +$payload_offset "$0" > sdk.zip
246 if $SUDO_EXEC unzip $EXTRA_TAR_OPTIONS sdk.zip -d $target_sdk_dir;then 250 if $SUDO_EXEC unzip $EXTRA_TAR_OPTIONS sdk.zip -d $target_sdk_dir;then
247 rm sdk.zip 251 rm sdk.zip
248 else 252 else
249 rm sdk.zip && exit 1 253 rm sdk.zip && exit 1
250 fi 254 fi
255elif [ @SDK_ARCHIVE_TYPE@ = "tar.zst" ]; then
256 if [ -z "$(command -v zstd)" ]; then
257 echo "Aborted, zstd is required to extract the SDK archive, please make sure it's installed on your system!"
258 exit 1
259 fi
260 tail -n +$payload_offset "$0"| zstd -T0 -dc | $SUDO_EXEC tar mx -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1
251else 261else
262 if [ -z "$(command -v xz)" ]; then
263 echo "Aborted, xz is required to extract the SDK archive, please make sure it's installed on your system!"
264 exit 1
265 fi
252 tail -n +$payload_offset "$0"| $SUDO_EXEC tar mxJ -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1 266 tail -n +$payload_offset "$0"| $SUDO_EXEC tar mxJ -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1
253fi 267fi
254echo "done" 268echo "done"
@@ -283,6 +297,10 @@ post_relocate="$target_sdk_dir/post-relocate-setup.sh"
283if [ -e "$post_relocate" ]; then 297if [ -e "$post_relocate" ]; then
284 $SUDO_EXEC sed -e "s:@SDKPATH@:$target_sdk_dir:g" -i $post_relocate 298 $SUDO_EXEC sed -e "s:@SDKPATH@:$target_sdk_dir:g" -i $post_relocate
285 $SUDO_EXEC /bin/sh $post_relocate "$target_sdk_dir" "@SDKPATH@" 299 $SUDO_EXEC /bin/sh $post_relocate "$target_sdk_dir" "@SDKPATH@"
300 if [ $? -ne 0 ]; then
301 echo "Executing $post_relocate failed"
302 exit 1
303 fi
286 $SUDO_EXEC rm -f $post_relocate 304 $SUDO_EXEC rm -f $post_relocate
287fi 305fi
288 306