diff --git a/bootstrap-vitasdk.sh b/bootstrap-vitasdk.sh index dde32bf..b85b1f8 100755 --- a/bootstrap-vitasdk.sh +++ b/bootstrap-vitasdk.sh @@ -5,7 +5,13 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" INSTALLDIR="${VITASDK:-/usr/local/vitasdk}" -. $DIR/include/install-vitasdk.sh +fallback_fail() { + echo "FAIL: removing $INSTALLDIR" + sudo rm -rf $INSTALLDIR + exit 1 +} + +. "$DIR/include/install-vitasdk.sh" if [ -d "$INSTALLDIR" ]; then echo "$INSTALLDIR already exists. Remove it first (e.g. 'sudo rm -rf $INSTALLDIR' or 'rm -rf $INSTALLDIR') and then restart this script" @@ -13,7 +19,7 @@ if [ -d "$INSTALLDIR" ]; then fi echo "==> Installing vitasdk to $INSTALLDIR" -install_vitasdk $INSTALLDIR +install_vitasdk $INSTALLDIR || fallback_fail echo "Please add the following to the bottom of your .bashrc:" printf "\033[0;36m""export VITASDK=${INSTALLDIR}""\033[0m\n" diff --git a/include/install-vitasdk.sh b/include/install-vitasdk.sh index ba9017c..67fe44c 100755 --- a/include/install-vitasdk.sh +++ b/include/install-vitasdk.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e get_download_link () { curl -sL https://github.com/vitasdk/vita-headers/raw/master/.travis.d/last_built_toolchain.py | python - $@ @@ -9,9 +10,9 @@ install_vitasdk () { case "$(uname -s)" in Darwin*) - mkdir -p $INSTALLDIR - wget -O "vitasdk-nightly.tar.bz2" "$(get_download_link master osx)" - tar xf "vitasdk-nightly.tar.bz2" -C $INSTALLDIR --strip-components=1 + mkdir -p $INSTALLDIR && + wget -O "vitasdk-nightly.tar.bz2" "$(get_download_link master osx)" && + tar xf "vitasdk-nightly.tar.bz2" -C $INSTALLDIR --strip-components=1 && rm -f "vitasdk-nightly.tar.bz2" ;; @@ -23,16 +24,16 @@ install_vitasdk () { sudo mkdir -p $INSTALLDIR sudo chown $USER:$(id -gn $USER) $INSTALLDIR fi - wget -O "vitasdk-nightly.tar.bz2" "$(get_download_link master linux)" - tar xf "vitasdk-nightly.tar.bz2" -C $INSTALLDIR --strip-components=1 + wget -O "vitasdk-nightly.tar.bz2" "$(get_download_link master linux)" && + tar xf "vitasdk-nightly.tar.bz2" -C $INSTALLDIR --strip-components=1 && rm -f "vitasdk-nightly.tar.bz2" ;; MSYS*|MINGW64*) UNIX=false - mkdir -p $INSTALLDIR - wget -O "vitasdk-nightly.tar.bz2" "$(get_download_link master win)" - tar xf "vitasdk-nightly.tar.bz2" -C $INSTALLDIR --strip-components=1 + mkdir -p $INSTALLDIR && + wget -O "vitasdk-nightly.tar.bz2" "$(get_download_link master win)" && + tar xf "vitasdk-nightly.tar.bz2" -C $INSTALLDIR --strip-components=1 && rm -f "vitasdk-nightly.tar.bz2" ;; diff --git a/install-all.sh b/install-all.sh index 33e3de6..5ffcfed 100755 --- a/install-all.sh +++ b/install-all.sh @@ -4,6 +4,6 @@ set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -. $DIR/include/install-packages.sh +. "$DIR/include/install-packages.sh" install_packages diff --git a/vitasdk-update b/vitasdk-update index c3e4839..7a9df5e 100755 --- a/vitasdk-update +++ b/vitasdk-update @@ -10,8 +10,8 @@ if [ -z "$VITASDK" ]; then exit 1 fi -. $DIR/include/install-vitasdk.sh -. $DIR/include/install-packages.sh +. "$DIR/include/install-vitasdk.sh" +. "$DIR/include/install-packages.sh" echo "==> Updating vitasdk" install_vitasdk $VITASDK