2015-05-16 15:20:14 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-05-13 02:40:26 +00:00
|
|
|
#
|
|
|
|
# This script works with CentOS 6 or 7
|
2015-05-16 22:03:22 +00:00
|
|
|
# The CentOS 5 kernel is too old for go's liking, but this script works on CentOS 5
|
2015-05-13 02:40:26 +00:00
|
|
|
|
2015-05-16 15:20:14 +00:00
|
|
|
set -eu
|
|
|
|
|
2015-05-13 02:40:26 +00:00
|
|
|
trap 'echo FAIL' ERR
|
|
|
|
|
2015-05-18 00:36:36 +00:00
|
|
|
REDHAT_VERSION=($(head -n 1 /etc/redhat-release | \grep -Eo '[0-9]+'))
|
|
|
|
|
2015-07-12 20:33:56 +00:00
|
|
|
cd $(dirname ${BASH_SOURCE[0]})
|
|
|
|
|
2015-05-18 00:36:36 +00:00
|
|
|
if [[ ${REDHAT_VERSION[0]} == 5 ]]; then
|
2015-07-12 20:33:56 +00:00
|
|
|
if ! rpm -q epel-release; then
|
|
|
|
yum install -y epel-release
|
|
|
|
fi
|
2015-07-13 04:37:58 +00:00
|
|
|
yum install -y bison git make man which perl-Digest-SHA
|
2015-05-16 22:03:22 +00:00
|
|
|
else
|
2015-05-18 00:36:36 +00:00
|
|
|
if [[ ${REDHAT_VERSION[0]} == 6 ]]; then
|
2015-07-12 20:33:56 +00:00
|
|
|
rpm -q epel-release || yum install -y epel-release
|
2015-07-13 04:37:58 +00:00
|
|
|
yum install -y bison golang make man which perl-Digest-SHA
|
2015-07-12 20:33:56 +00:00
|
|
|
if which git > /dev/null 2>&1; then
|
|
|
|
GIT_VERSION=($(git --version))
|
|
|
|
IFS_OLD=${IFS}
|
|
|
|
IFS=.
|
|
|
|
GIT_VERSION=(${GIT_VERSION[2]})
|
|
|
|
IFS=${IFS_OLD}
|
|
|
|
else
|
|
|
|
GIT_VERSION=(0 0 0)
|
|
|
|
fi
|
|
|
|
if ( [[ ${GIT_VERSION[0]} == 1 ]] && [[ ${GIT_VERSION[1]} < 8 ]] ) || [[ ${GIT_VERSION[0]} < 1 ]]; then
|
|
|
|
mkdir -p git_build
|
|
|
|
pushd git_build
|
|
|
|
curl -L -O https://www.kernel.org/pub/software/scm/git/git-2.4.5.tar.xz
|
|
|
|
yum install -y curl-devel expat-devel gettext openssl-devel zlib-devel perl-Error perl-ExtUtils-MakeMaker emacs asciidoc xmlto gcc tar
|
|
|
|
tar Jxvf git-*.tar.xz
|
|
|
|
pushd git-*/
|
|
|
|
make
|
|
|
|
make install prefix=/usr/local
|
|
|
|
popd
|
|
|
|
popd
|
|
|
|
rm -rf git_build
|
|
|
|
fi
|
|
|
|
else
|
2015-07-13 04:37:58 +00:00
|
|
|
yum install -y bison git golang make man which perl-Digest-SHA
|
2015-05-16 22:03:22 +00:00
|
|
|
fi
|
|
|
|
fi
|
2015-05-16 16:13:50 +00:00
|
|
|
|
|
|
|
if git rev-parse; then
|
|
|
|
cd $(git rev-parse --show-toplevel)
|
2015-05-18 01:01:38 +00:00
|
|
|
elif [ -e bootstrap ];then
|
2015-05-16 16:39:02 +00:00
|
|
|
cd ..
|
2015-05-16 16:13:50 +00:00
|
|
|
else
|
|
|
|
cd /tmp
|
|
|
|
[ -d git-lfs ] || git clone https://github.com/github/git-lfs
|
|
|
|
cd git-lfs
|
|
|
|
fi
|
|
|
|
|
2015-05-18 00:36:36 +00:00
|
|
|
if [[ ${REDHAT_VERSION[0]} == 5 ]]; then
|
|
|
|
if ! env PATH=${PATH}:`pwd`/go/bin which gofmt > /dev/null 2>&1; then
|
|
|
|
yum install -y gcc glibc
|
|
|
|
curl -L -O https://storage.googleapis.com/golang/go1.4.2.src.tar.gz
|
|
|
|
tar -zxvf go1.4.2.src.tar.gz
|
|
|
|
rm go1.4.2.src.tar.gz
|
|
|
|
pushd ./go/src
|
|
|
|
sed -i 's|.*--build-id.*||' ./cmd/go/build.go
|
|
|
|
./make.bash
|
|
|
|
#This will have a few failures, but that is expected in CentOS 5
|
|
|
|
./run.bash | true
|
|
|
|
popd
|
|
|
|
fi
|
2015-06-19 22:11:42 +00:00
|
|
|
#If go isn't in the path, then it's in the go dir, so add it to the path
|
|
|
|
if ! which gofmt > /dev/null 2>&1; then
|
|
|
|
export PATH=${PATH}:`pwd`/go/bin
|
|
|
|
fi
|
2015-05-18 00:36:36 +00:00
|
|
|
fi
|
|
|
|
|
2015-05-30 00:41:13 +00:00
|
|
|
mkdir -p src/github.com/github
|
2015-06-18 04:19:04 +00:00
|
|
|
if [ ! -e "src/github.com/github/git-lfs" ]; then
|
|
|
|
ln -s $(pwd) src/github.com/github/git-lfs
|
|
|
|
fi
|
2015-05-30 00:41:13 +00:00
|
|
|
GOPATH=`pwd` ./script/bootstrap
|
|
|
|
|
2015-05-13 02:40:26 +00:00
|
|
|
install -D bin/git-lfs /usr/local/bin
|
|
|
|
git lfs init
|
|
|
|
|
2015-05-16 15:20:14 +00:00
|
|
|
if which ruby > /dev/null 2>&1; then
|
|
|
|
IFS_OLD=${IFS}
|
|
|
|
IFS=.
|
|
|
|
RUBY_VERSION=($(ruby -e "print RUBY_VERSION"))
|
|
|
|
IFS=${IFS_OLD}
|
|
|
|
else
|
|
|
|
RUBY_VERSION=(0 0 0) #Thanks -u!
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${RUBY_VERSION[0]} < 2 ]]; then
|
2015-05-18 00:36:36 +00:00
|
|
|
if [[ ${REDHAT_VERSION[0]} < 7 ]]; then
|
2015-05-16 15:20:14 +00:00
|
|
|
yum install -y tar
|
2015-05-17 03:30:11 +00:00
|
|
|
#if gpg isn't installed, everything actually works. if it is, the key must be added or rvm won't work
|
2015-05-18 00:36:36 +00:00
|
|
|
which gpg2 > /dev/null 2>&1 &&
|
|
|
|
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
|
|
|
|
which gpg > /dev/null 2>&1 &&
|
|
|
|
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
|
2015-05-16 22:03:22 +00:00
|
|
|
set +e #For CentOS 5
|
|
|
|
curl -L get.rvm.io | bash -s stable
|
2015-05-16 15:20:14 +00:00
|
|
|
set +u
|
|
|
|
source /usr/local/rvm/scripts/rvm
|
2015-05-16 22:03:22 +00:00
|
|
|
rvm install ruby
|
2015-05-16 15:20:14 +00:00
|
|
|
rvm use ruby
|
2015-05-16 22:03:22 +00:00
|
|
|
set -ue
|
2015-05-16 15:20:14 +00:00
|
|
|
elif grep -q ' 7' /etc/redhat-release; then
|
2015-05-18 00:36:36 +00:00
|
|
|
yum install -y ruby ruby-devel
|
2015-05-16 15:20:14 +00:00
|
|
|
fi
|
2015-05-13 02:40:26 +00:00
|
|
|
fi
|
|
|
|
|
2015-05-16 15:20:14 +00:00
|
|
|
gem install ronn
|
2015-05-30 00:41:13 +00:00
|
|
|
GOPATH=`pwd` ./script/man
|
2015-05-16 15:20:14 +00:00
|
|
|
install -D man/*.1 /usr/local/share/man/man1
|
|
|
|
git help lfs > /dev/null
|
|
|
|
|
2015-05-13 02:40:26 +00:00
|
|
|
echo SUCCESS
|