2017-01-18 20:43:35 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
LINUX=false
|
|
|
|
OSX=false
|
|
|
|
|
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
|
|
OSX=true
|
|
|
|
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
|
|
|
LINUX=true
|
|
|
|
else
|
|
|
|
echo "Platform detection failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
SUDO=''
|
2017-10-27 05:30:48 +02:00
|
|
|
if (( $EUID != 0 )); then
|
2017-01-18 20:43:35 +01:00
|
|
|
SUDO='sudo'
|
|
|
|
fi
|
|
|
|
|
|
|
|
cmd_exists() {
|
|
|
|
command -v "$1" >/dev/null 2>&1
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2017-01-25 07:24:04 +01:00
|
|
|
set +eu
|
2017-01-18 21:57:34 +01:00
|
|
|
GITUSERNAME=$(git config --global --get user.name)
|
|
|
|
if [ -z "$GITUSERNAME" ]; then
|
|
|
|
git config --global user.name "$(whoami)"
|
|
|
|
fi
|
2017-03-06 23:17:03 +01:00
|
|
|
GITEMAIL=$(git config --global --get user.email)
|
2017-01-18 21:57:34 +01:00
|
|
|
if [ -z "$GITEMAIL" ]; then
|
|
|
|
git config --global user.email "$(whoami)@lbry.io"
|
|
|
|
fi
|
2017-01-25 07:24:04 +01:00
|
|
|
set -eu
|
2017-01-18 21:57:34 +01:00
|
|
|
|
2017-01-18 20:43:35 +01:00
|
|
|
|
|
|
|
if $LINUX; then
|
|
|
|
INSTALL="$SUDO apt-get install --no-install-recommends -y"
|
2017-10-27 05:30:48 +02:00
|
|
|
$INSTALL build-essential libssl-dev libffi-dev libgmp3-dev python2.7-dev libsecret-1-dev curl
|
2017-01-18 20:43:35 +01:00
|
|
|
elif $OSX && ! cmd_exists brew ; then
|
|
|
|
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if ! cmd_exists python; then
|
|
|
|
if $LINUX; then
|
2017-01-18 22:08:27 +01:00
|
|
|
$INSTALL python2.7
|
2017-01-18 20:43:35 +01:00
|
|
|
elif $OSX; then
|
|
|
|
brew install python
|
2017-11-10 16:47:51 +01:00
|
|
|
else
|
|
|
|
echo "python2.7 required"
|
|
|
|
exit 1
|
2017-01-18 20:43:35 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
PYTHON_VERSION=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
|
|
|
|
if [ "$PYTHON_VERSION" != "2.7" ]; then
|
|
|
|
echo "Python 2.7 required"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! cmd_exists pip; then
|
|
|
|
if $LINUX; then
|
|
|
|
$INSTALL python-pip
|
2017-10-27 05:30:48 +02:00
|
|
|
elif $OSX; then
|
|
|
|
$SUDO easy_install pip
|
2017-11-10 16:47:51 +01:00
|
|
|
else
|
|
|
|
echo "pip required"
|
|
|
|
exit 1
|
2017-01-18 20:43:35 +01:00
|
|
|
fi
|
2017-10-27 05:30:48 +02:00
|
|
|
$SUDO pip install --upgrade pip
|
2017-01-18 20:43:35 +01:00
|
|
|
fi
|
|
|
|
|
2017-03-07 16:28:37 +01:00
|
|
|
if $LINUX && [ "$(pip list --format=columns | grep setuptools | wc -l)" -ge 1 ]; then
|
2017-01-18 20:43:35 +01:00
|
|
|
$SUDO pip install setuptools
|
|
|
|
fi
|
|
|
|
|
2017-01-18 22:33:27 +01:00
|
|
|
if ! cmd_exists virtualenv; then
|
|
|
|
$SUDO pip install virtualenv
|
|
|
|
fi
|
|
|
|
|
2017-01-18 20:43:35 +01:00
|
|
|
if ! cmd_exists node; then
|
|
|
|
if $LINUX; then
|
2017-12-12 19:10:09 +01:00
|
|
|
curl -sL https://deb.nodesource.com/setup_8.x | $SUDO -E bash -
|
2017-01-18 20:43:35 +01:00
|
|
|
$INSTALL nodejs
|
|
|
|
elif $OSX; then
|
|
|
|
brew install node
|
2017-11-10 16:47:51 +01:00
|
|
|
else
|
|
|
|
echo "node required"
|
|
|
|
exit 1
|
2017-01-18 20:43:35 +01:00
|
|
|
fi
|
|
|
|
fi
|
2017-04-11 16:38:32 +02:00
|
|
|
|
2017-06-23 21:18:03 +02:00
|
|
|
if ! cmd_exists yarn; then
|
|
|
|
if $LINUX; then
|
|
|
|
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | $SUDO apt-key add -
|
|
|
|
echo "deb https://dl.yarnpkg.com/debian/ stable main" | $SUDO tee /etc/apt/sources.list.d/yarn.list
|
|
|
|
$SUDO apt-get update
|
2017-12-13 14:32:41 +01:00
|
|
|
$SUDO apt-get -o Dpkg::Options::="--force-overwrite" install yarn
|
2017-06-23 21:18:03 +02:00
|
|
|
elif $OSX; then
|
|
|
|
brew install yarn
|
2017-11-10 16:47:51 +01:00
|
|
|
else
|
|
|
|
echo "yarn required"
|
|
|
|
exit 1
|
2017-06-23 21:18:03 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-04-11 16:38:32 +02:00
|
|
|
if ! cmd_exists unzip; then
|
|
|
|
if $LINUX; then
|
|
|
|
$INSTALL unzip
|
2017-11-10 16:47:51 +01:00
|
|
|
else
|
2017-04-11 16:38:32 +02:00
|
|
|
echo "unzip required"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|