5 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8 # TODO this is kind of a hacky way of determining if root is required -
9 # ideally we wouuld set up a little virtualenv in the dependencies folder
11 if command -v sudo >/dev/null 2>&1; then
14 echo "The bootstrap script needs to install a few packages to your system as an admin, and we will use the 'sudo' command - enter your password to continue"
15 $SUDO_CMD ls > /dev/null
19 if [ ${KERNEL:0:7} == "MINGW32" ]; then
21 elif [ ${KERNEL:0:6} == "CYGWIN" ]; then
23 elif [ $KERNEL == "Darwin" ]; then
27 if ! command -v lsb_release >/dev/null 2>&1; then
29 if command -v pacman>/dev/null 2>&1; then
30 $SUDO_CMD pacman -S lsb-release
34 DISTRO=`lsb_release -si`
38 echo >&2 "${bldred}$@${txtrst}"
44 echo "${bldred}Missing \"$1\"${txtrst} - run the Cygwin installer again and select the base package set:"
45 echo " $CYGWIN_PACKAGES"
46 echo "After installing the packages, re-run this bootstrap script."
50 if ! command -v tput >/dev/null 2>&1; then
51 if [ $OS == "cygwin" ]; then
52 echo "OPTIONAL: Install the \"ncurses\" package in Cygwin to get colored shell output"
55 txtrst=$(tput sgr0) # reset
56 bldred=${txtbld}$(tput setaf 1)
57 bldgreen=${txtbld}$(tput setaf 2)
70 echo "Press Enter when done"
76 if [ $OS == "cygwin" ]; then
78 elif [ $OS == "mac" ]; then
79 # brew exists with 1 if it's already installed
84 if [ -z $DISTRO ]; then
86 echo "Missing $1 - install it using your distro's package manager or build from source"
89 if [ $DISTRO == "arch" ]; then
90 $SUDO_CMD pacman -S $1
91 elif [ $DISTRO == "Ubuntu" ]; then
92 $SUDO_CMD apt-get update -qq
93 $SUDO_CMD apt-get install $1 -y
96 echo "Missing $1 - install it using your distro's package manager or build from source"
103 CYGWIN_PACKAGES="make curl, libsasl2, ca-certificates, ncurses, python-setuptools"
108 curl $url -L --O $filename
111 if [ `id -u` == 0 ]; then
112 die "Error: running as root - don't use 'sudo' with this script"
115 if ! command -v curl >/dev/null 2>&1; then
116 if [ $OS == "cygwin" ]; then
123 if [ $OS == "windows" ]; then
124 die "Sorry, the bootstrap script for compiling from source doesn't support the Windows console - try Cygwin."
127 if [ $OS == "mac" ] && ! command -v brew >/dev/null 2>&1; then
128 echo "Installing Homebrew..."
129 ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
132 if ! command -v make >/dev/null 2>&1; then
133 if [ $OS == "cygwin" ]; then
135 elif [ $OS == "mac" ]; then
136 die "Missing 'make' - install the Xcode CLI tools"
138 if [ $DISTRO == "arch" ]; then
139 $SUDO_CMD pacman -S base-devel
140 elif [ $DISTRO == "Ubuntu" ]; then
141 $SUDO_CMD apt-get update -qq
142 $SUDO_CMD apt-get install build-essential -y
147 if ! command -v python >/dev/null 2>&1; then
148 echo "Installing Python..."
152 if ! command -v pip >/dev/null 2>&1; then
153 echo "Installing Pip..."
154 if ! command -v easy_install >/dev/null 2>&1; then
155 die "easy_install not available, can't install pip"
158 $SUDO_CMD easy_install pip
161 $SUDO_CMD pip install -U pip
162 $SUDO_CMD pip install --pre -Ur pip-requirements.txt
164 if ! command -v protoc >/dev/null 2>&1; then
165 if [ $OS == "cygwin" ]; then
166 _cygwin_error "protobuf"
167 elif [ $OS == "mac" ] || [ $OS == "linux" ]; then
168 if [ $DISTRO == "Ubuntu" ]; then
169 _install protobuf-compiler
179 echo "${bldgreen}All developer dependencies installed, ready to compile.$txtrst"