diff --git a/script/centos-build b/script/centos-build index 0db20bac..c4f6bc92 100755 --- a/script/centos-build +++ b/script/centos-build @@ -1,29 +1,100 @@ -#!/bin/bash -eu +#!/usr/bin/env bash # # This script works with CentOS 6 or 7 -# The CentOS 5 kernel is too old for go's liking. +# The CentOS 5 kernel is too old for go's liking, but this script works on CentOS 5 + +set -eu trap 'echo FAIL' ERR -if grep -q ' 6' /etc/redhat-release; then - rpm -q epel-release || rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm +REDHAT_VERSION=($(head -n 1 /etc/redhat-release | \grep -Eo '[0-9]+')) + +if [[ ${REDHAT_VERSION[0]} == 5 ]]; then + pushd /tmp + #Don't know why rpm -Uvh {url} doesn't work... Probably 302 + if ! rpm -q epel-release; then + yum install -y curl.x86_64 #Centos 5 isn't as smart about not downloading 32 bit + curl -L -O http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm + rpm -Uvh epel-release-5-4.noarch.rpm + rm epel-release-5-4.noarch.rpm + fi + popd + yum install -y bison git make man which +else + if [[ ${REDHAT_VERSION[0]} == 6 ]]; then + rpm -q epel-release || rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm + fi + + yum install -y bison git golang make man which fi -yum install -y bison git golang make man -cd /tmp -[ -d git-lfs ] || git clone https://github.com/github/git-lfs -cd git-lfs -./script/bootstrap +cd $(dirname ${BASH_SOURCE[0]}) +if git rev-parse; then + cd $(git rev-parse --show-toplevel) +elif [ -e bootstrap ];then + cd .. +else + cd /tmp + [ -d git-lfs ] || git clone https://github.com/github/git-lfs + cd git-lfs +fi + +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 + export GOROOT=`pwd`/go + export PATH=${PATH}:${GOROOT}/bin +fi + +mkdir -p src/github.com/github +ln -s $(pwd) src/github.com/github/git-lfs +GOPATH=`pwd` ./script/bootstrap + install -D bin/git-lfs /usr/local/bin git lfs init -# I don't know how to install ruby2.0 on CentOS6 yet -if grep -q ' 7' /etc/redhat-release; then - yum install ruby ruby-devel - gem install ronn - ./script/man - install -D man/*.1 /usr/local/share/man/man1 - git help lfs > /dev/null +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 + if [[ ${REDHAT_VERSION[0]} < 7 ]]; then + yum install -y tar + #if gpg isn't installed, everything actually works. if it is, the key must be added or rvm won't work + 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 + set +e #For CentOS 5 + curl -L get.rvm.io | bash -s stable + set +u + source /usr/local/rvm/scripts/rvm + rvm install ruby + rvm use ruby + set -ue + elif grep -q ' 7' /etc/redhat-release; then + yum install -y ruby ruby-devel + fi +fi + +gem install ronn +GOPATH=`pwd` ./script/man +install -D man/*.1 /usr/local/share/man/man1 +git help lfs > /dev/null + echo SUCCESS diff --git a/script/debian-build b/script/debian-build index 91bbb734..478a9c1a 100755 --- a/script/debian-build +++ b/script/debian-build @@ -18,9 +18,17 @@ if [[ $go_version < 1.3.1 ]]; then set -u fi -cd /tmp -[ -d git-lfs ] || git clone https://github.com/github/git-lfs -cd git-lfs +cd $(dirname ${BASH_SOURCE[0]}) +if git rev-parse; then + cd $(git rev-parse --show-toplevel) +elif [ -e bootstrap ];then + cd .. +else + cd /tmp + [ -d git-lfs ] || git clone https://github.com/github/git-lfs + cd git-lfs +fi + ./script/bootstrap install -D bin/git-lfs /usr/local/bin git lfs init