|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# A script to install dependencies of GraphScope. |
| 4 | + |
| 5 | +set -e |
| 6 | +set -x |
| 7 | +set -o pipefail |
| 8 | + |
| 9 | +is_in_wsl=false && [[ ! -z "${IS_WSL}" || ! -z "${WSL_DISTRO_NAME}" ]] && is_in_wsl=true |
| 10 | + |
| 11 | +# https://unix.stackexchange.com/questions/6345/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script |
| 12 | +function get_os_version() { |
| 13 | + if [ -f /etc/os-release ]; then |
| 14 | + # freedesktop.org and systemd |
| 15 | + . /etc/os-release |
| 16 | + platform="${NAME}" |
| 17 | + os_version="${VERSION_ID}" |
| 18 | + elif type lsb_release >/dev/null 2>&1; then |
| 19 | + # linuxbase.org |
| 20 | + platform=$(lsb_release -si) |
| 21 | + os_version=$(lsb_release -sr) |
| 22 | + elif [ -f /etc/lsb-release ]; then |
| 23 | + # For some versions of Debian/Ubuntu without lsb_release command |
| 24 | + . /etc/lsb-release |
| 25 | + platform="${DISTRIB_ID}" |
| 26 | + os_version="${DISTRIB_RELEASE}" |
| 27 | + elif [ -f /etc/debian_version ]; then |
| 28 | + # Older Debian/Ubuntu/etc. |
| 29 | + platform=Debian |
| 30 | + os_version=$(cat /etc/debian_version) |
| 31 | + elif [ -f /etc/centos-release ]; then |
| 32 | + # Older Red Hat, CentOS, etc. |
| 33 | + platform=CentOS |
| 34 | + os_version=$(cat /etc/centos-release | sed 's/.* \([0-9]\).*/\1/') |
| 35 | + else |
| 36 | + # Fall back to uname, e.g. "Linux <version>", also works for BSD, Darwin, etc. |
| 37 | + platform=$(uname -s) |
| 38 | + os_version=$(uname -r) |
| 39 | + fi |
| 40 | +} |
| 41 | + |
| 42 | +function check_os_compatibility() { |
| 43 | + if [[ "${is_in_wsl}" == true && -z "${WSL_INTEROP}" ]]; then |
| 44 | + echo "GraphScope not support to run on WSL1, please use WSL2." |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + |
| 48 | + if [[ "${platform}" != *"Ubuntu"* ]]; then |
| 49 | + echo "This script is only available on Ubuntu" |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | + |
| 53 | + if [[ "${platform}" == *"Ubuntu"* && "$(echo ${os_version} | sed 's/\([0-9]\)\([0-9]\).*/\1\2/')" -lt "20" ]]; then |
| 54 | + echo "This script requires Ubuntu 20 or greater." |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | + |
| 58 | + echo "$(date '+%Y-%m-%d %H:%M:%S') preparing environment on '${platform}' '${os_version}'" |
| 59 | +} |
| 60 | + |
| 61 | +function check_dependencies_version() { |
| 62 | + # python |
| 63 | + if ! hash python3; then |
| 64 | + echo "Python3 is not installed" |
| 65 | + exit 1 |
| 66 | + fi |
| 67 | + ver=$(python3 -V 2>&1 | sed 's/.* \([0-9]\).\([0-9]\).*/\1\2/') |
| 68 | + if [ "$ver" -lt "36" ]; then |
| 69 | + echo "GraphScope requires python 3.6 or greater." |
| 70 | + exit 1 |
| 71 | + fi |
| 72 | +} |
| 73 | + |
| 74 | +function install_dependencies() { |
| 75 | + echo "$(date '+%Y-%m-%d %H:%M:%S') install dependencies." |
| 76 | + if [[ "${platform}" == *"Ubuntu"* ]]; then |
| 77 | + sudo apt-get update -y |
| 78 | + sudo apt install -y ca-certificates ccache cmake curl etcd libbrotli-dev \ |
| 79 | + libbz2-dev libcurl4-openssl-dev libdouble-conversion-dev libevent-dev libgflags-dev \ |
| 80 | + libboost-all-dev libgoogle-glog-dev libgrpc-dev libgrpc++-dev libgtest-dev libgsasl7-dev \ |
| 81 | + libtinfo5 libkrb5-dev liblz4-dev libprotobuf-dev librdkafka-dev libre2-dev libsnappy-dev \ |
| 82 | + libssl-dev libunwind-dev libutf8proc-dev libxml2-dev libz-dev libzstd-dev lsb-release maven \ |
| 83 | + openjdk-8-jdk perl protobuf-compiler-grpc python3-pip uuid-dev wget zip zlib1g-dev |
| 84 | + |
| 85 | + # install apache-arrow |
| 86 | + wget https://apache.bintray.com/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-archive-keyring-latest-$(lsb_release --codename --short).deb -P /tmp |
| 87 | + sudo apt install -y -V /tmp/apache-arrow-archive-keyring-latest-$(lsb_release --codename --short).deb |
| 88 | + sudo apt update |
| 89 | + sudo apt install -y libarrow-dev=1.0.1-1 libarrow-python-dev=1.0.1-1 |
| 90 | + |
| 91 | + # install zookeeper |
| 92 | + wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz -P /tmp |
| 93 | + tar xf /tmp/zookeeper-3.4.14.tar.gz -C /tmp/ |
| 94 | + cp /tmp/zookeeper-3.4.14/conf/zoo_sample.cfg /tmp/zookeeper-3.4.14/conf/zoo.cfg |
| 95 | + sudo cp -r /tmp/zookeeper-3.4.14 /usr/local/zookeeper || true |
| 96 | + |
| 97 | + # rust |
| 98 | + wget --no-verbose https://golang.org/dl/go1.15.5.linux-amd64.tar.gz -P /tmp |
| 99 | + sudo tar -C /usr/local -xzf /tmp/go1.15.5.linux-amd64.tar.gz |
| 100 | + curl -sf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --profile minimal --default-toolchain 1.48.0 |
| 101 | + |
| 102 | + # clean |
| 103 | + rm -fr /tmp/apache-arrow-archive-keyring-latest-$(lsb_release --codename --short).deb |
| 104 | + rm -fr /tmp/zookeeper-3.4.14.tar.gz /tmp/zookeeper-3.4.14 /tmp/go1.15.5.linux-amd64.tar.gz |
| 105 | + |
| 106 | + # install python packages for vineyard codegen |
| 107 | + pip3 install -U pip --user |
| 108 | + pip3 install libclang parsec setuptools wheel twine --user |
| 109 | + fi |
| 110 | + |
| 111 | + check_dependencies_version |
| 112 | +} |
| 113 | + |
| 114 | +get_os_version |
| 115 | + |
| 116 | +check_os_compatibility |
| 117 | + |
| 118 | +install_dependencies |
| 119 | + |
| 120 | +echo "The script has successfully install dependencies for GraphScope." |
| 121 | + |
| 122 | +set +x |
| 123 | +set +e |
| 124 | +set +o pipefail |
0 commit comments