diff options
Diffstat (limited to 'meta/files/toolchain-shar-extract.sh')
-rw-r--r-- | meta/files/toolchain-shar-extract.sh | 101 |
1 files changed, 85 insertions, 16 deletions
diff --git a/meta/files/toolchain-shar-extract.sh b/meta/files/toolchain-shar-extract.sh index 9279310376..4386b985bb 100644 --- a/meta/files/toolchain-shar-extract.sh +++ b/meta/files/toolchain-shar-extract.sh @@ -1,16 +1,34 @@ #!/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 + *:"$1":*) + ;; + *) + PATH=$PATH:$1 + esac +} + +# Some systems don't have /usr/sbin or /sbin in the cleaned environment PATH but we make need it +# for the system's host tooling checks +tweakpath /usr/sbin +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 2>/dev/null | sed -ne 's/.* \([0-9]\+\.[0-9]\+\)\.[0-9]\+.*/\1/p') +SDK_GCC_VER='@SDK_GCC_VER@' + verlte () { [ "$1" = "`printf "$1\n$2" | sort -V | head -n1`" ] } @@ -28,7 +46,7 @@ fi if [ "$INST_ARCH" != "$SDK_ARCH" ]; then # Allow for installation of ix86 SDK on x86_64 host if [ "$INST_ARCH" != x86_64 -o "$SDK_ARCH" != ix86 ]; then - echo "Error: Installation machine not supported!" + echo "Error: Incompatible SDK installer! Your host is $INST_ARCH and this SDK was built for $SDK_ARCH hosts." exit 1 fi fi @@ -38,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="" @@ -47,7 +66,8 @@ relocate=1 savescripts=0 verbose=0 publish=0 -while getopts ":yd:npDRS" OPT; do +listcontents=0 +while getopts ":yd:npDRSl" OPT; do case $OPT in y) answer="Y" @@ -72,8 +92,11 @@ while getopts ":yd:npDRS" OPT; do S) savescripts=1 ;; + l) + 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 ============" @@ -83,11 +106,27 @@ while getopts ":yd:npDRS" OPT; do echo " -S Save relocation scripts" echo " -R Do not relocate executables" echo " -D use set -x to see what is going on" + echo " -l list files that will be extracted" exit 1 ;; esac done +payload_offset=$(($(grep -na -m1 "^MARKER:$" "$0"|cut -d':' -f1) + 1)) +if [ "$listcontents" = "1" ] ; then + 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 + titlestr="@SDK_TITLE@ installer version @SDK_VERSION@" printf "%s\n" "$titlestr" printf "%${#titlestr}s\n" | tr " " "=" @@ -101,6 +140,11 @@ fi # SDK_EXTENSIBLE is exposed from the SDK_PRE_INSTALL_COMMAND above if [ "$SDK_EXTENSIBLE" = "1" ]; then DEFAULT_INSTALL_DIR="@SDKEXTPATH@" + if [ "$INST_GCC_VER" = '4.8' -a "$SDK_GCC_VER" = '4.9' ] || [ "$INST_GCC_VER" = '4.8' -a "$SDK_GCC_VER" = '' ] || \ + [ "$INST_GCC_VER" = '4.9' -a "$SDK_GCC_VER" = '' ]; then + echo "Error: Incompatible SDK installer! Your host gcc version is $INST_GCC_VER and this SDK was built by gcc higher version." + exit 1 + fi fi if [ "$target_sdk_dir" = "" ]; then @@ -132,6 +176,16 @@ if [ "$SDK_EXTENSIBLE" = "1" ]; then "characters such as spaces, @, \$ or +. Abort!" exit 1 fi + # The build system doesn't work well with /tmp on NFS + fs_dev_path="$target_sdk_dir" + while [ ! -d "$fs_dev_path" ] ; do + fs_dev_path=`dirname $fs_dev_path` + done + fs_dev_type=`stat -f -c '%t' "$fs_dev_path"` + if [ "$fsdevtype" = "6969" ] ; then + echo "The target directory path $target_sdk_dir is on NFS, this is not possible. Abort!" + exit 1 + fi else if [ -n "$(echo $target_sdk_dir|grep ' ')" ]; then echo "The target directory path ($target_sdk_dir) contains spaces. Abort!" @@ -141,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 @@ -187,10 +241,17 @@ if [ ! -x $target_sdk_dir -o ! -w $target_sdk_dir -o ! -r $target_sdk_dir ]; the $SUDO_EXEC mkdir -p $target_sdk_dir >/dev/null 2>&1 fi -payload_offset=$(($(grep -na -m1 "^MARKER:$" $0|cut -d':' -f1) + 1)) - 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..." @@ -218,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 |