diff options
Diffstat (limited to 'meta/files/toolchain-shar-extract.sh')
-rw-r--r-- | meta/files/toolchain-shar-extract.sh | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/meta/files/toolchain-shar-extract.sh b/meta/files/toolchain-shar-extract.sh index 91804ec281..4386b985bb 100644 --- a/meta/files/toolchain-shar-extract.sh +++ b/meta/files/toolchain-shar-extract.sh @@ -1,12 +1,13 @@ #!/bin/sh -[ -z "$ENVCLEANED" ] && exec /usr/bin/env -i ENVCLEANED=1 HOME="$HOME" \ - LC_ALL=en_US.UTF-8 \ - TERM=$TERM \ - http_proxy="$http_proxy" https_proxy="$https_proxy" ftp_proxy="$ftp_proxy" \ - no_proxy="$no_proxy" all_proxy="$all_proxy" GIT_PROXY_COMMAND="$GIT_PROXY_COMMAND" "$0" "$@" -[ -f /etc/environment ] && . /etc/environment -export PATH=`echo "$PATH" | sed -e 's/:\.//' -e 's/::/:/'` +export LC_ALL=en_US.UTF-8 +#Make sure at least one python is installed +INIT_PYTHON=$(which python3 2>/dev/null ) +[ -z "$INIT_PYTHON" ] && INIT_PYTHON=$(which python2 2>/dev/null) +[ -z "$INIT_PYTHON" ] && echo "Error: The SDK needs a python installed" && exit 1 + +# Remove invalid PATH elements first (maybe from a previously setup toolchain now deleted +PATH=`$INIT_PYTHON -c 'import os; print(":".join(e for e in os.environ["PATH"].split(":") if os.path.exists(e)))'` tweakpath () { case ":${PATH}:" in @@ -25,7 +26,7 @@ tweakpath /sbin INST_ARCH=$(uname -m | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/") SDK_ARCH=$(echo @SDK_ARCH@ | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/") -INST_GCC_VER=$(gcc --version | sed -ne 's/.* \([0-9]\+\.[0-9]\+\)\.[0-9]\+.*/\1/p') +INST_GCC_VER=$(gcc --version 2>/dev/null | sed -ne 's/.* \([0-9]\+\.[0-9]\+\)\.[0-9]\+.*/\1/p') SDK_GCC_VER='@SDK_GCC_VER@' verlte () { @@ -55,7 +56,8 @@ if ! xz -V > /dev/null 2>&1; then exit 1 fi -DEFAULT_INSTALL_DIR="@SDKPATH@" +SDK_BUILD_PATH="@SDKPATH@" +DEFAULT_INSTALL_DIR="@SDKPATHINSTALL@" SUDO_EXEC="" EXTRA_TAR_OPTIONS="" target_sdk_dir="" @@ -94,7 +96,7 @@ while getopts ":yd:npDRSl" OPT; do listcontents=1 ;; *) - echo "Usage: $(basename $0) [-y] [-d <dir>]" + echo "Usage: $(basename "$0") [-y] [-d <dir>]" echo " -y Automatic yes to all prompts" echo " -d <dir> Install the SDK to <dir>" echo "======== Extensible SDK only options ============" @@ -110,9 +112,18 @@ while getopts ":yd:npDRSl" OPT; do esac done -payload_offset=$(($(grep -na -m1 "^MARKER:$" $0|cut -d':' -f1) + 1)) +payload_offset=$(($(grep -na -m1 "^MARKER:$" "$0"|cut -d':' -f1) + 1)) if [ "$listcontents" = "1" ] ; then - tail -n +$payload_offset $0| tar tvJ || exit 1 + if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then + tail -n +$payload_offset "$0" > sdk.zip + if unzip -l sdk.zip;then + rm sdk.zip + else + rm sdk.zip && exit 1 + fi + else + tail -n +$payload_offset "$0"| tar tvJ || exit 1 + fi exit fi @@ -184,11 +195,11 @@ fi if [ -e "$target_sdk_dir/environment-setup-@REAL_MULTIMACH_TARGET_SYS@" ]; then echo "The directory \"$target_sdk_dir\" already contains a SDK for this architecture." - printf "If you continue, existing files will be overwritten! Proceed[y/N]? " + printf "If you continue, existing files will be overwritten! Proceed [y/N]? " default_answer="n" else - printf "You are about to install the SDK to \"$target_sdk_dir\". Proceed[Y/n]? " + printf "You are about to install the SDK to \"$target_sdk_dir\". Proceed [Y/n]? " default_answer="y" fi @@ -231,7 +242,16 @@ if [ ! -x $target_sdk_dir -o ! -w $target_sdk_dir -o ! -r $target_sdk_dir ]; the fi printf "Extracting SDK..." -tail -n +$payload_offset $0| $SUDO_EXEC tar xJ -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1 +if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then + tail -n +$payload_offset "$0" > sdk.zip + if $SUDO_EXEC unzip $EXTRA_TAR_OPTIONS sdk.zip -d $target_sdk_dir;then + rm sdk.zip + else + rm sdk.zip && exit 1 + fi +else + tail -n +$payload_offset "$0"| $SUDO_EXEC tar mxJ -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1 +fi echo "done" printf "Setting it up..." @@ -259,6 +279,14 @@ if [ $savescripts = 0 ] ; then $SUDO_EXEC rm -f ${env_setup_script%/*}/relocate_sdk.py ${env_setup_script%/*}/relocate_sdk.sh fi +# Execute post-relocation script +post_relocate="$target_sdk_dir/post-relocate-setup.sh" +if [ -e "$post_relocate" ]; then + $SUDO_EXEC sed -e "s:@SDKPATH@:$target_sdk_dir:g" -i $post_relocate + $SUDO_EXEC /bin/sh $post_relocate "$target_sdk_dir" "@SDKPATH@" + $SUDO_EXEC rm -f $post_relocate +fi + echo "SDK has been successfully set up and is ready to be used." echo "Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g." for env_setup_script in `ls $target_sdk_dir/environment-setup-*`; do |