diff options
| author | TitanSnow <[email protected]> | 2017-04-21 16:52:32 +0800 |
|---|---|---|
| committer | TitanSnow <[email protected]> | 2017-04-21 16:52:32 +0800 |
| commit | 92ab4637f31a1645b04cfd04f7bd368ccc15105c (patch) | |
| tree | b2e9eed691d402a3dab48d50b0768bb4445f14d9 /scripts | |
| parent | c1338a3ae83159bdf54d8cfe6d59ce2f4ac0dec3 (diff) | |
check & install tools autoly
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/get.sh | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/scripts/get.sh b/scripts/get.sh index 2327916c7..83dcfb627 100755 --- a/scripts/get.sh +++ b/scripts/get.sh @@ -3,6 +3,37 @@ # xmake getter # usage: bash <(curl -s <my location>) [branch] +if [ 0 -ne $(id -u) ] +then + sudoprefix=sudo +else + sudoprefix= +fi +test_tools() +{ + { + git --version && + make --version && + { + cc --version || + gcc --version || + clang --version + } + } >/dev/null 2>&1 +} +install_tools() +{ + { apt-get --version >/dev/null 2>&1 && $sudoprefix apt-get install -y git build-essential; } || + { yum --version >/dev/null 2>&1 && $sudoprefix yum install -y git 'Development Tools'; } || + { zypper --version >/dev/null 2>&1 && $sudoprefix zypper install -n git && $sudoprefix zypper install -n -t pattern devel_C_C++; } || + { pacman -V >/dev/null 2>&1 && $sudoprefix pacman -S --noconfirm git base-devel; } +} +test_tools || { install_tools && test_tools; } || +{ + rv=$? + echo 'Dependencies Installation Fail' + exit $rv +} branch= if [ x != x$1 ];then branch="-b $1";fi git clone --depth=1 $branch https://github.com/tboox/xmake.git /tmp/$$xmake_getter || exit $? @@ -26,11 +57,8 @@ done if [ x$prefix != x ] then make -C /tmp/$$xmake_getter --no-print-directory install prefix="$prefix"|| exit $? -elif [ 0 -eq $(id -u) ] -then - make -C /tmp/$$xmake_getter --no-print-directory install || exit $? else - sudo make -C /tmp/$$xmake_getter --no-print-directory install || exit $? + $sudoprefix make -C /tmp/$$xmake_getter --no-print-directory install || exit $? fi rm -rf /tmp/$$xmake_getter xmake --version |
