From 8ffb52a4d9bf26f240f6a1a8252b3739047ae8d7 Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Fri, 26 May 2017 10:38:03 +0800 Subject: add __uninstall__ for get.sh --- scripts/get.sh | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'scripts') 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 ) [[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 ] -- cgit v1.3.1