#!/bin/sh # NB: If you change this script you must also change quick-install.sh say() { echo "blastoff: $1" } verbose_say() { if [ "$flag_verbose" = true ]; then say "$1" fi } err() { say "$1" >&2 exit 1 } need_cmd() { if ! command -v $1 > /dev/null 2>&1 then err "need $1" fi } need_ok() { if [ $? != 0 ]; then err "$1" fi } assert_nz() { if [ -z "$1" ]; then err "assert_nz $2" fi } create_tmp_dir() { local tmp_dir="`pwd`/multirust-tmp-install" rm -Rf "${tmp_dir}" need_ok "failed to remove temporary installation directory" mkdir -p "${tmp_dir}" need_ok "failed to create create temporary installation directory" echo $tmp_dir } # Copied from rustup.sh get_architecture() { verbose_say "detecting architecture" local _ostype="$(uname -s)" local _cputype="$(uname -m)" verbose_say "uname -s reports: $_ostype" verbose_say "uname -m reports: $_cputype" if [ "$_ostype" = Darwin -a "$_cputype" = i386 ]; then # Darwin `uname -s` lies if sysctl hw.optional.x86_64 | grep -q ': 1'; then local _cputype=x86_64 fi fi case "$_ostype" in Linux) local _ostype=unknown-linux-gnu ;; FreeBSD) local _ostype=unknown-freebsd ;; DragonFly) local _ostype=unknown-dragonfly ;; Darwin) local _ostype=apple-darwin ;; MINGW* | MSYS*) local _ostype=pc-windows-gnu ;; *) err "unrecognized OS type: $_ostype" ;; esac case "$_cputype" in i386 | i486 | i686 | i786 | x86) local _cputype=i686 ;; xscale | arm) local _cputype=arm ;; armv6l) local _cputype=arm local _ostype="${_ostype}eabihf" ;; armv7l) local _cputype=armv7 local _ostype="${_ostype}eabihf" ;; x86_64 | x86-64 | x64 | amd64) local _cputype=x86_64 ;; *) err "unknown CPU type: $CFG_CPUTYPE" esac # Detect 64-bit linux with 32-bit userland if [ $_ostype = unknown-linux-gnu -a $_cputype = x86_64 ]; then # $SHELL does not exist in standard 'sh', so probably only exists # if configure is running in an interactive bash shell. /usr/bin/env # exists *everywhere*. local _bin_to_probe="${SHELL-bogus_shell}" if [ ! -e "$_bin_to_probe" -a -e "/usr/bin/env" ]; then _bin_to_probe="/usr/bin/env" fi if [ -e "$_bin_to_probe" ]; then file -L "$_bin_to_probe" | grep -q "x86[_-]64" if [ $? != 0 ]; then local _cputype=i686 fi fi fi local _arch="$_cputype-$_ostype" verbose_say "architecture is $_arch" RETVAL="$_arch" } check_for_windows() { get_architecture case "$RETVAL" in *pc-windows*) return 0 ;; *) return 1 ;; esac } run() { need_cmd rm need_cmd git need_cmd sed need_cmd sh need_cmd sleep need_cmd file GIT_REPO=https://github.com/brson/multirust.git UNINSTALL= YES= for arg in "$@"; do case "$arg" in --uninstall) UNINSTALL=true ;; --yes) YES=true ;; *) err "unrecognized argument '$arg'" ;; esac done if [ ! -e "/dev/tty" ]; then err "/dev/tty does not exist" fi check_for_windows if [ "$?" = 0 ]; then local _is_windows=true else local _is_windows=false fi if [ "$_is_windows" = "false" ]; then if [ -z "$UNINSTALL" ]; then cat < /dev/null 2>&1; then err 'unable to run `multirust` after install. this is odd. not finishing configuration' fi say "installing stable toolchain" multirust default stable need_ok 'failed to install stable toolchain. if this appears to be a network problem retry with `multirust default stable`' say "all systems go" } run "$@"