From b8acf77d72644b644e8fa3c4f6c4d5297c84c9fa Mon Sep 17 00:00:00 2001 From: Andy Neff Date: Sat, 16 May 2015 11:20:14 -0400 Subject: [PATCH 01/10] Install ruby on CentOS 6 On CentOS 6, it will download the rvm and install the latest stable ruby release Tested on a BARE MINIMUM CentOS 6.6/6.5 chroot with nothing but yum installed --- script/centos-build | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/script/centos-build b/script/centos-build index 0db20bac..bcbaf79b 100755 --- a/script/centos-build +++ b/script/centos-build @@ -1,15 +1,17 @@ -#!/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. +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 fi -yum install -y bison git golang make man +yum install -y bison git golang make man which cd /tmp [ -d git-lfs ] || git clone https://github.com/github/git-lfs cd git-lfs @@ -17,13 +19,32 @@ cd git-lfs 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 grep -q ' 6' /etc/redhat-release; then + yum install -y tar + gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 + curl -L get.rvm.io | bash -s stable --ruby + set +u + source /usr/local/rvm/scripts/rvm + rvm use ruby + set -u + elif grep -q ' 7' /etc/redhat-release; then + yum install ruby ruby-devel + fi +fi + +gem install ronn +./script/man +install -D man/*.1 /usr/local/share/man/man1 +git help lfs > /dev/null + echo SUCCESS From e329c84480b990a25f4abd0d06c7de38e7cba04e Mon Sep 17 00:00:00 2001 From: Andy Neff Date: Sat, 16 May 2015 12:13:50 -0400 Subject: [PATCH 02/10] Uses current dir if its a git repo as mentioned in #299 --- script/centos-build | 13 ++++++++++--- script/debian-build | 12 +++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/script/centos-build b/script/centos-build index bcbaf79b..adac5055 100755 --- a/script/centos-build +++ b/script/centos-build @@ -12,9 +12,16 @@ if grep -q ' 6' /etc/redhat-release; then fi yum install -y bison git golang make man which -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) +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 diff --git a/script/debian-build b/script/debian-build index 91bbb734..ae8f6651 100755 --- a/script/debian-build +++ b/script/debian-build @@ -18,9 +18,15 @@ 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) +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 From 01a976cfbf709d9d31ce992da9b2e4cd14653418 Mon Sep 17 00:00:00 2001 From: Andy Neff Date: Sat, 16 May 2015 12:39:02 -0400 Subject: [PATCH 03/10] Uses current dir if its looks like an archive --- script/centos-build | 2 ++ script/debian-build | 2 ++ 2 files changed, 4 insertions(+) diff --git a/script/centos-build b/script/centos-build index adac5055..f0a2ee8e 100755 --- a/script/centos-build +++ b/script/centos-build @@ -16,6 +16,8 @@ yum install -y bison git golang make man which cd $(dirname ${BASH_SOURCE[0]}) if git rev-parse; then cd $(git rev-parse --show-toplevel) +elif [ -e ../bin/git-lfs ] && [ -d ../docs/man ] && [ -e bootstrap ];then + cd .. else cd /tmp [ -d git-lfs ] || git clone https://github.com/github/git-lfs diff --git a/script/debian-build b/script/debian-build index ae8f6651..fe521335 100755 --- a/script/debian-build +++ b/script/debian-build @@ -21,6 +21,8 @@ fi cd $(dirname ${BASH_SOURCE[0]}) if git rev-parse; then cd $(git rev-parse --show-toplevel) +elif [ -e ../bin/git-lfs ] && [ -d ../docs/man ] && [ -e bootstrap ];then + cd .. else cd /tmp [ -d git-lfs ] || git clone https://github.com/github/git-lfs From ae7482b80451456e73455a6c4cdb7439906a7996 Mon Sep 17 00:00:00 2001 From: Andy Neff Date: Sat, 16 May 2015 18:03:22 -0400 Subject: [PATCH 04/10] Added CentOS 5 support Tested against a CentOS 5.11 chroot --- script/centos-build | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/script/centos-build b/script/centos-build index f0a2ee8e..8f3fb269 100755 --- a/script/centos-build +++ b/script/centos-build @@ -1,17 +1,37 @@ #!/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 -fi +if grep -q ' 5' /etc/redhat-release; then + pushd /tmp + #No clue why rpm -Uvh {url} doesn't work... it doesn't + 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 + fi + yum install -y bison git make man which tar + #wget https://storage.googleapis.com/golang/go1.4.2.src.tar.gz --no-check-certificate + #wget https://storage.googleapis.com/golang/go1.4.2.linux-386.tar.gz --no-check-certificate + if [ ! -d /tmp/go ]; then + curl -L -O https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz + tar -zxf go1.4.2.linux-amd64.tar.gz + fi + export GOROOT=/tmp/go + export PATH=${PATH}:${GOROOT}/bin + popd +else + 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 + fi -yum install -y bison git golang make man which + yum install -y bison git golang make man which +fi cd $(dirname ${BASH_SOURCE[0]}) if git rev-parse; then @@ -38,14 +58,18 @@ else fi if [[ ${RUBY_VERSION[0]} < 2 ]]; then - if grep -q ' 6' /etc/redhat-release; then + if grep -q ' 6' /etc/redhat-release || grep -q ' 5' /etc/redhat-release; then yum install -y tar - gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 - curl -L get.rvm.io | bash -s stable --ruby + if grep -q ' 6' /etc/redhat-release; then + gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 + fi + 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 -u + set -ue elif grep -q ' 7' /etc/redhat-release; then yum install ruby ruby-devel fi From 2a86523002b96605a3b46331fd1c9c39cad86e40 Mon Sep 17 00:00:00 2001 From: Andy Neff Date: Sat, 16 May 2015 23:30:11 -0400 Subject: [PATCH 05/10] Now successfully builds on CentOS 5 Using go built on CentOS 6, CentOS 5 is able to build git-lfs It appears to work. --- script/centos-build | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/script/centos-build b/script/centos-build index 8f3fb269..b9e7826e 100755 --- a/script/centos-build +++ b/script/centos-build @@ -14,13 +14,12 @@ if grep -q ' 5' /etc/redhat-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 yum install -y bison git make man which tar - #wget https://storage.googleapis.com/golang/go1.4.2.src.tar.gz --no-check-certificate - #wget https://storage.googleapis.com/golang/go1.4.2.linux-386.tar.gz --no-check-certificate if [ ! -d /tmp/go ]; then - curl -L -O https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz - tar -zxf go1.4.2.linux-amd64.tar.gz + curl -L -O https://github.com/andyneff/go4cento5/raw/master/go-1.4.2-rhel6.tgz + tar -zxf go-1.4.2-rhel6.tgz fi export GOROOT=/tmp/go export PATH=${PATH}:${GOROOT}/bin @@ -36,7 +35,7 @@ fi cd $(dirname ${BASH_SOURCE[0]}) if git rev-parse; then cd $(git rev-parse --show-toplevel) -elif [ -e ../bin/git-lfs ] && [ -d ../docs/man ] && [ -e bootstrap ];then +elif [ -d ../docs/man ] && [ -e bootstrap ];then cd .. else cd /tmp @@ -60,8 +59,11 @@ fi if [[ ${RUBY_VERSION[0]} < 2 ]]; then if grep -q ' 6' /etc/redhat-release || grep -q ' 5' /etc/redhat-release; 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 if grep -q ' 6' /etc/redhat-release; then - gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 + gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 | true + else + gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 | true fi set +e #For CentOS 5 curl -L get.rvm.io | bash -s stable From b769b35e8d5f6bcd25969453eaca542fd614970a Mon Sep 17 00:00:00 2001 From: Andy Neff Date: Sun, 17 May 2015 03:38:50 -0400 Subject: [PATCH 06/10] Moved to sf --- script/centos-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/centos-build b/script/centos-build index b9e7826e..5af3585d 100755 --- a/script/centos-build +++ b/script/centos-build @@ -18,7 +18,7 @@ if grep -q ' 5' /etc/redhat-release; then fi yum install -y bison git make man which tar if [ ! -d /tmp/go ]; then - curl -L -O https://github.com/andyneff/go4cento5/raw/master/go-1.4.2-rhel6.tgz + curl -L -O http://sourceforge.net/projects/go4centos5/files/go-1.4.2-rhel6.tgz tar -zxf go-1.4.2-rhel6.tgz fi export GOROOT=/tmp/go From 1a82ce235d6942652dd7514677379dfa8dda8bd1 Mon Sep 17 00:00:00 2001 From: Andy Neff Date: Sun, 17 May 2015 18:38:55 -0400 Subject: [PATCH 07/10] CentOS 5 uses EPEL SRPM to build instead of download binary This no longer depends on my sf binaries for download, but I don't think anyone is going to accept the solution. While it is better, and includes all the RHEL patches, I am sure someone or EVERYONE will say "Its too complciated" etc..." Better find a simplier solution without all the patches --- script/centos-build | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/script/centos-build b/script/centos-build index 5af3585d..6e118b5f 100755 --- a/script/centos-build +++ b/script/centos-build @@ -9,7 +9,7 @@ trap 'echo FAIL' ERR if grep -q ' 5' /etc/redhat-release; then pushd /tmp - #No clue why rpm -Uvh {url} doesn't work... it doesn't + #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 @@ -17,12 +17,30 @@ if grep -q ' 5' /etc/redhat-release; then rm epel-release-5-4.noarch.rpm fi yum install -y bison git make man which tar - if [ ! -d /tmp/go ]; then - curl -L -O http://sourceforge.net/projects/go4centos5/files/go-1.4.2-rhel6.tgz - tar -zxf go-1.4.2-rhel6.tgz + if [ ! -d /usr/lib/golang ]; then + yum install -y rpm-build xz gcc glibc + mkdir -p /tmp/go/{BUILD,RPMS,SOURCES,SPECS,SRPMS} + pushd /tmp/go + #Get EPEL full list + curl -L -O https://dl.fedoraproject.org/pub/epel/fullfilelist + #Get latest golang src rpm + curl -L -O https://dl.fedoraproject.org/pub/epel/$(grep '6/SRPMS/golang-[0-9].*src.rpm' fullfilelist) + rpm2cpio *.src.rpm | cpio -div + #Patch the spec file to patch the build to work on CentOS 5 + sed -ri 's|(^%build)|\1\nsed -i '"'"'s:.*--build-id.*::'"'"' ./src/cmd/go/build.go|' *.spec + #Make SPEC CentOS 5 compliant + sed -ri 's|(^Name:.*)|\1\nGroup: Software|' *.spec + sed -ri 's|(^%package\s.*)|\1\nGroup: Software|' *.spec + #The test WILL fail, so make the rpm not fail + sed -ri 's;(.*run.bash.*);\1|true;' *.spec + mv *.spec SPECS/ + mv *.* SOURCES/ + mv *-* SOURCES/ + rpmbuild --define "_topdir `pwd`" SPECS/golang.spec -bi + popd fi - export GOROOT=/tmp/go - export PATH=${PATH}:${GOROOT}/bin + export GOROOT=/usr/lib/golang + export PATH=${PATH}:${GOROOT}/bin/linux_amd64 popd else if grep -q ' 6' /etc/redhat-release; then From caaf7a524a52ef0520bd5c45f9e1f950b06377ca Mon Sep 17 00:00:00 2001 From: Andy Neff Date: Sun, 17 May 2015 20:36:36 -0400 Subject: [PATCH 08/10] Simpler support for CentOS 5 Simple patch to go src to build on CentOS 5 Cleaned up a little Remove prompt for ruby on Centos 7 Tested on CentOS 5.11, 6.6, 7.1.1503 --- script/centos-build | 62 ++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/script/centos-build b/script/centos-build index 6e118b5f..580ad432 100755 --- a/script/centos-build +++ b/script/centos-build @@ -7,7 +7,9 @@ set -eu trap 'echo FAIL' ERR -if grep -q ' 5' /etc/redhat-release; then +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 @@ -16,34 +18,10 @@ if grep -q ' 5' /etc/redhat-release; then rpm -Uvh epel-release-5-4.noarch.rpm rm epel-release-5-4.noarch.rpm fi - yum install -y bison git make man which tar - if [ ! -d /usr/lib/golang ]; then - yum install -y rpm-build xz gcc glibc - mkdir -p /tmp/go/{BUILD,RPMS,SOURCES,SPECS,SRPMS} - pushd /tmp/go - #Get EPEL full list - curl -L -O https://dl.fedoraproject.org/pub/epel/fullfilelist - #Get latest golang src rpm - curl -L -O https://dl.fedoraproject.org/pub/epel/$(grep '6/SRPMS/golang-[0-9].*src.rpm' fullfilelist) - rpm2cpio *.src.rpm | cpio -div - #Patch the spec file to patch the build to work on CentOS 5 - sed -ri 's|(^%build)|\1\nsed -i '"'"'s:.*--build-id.*::'"'"' ./src/cmd/go/build.go|' *.spec - #Make SPEC CentOS 5 compliant - sed -ri 's|(^Name:.*)|\1\nGroup: Software|' *.spec - sed -ri 's|(^%package\s.*)|\1\nGroup: Software|' *.spec - #The test WILL fail, so make the rpm not fail - sed -ri 's;(.*run.bash.*);\1|true;' *.spec - mv *.spec SPECS/ - mv *.* SOURCES/ - mv *-* SOURCES/ - rpmbuild --define "_topdir `pwd`" SPECS/golang.spec -bi - popd - fi - export GOROOT=/usr/lib/golang - export PATH=${PATH}:${GOROOT}/bin/linux_amd64 popd + yum install -y bison git make man which else - if grep -q ' 6' /etc/redhat-release; then + 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 @@ -61,6 +39,23 @@ else 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 + ./script/bootstrap install -D bin/git-lfs /usr/local/bin git lfs init @@ -75,14 +70,13 @@ else fi if [[ ${RUBY_VERSION[0]} < 2 ]]; then - if grep -q ' 6' /etc/redhat-release || grep -q ' 5' /etc/redhat-release; 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 - if grep -q ' 6' /etc/redhat-release; then - gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 | true - else - gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 | true - fi + 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 @@ -91,7 +85,7 @@ if [[ ${RUBY_VERSION[0]} < 2 ]]; then rvm use ruby set -ue elif grep -q ' 7' /etc/redhat-release; then - yum install ruby ruby-devel + yum install -y ruby ruby-devel fi fi From 53979f7f0076327fb582e9b832d5f491f5825b3c Mon Sep 17 00:00:00 2001 From: Andy Neff Date: Sun, 17 May 2015 21:01:38 -0400 Subject: [PATCH 09/10] Changed check for git-lfs to look just for bootstrap --- script/centos-build | 2 +- script/debian-build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/centos-build b/script/centos-build index 580ad432..466c1ff8 100755 --- a/script/centos-build +++ b/script/centos-build @@ -31,7 +31,7 @@ fi cd $(dirname ${BASH_SOURCE[0]}) if git rev-parse; then cd $(git rev-parse --show-toplevel) -elif [ -d ../docs/man ] && [ -e bootstrap ];then +elif [ -e bootstrap ];then cd .. else cd /tmp diff --git a/script/debian-build b/script/debian-build index fe521335..478a9c1a 100755 --- a/script/debian-build +++ b/script/debian-build @@ -21,7 +21,7 @@ fi cd $(dirname ${BASH_SOURCE[0]}) if git rev-parse; then cd $(git rev-parse --show-toplevel) -elif [ -e ../bin/git-lfs ] && [ -d ../docs/man ] && [ -e bootstrap ];then +elif [ -e bootstrap ];then cd .. else cd /tmp From 567032e1841bb65b06cbc2b4f0e03647a97ce585 Mon Sep 17 00:00:00 2001 From: Andy Neff Date: Fri, 29 May 2015 20:41:13 -0400 Subject: [PATCH 10/10] Fixes to handle #330/#331 --- script/centos-build | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/script/centos-build b/script/centos-build index 466c1ff8..c4f6bc92 100755 --- a/script/centos-build +++ b/script/centos-build @@ -56,7 +56,10 @@ if [[ ${REDHAT_VERSION[0]} == 5 ]]; then export PATH=${PATH}:${GOROOT}/bin fi -./script/bootstrap +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 @@ -90,7 +93,7 @@ if [[ ${RUBY_VERSION[0]} < 2 ]]; then fi gem install ronn -./script/man +GOPATH=`pwd` ./script/man install -D man/*.1 /usr/local/share/man/man1 git help lfs > /dev/null