diff options
| author | TitanSnow <[email protected]> | 2017-05-26 10:38:03 +0800 |
|---|---|---|
| committer | TitanSnow <[email protected]> | 2017-05-26 10:38:03 +0800 |
| commit | 8ffb52a4d9bf26f240f6a1a8252b3739047ae8d7 (patch) | |
| tree | 5c704f8fe6f4db185f8c50bb47de1662ba8a3aa9 /scripts | |
| parent | fd89ef0415b9a1d26cd9649fd242db51c6893da5 (diff) | |
add __uninstall__ for get.sh
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/get.sh | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/scripts/get.sh b/scripts/get.sh index 9c01b2526..3a1fabd21 100755 --- a/scripts/get.sh +++ b/scripts/get.sh @@ -4,6 +4,38 @@ # usage: bash <(curl -s <my location>) [[mirror:]branch] [commit/__install_only__] set -o pipefail + +if [ 0 -ne "$(id -u)" ] +then + sudoprefix=sudo +else + sudoprefix= +fi + +remote_get_content(){ + if curl --version >/dev/null 2>&1 + then + curl -fsSL "$1" + elif wget --version >/dev/null 2>&1 + then + wget -q "$1" -O - + fi +} + +if [ "$1" = "__uninstall__" ] +then + # uninstall + makefile=$(remote_get_content https://github.com/tboox/xmake/raw/master/makefile) + while which xmake >/dev/null 2>&1 + do + pre=$(which xmake | sed 's/\/bin\/xmake$//') + # don't care if make exists -- if there's no make, how xmake built and installed? + echo "$makefile" | make -f - uninstall prefix="$pre" 2>/dev/null || echo "$makefile" | $sudoprefix make -f - uninstall prefix="$pre" || exit $? + done + exit +fi + +# below is installation # print a LOGO! echo ' _ ' echo ' __ ___ __ __ __ _| | ______ ' @@ -17,12 +49,6 @@ then brew --version >/dev/null 2>&1 && brew install --HEAD xmake && xmake --version && exit fi -if [ 0 -ne "$(id -u)" ] -then - sudoprefix=sudo -else - sudoprefix= -fi my_exit(){ rv=$? if [ "x$1" != x ] |
