diff options
Diffstat (limited to 'meta/files/toolchain-shar-extract.sh')
-rw-r--r-- | meta/files/toolchain-shar-extract.sh | 44 |
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 | ||
3 | export LC_ALL=en_US.UTF-8 | 3 | export 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 |
5 | INIT_PYTHON=$(which python3 2>/dev/null ) | 10 | INIT_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 | |||
26 | INST_ARCH=$(uname -m | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/") | 31 | INST_ARCH=$(uname -m | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/") |
27 | SDK_ARCH=$(echo @SDK_ARCH@ | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/") | 32 | SDK_ARCH=$(echo @SDK_ARCH@ | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/") |
28 | 33 | ||
29 | INST_GCC_VER=$(gcc --version 2>/dev/null | sed -ne 's/.* \([0-9]\+\.[0-9]\+\)\.[0-9]\+.*/\1/p') | ||
30 | SDK_GCC_VER='@SDK_GCC_VER@' | ||
31 | |||
32 | verlte () { | 34 | verlte () { |
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 |
57 | fi | 59 | fi |
58 | 60 | ||
59 | DEFAULT_INSTALL_DIR="@SDKPATH@" | 61 | SDK_BUILD_PATH="@SDKPATH@" |
62 | DEFAULT_INSTALL_DIR="@SDKPATHINSTALL@" | ||
60 | SUDO_EXEC="" | 63 | SUDO_EXEC="" |
61 | EXTRA_TAR_OPTIONS="" | 64 | EXTRA_TAR_OPTIONS="" |
62 | target_sdk_dir="" | 65 | target_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 |
140 | if [ "$SDK_EXTENSIBLE" = "1" ]; then | 143 | if [ "$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 | ||
147 | fi | 145 | fi |
148 | 146 | ||
149 | if [ "$target_sdk_dir" = "" ]; then | 147 | if [ "$target_sdk_dir" = "" ]; then |
@@ -163,7 +161,9 @@ else | |||
163 | fi | 161 | fi |
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. |
166 | if [ ${#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 | ||
166 | if [ ${#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 |
169 | fi | 169 | fi |
@@ -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 | ||
243 | printf "Extracting SDK..." | 243 | printf "Extracting SDK..." |
244 | if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then | 244 | if [ @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 |
255 | elif [ @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 | ||
251 | else | 261 | else |
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 |
253 | fi | 267 | fi |
254 | echo "done" | 268 | echo "done" |
@@ -283,6 +297,10 @@ post_relocate="$target_sdk_dir/post-relocate-setup.sh" | |||
283 | if [ -e "$post_relocate" ]; then | 297 | if [ -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 |
287 | fi | 305 | fi |
288 | 306 | ||