2015-05-19 03:29:07 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
CURDIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
2015-07-31 05:47:47 +00:00
|
|
|
if [ -e /etc/os-release ]; then
|
|
|
|
VERSION_ID=$(source /etc/os-release; echo ${VERSION_ID})
|
|
|
|
OS_NAME=$(source /etc/os-release; echo ${NAME})
|
|
|
|
OS_NAME=${OS_NAME,,}
|
|
|
|
else #Basically Centos 5/6
|
|
|
|
VERSION_ID=($(head -n 1 /etc/redhat-release | \grep -Eo '[0-9]+'))
|
|
|
|
OS_NAME=$(awk '{print tolower($1)}' /etc/redhat-release)
|
|
|
|
#Stupid ancient bash 3...
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "${OS_NAME}" in
|
|
|
|
centos*|red*)
|
|
|
|
RPM_DIST=".el${VERSION_ID}"
|
|
|
|
;;
|
|
|
|
fedora)
|
|
|
|
RPM_DIST=".fc${VERSION_ID}"
|
|
|
|
;;
|
|
|
|
sles)
|
|
|
|
RPM_DIST=".sles${VERSION_ID}"
|
|
|
|
;;
|
|
|
|
opensuse)
|
|
|
|
RPM_DIST=".opensuse${VERSION_ID}"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
RPM_DIST="%{nil}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
RPMBUILD=(rpmbuild --define "_topdir ${CURDIR}" --define "dist ${RPM_DIST}")
|
|
|
|
if [[ ${NODEPS:-0} != 0 ]]; then
|
|
|
|
RPMBUILD=("${RPMBUILD[@]}" --nodeps)
|
2015-06-19 22:11:42 +00:00
|
|
|
fi
|
2015-05-19 03:29:07 +00:00
|
|
|
LOG=${CURDIR}/build.log
|
2015-07-12 05:37:38 +00:00
|
|
|
SUDO=${SUDO=`if which sudo > /dev/null 2>&1; then echo sudo; fi`}
|
2015-05-19 03:29:07 +00:00
|
|
|
export PATH=${PATH}:/usr/local/bin
|
|
|
|
|
|
|
|
exec 6>&1
|
|
|
|
exec 7>&2
|
|
|
|
|
|
|
|
exec > $LOG
|
|
|
|
exec 2>> $LOG
|
|
|
|
|
|
|
|
set -vx
|
|
|
|
|
|
|
|
echo "Downloading/checking for some essentials..." >&6
|
2015-07-09 17:22:48 +00:00
|
|
|
if which git > /dev/null 2>&1; then
|
|
|
|
GIT_VERSION=($(git --version))
|
2015-07-12 19:56:00 +00:00
|
|
|
IFS_OLD=${IFS}
|
|
|
|
IFS=.
|
|
|
|
GIT_VERSION=(${GIT_VERSION[2]})
|
|
|
|
IFS=${IFS_OLD}
|
2015-07-09 17:22:48 +00:00
|
|
|
else
|
|
|
|
GIT_VERSION=(0 0 0)
|
|
|
|
fi
|
|
|
|
|
2015-07-31 05:47:47 +00:00
|
|
|
SPEC=${CURDIR}/SPECS/git-lfs.spec
|
2015-05-19 03:29:07 +00:00
|
|
|
|
2015-07-31 05:47:47 +00:00
|
|
|
if [[ ${VERSION_ID[0]} == 5 ]]; then
|
2015-07-13 04:37:58 +00:00
|
|
|
if ! rpm -q epel-release > /dev/null 2>&1; then
|
|
|
|
$SUDO yum install -y epel-release
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
$SUDO yum install -y make curl which rpm-build tar bison perl-Digest-SHA
|
|
|
|
|
2015-05-19 03:29:07 +00:00
|
|
|
mkdir -p ${CURDIR}/{BUILD,BUILDROOT,SOURCES,RPMS,SRPMS}
|
|
|
|
|
2015-07-09 17:22:48 +00:00
|
|
|
if ( [[ ${GIT_VERSION[0]} == 1 ]] && [[ ${GIT_VERSION[1]} < 8 ]] ) || [[ ${GIT_VERSION[0]} < 1 ]]; then
|
2015-07-31 05:47:47 +00:00
|
|
|
if [[ ${VERSION_ID[0]} != 6 ]]; then
|
2015-07-09 17:22:48 +00:00
|
|
|
$SUDO yum install -y git
|
2015-07-13 04:37:58 +00:00
|
|
|
else
|
2015-07-09 17:22:48 +00:00
|
|
|
$SUDO yum install -y curl-devel expat-devel gettext openssl-devel zlib-devel perl-Error perl-ExtUtils-MakeMaker emacs asciidoc xmlto gcc
|
|
|
|
#I only include emacs here because the real RHEL rpm create emacs hook, so I will too for MAX compatibility
|
|
|
|
pushd ${CURDIR}/SOURCES
|
|
|
|
curl -L -O http://vault.centos.org/6.6/os/Source/SPackages/git-1.7.1-3.el6_4.1.src.rpm
|
|
|
|
rpm2cpio git-1.7.1-3.el6_4.1.src.rpm | cpio -div git-init.el git.xinetd.in git.conf.httpd git-gui.desktop gitweb.conf.in
|
|
|
|
NEW_GIT_VERSION=$(\grep ^Version: ${CURDIR}/SPECS/git.spec | sed 's|Version:\s*\(.*\)|\1|')
|
|
|
|
curl -L -O http://kernel.org/pub/software/scm/git/git-${NEW_GIT_VERSION}.tar.xz
|
2015-07-18 04:42:13 +00:00
|
|
|
"${RPMBUILD[@]}" -ba ${CURDIR}/SPECS/git.spec
|
2015-07-09 17:22:48 +00:00
|
|
|
$SUDO yum install -y --nogpgcheck ${CURDIR}/RPMS/*/git-${NEW_GIT_VERSION}*.rpm ${CURDIR}/RPMS/*/perl-Git-${NEW_GIT_VERSION}*.rpm
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-05-19 03:29:07 +00:00
|
|
|
if ! which go; then
|
|
|
|
echo "Installing go... one way or another" >&6
|
2015-07-31 05:47:47 +00:00
|
|
|
if [[ ${VERSION_ID[0]} == 5 ]]; then
|
2015-05-19 03:29:07 +00:00
|
|
|
$SUDO yum install -y curl.x86_64 glibc gcc
|
|
|
|
${CURDIR}/golang_patch.bsh
|
2015-07-18 04:42:13 +00:00
|
|
|
"${RPMBUILD[@]}" -ba ${CURDIR}/SPECS/golang.spec
|
2015-07-24 02:57:39 +00:00
|
|
|
$SUDO yum install -y --nogpgcheck ${CURDIR}/RPMS/noarch/golang-1*.rpm \
|
|
|
|
${CURDIR}/RPMS/noarch/golang-pkg-bin-linux-amd64-1*.rpm \
|
|
|
|
${CURDIR}/RPMS/noarch/golang-src-1*.noarch.rpm \
|
|
|
|
${CURDIR}/RPMS/noarch/golang-pkg-linux-amd64-1*.noarch.rpm \
|
|
|
|
${CURDIR}/RPMS/noarch/golang-pkg-linux-386-1*.noarch.rpm
|
2015-05-19 03:29:07 +00:00
|
|
|
else
|
|
|
|
$SUDO yum install -y epel-release
|
|
|
|
$SUDO yum install -y golang
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
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)
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${RUBY_VERSION[0]} < 2 ]]; then
|
2015-07-31 05:47:47 +00:00
|
|
|
if [[ ${VERSION_ID[0]} < 7 ]]; then
|
2015-05-19 03:29:07 +00:00
|
|
|
echo "Downloading ruby..." >&6
|
|
|
|
|
|
|
|
if ! rpm -q epel-release; then
|
2015-07-12 14:19:24 +00:00
|
|
|
$SUDO yum install -y epel-release #Optional part of centos
|
2015-05-19 03:29:07 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
$SUDO yum install -y patch libyaml-devel glibc-headers autoconf gcc-c++ glibc-devel readline-devel zlib-devel libffi-devel openssl-devel automake libtool sqlite-devel
|
|
|
|
pushd ${CURDIR}/SOURCES
|
2015-06-19 07:22:10 +00:00
|
|
|
curl -L -O http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz
|
2015-05-19 03:29:07 +00:00
|
|
|
popd
|
|
|
|
echo "Building ruby..." >&6
|
2015-07-18 04:42:13 +00:00
|
|
|
"${RPMBUILD[@]}" -ba ${CURDIR}/SPECS/ruby.spec
|
2015-05-19 03:29:07 +00:00
|
|
|
echo "Installing ruby..." >&6
|
2015-06-19 07:22:10 +00:00
|
|
|
$SUDO yum install -y --nogpgcheck ${CURDIR}/RPMS/x86_64/ruby*.rpm
|
2015-05-19 03:29:07 +00:00
|
|
|
else
|
|
|
|
$SUDO yum install -y ruby ruby-devel
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! which ronn; then
|
|
|
|
echo "Downloading some ruby gems..." >&6
|
2015-06-19 07:22:10 +00:00
|
|
|
pushd ${CURDIR}/SOURCES
|
2015-05-19 03:29:07 +00:00
|
|
|
curl -L -O https://rubygems.org/downloads/rdiscount-2.1.8.gem
|
|
|
|
curl -L -O https://rubygems.org/downloads/hpricot-0.8.6.gem
|
|
|
|
curl -L -O https://rubygems.org/downloads/mustache-1.0.1.gem
|
|
|
|
curl -L -O https://rubygems.org/downloads/ronn-0.7.3.gem
|
|
|
|
popd
|
|
|
|
|
|
|
|
echo "Building ruby gems..." >&6
|
2015-07-18 04:42:13 +00:00
|
|
|
"${RPMBUILD[@]}" -ba ${CURDIR}/SPECS/rubygem-rdiscount.spec
|
|
|
|
"${RPMBUILD[@]}" -ba ${CURDIR}/SPECS/rubygem-mustache.spec
|
|
|
|
"${RPMBUILD[@]}" -ba ${CURDIR}/SPECS/rubygem-hpricot.spec
|
|
|
|
"${RPMBUILD[@]}" -ba ${CURDIR}/SPECS/rubygem-ronn.spec
|
2015-05-19 03:29:07 +00:00
|
|
|
|
|
|
|
echo "Installing ruby gems..." >&6
|
2015-06-19 07:22:10 +00:00
|
|
|
$SUDO yum install -y --nogpgcheck $(ls ${CURDIR}/RPMS/noarch/rubygem-*.rpm ${CURDIR}/RPMS/x86_64/rubygem-*.rpm | grep -v debuginfo)
|
2015-05-19 03:29:07 +00:00
|
|
|
fi
|
|
|
|
|
2015-07-30 05:02:46 +00:00
|
|
|
pushd ${CURDIR}/..
|
|
|
|
#Yes, compile lfs before compiling lfs...
|
|
|
|
./script/bootstrap
|
|
|
|
#Use the version output to grab the version number and short sha
|
|
|
|
#(that yes, I could have gotten from git myself)
|
|
|
|
LFS_VERSION=$(./bin/git-lfs version | sed -r 's|.*/([0-9.]*).*|\1|')
|
|
|
|
sed -i 's|\(^Version:\s*\).*|\1'"${LFS_VERSION}"'|' ${CURDIR}/SPECS/git-lfs.spec
|
2015-07-31 20:32:40 +00:00
|
|
|
#LFS_SHA=$(git rev-parse --short HEAD)
|
|
|
|
#sed -i 's|\(^commit=*\).*|\1'"${LFS_SHA}"'|' ./script/run
|
|
|
|
#Not needed thanks to #549
|
2015-07-30 05:02:46 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
#Prep the SOURCES dir for git-lfs
|
|
|
|
echo "Zipping up current checkout of git-lfs..." >&6
|
|
|
|
|
|
|
|
rm -rvf ${CURDIR}/tmptar
|
|
|
|
mkdir -p ${CURDIR}/tmptar/git-lfs-${LFS_VERSION}
|
|
|
|
pushd ${CURDIR}/..
|
|
|
|
#I started running out of space in the docker, so I needed to copy a little less waste
|
|
|
|
tar -c . --exclude tmptar --exclude repos | tar -x -C ${CURDIR}/tmptar/git-lfs-${LFS_VERSION}/
|
|
|
|
popd
|
|
|
|
pushd ${CURDIR}/tmptar/git-lfs-${LFS_VERSION}
|
|
|
|
git clean -xdf
|
|
|
|
rm -rvf .git
|
|
|
|
popd
|
|
|
|
pushd ${CURDIR}/tmptar
|
|
|
|
tar -zcf ${CURDIR}/SOURCES/git-lfs-${LFS_VERSION}.tar.gz git-lfs-${LFS_VERSION}
|
|
|
|
popd
|
|
|
|
rm -rvf ${CURDIR}/tmptar
|
|
|
|
|
|
|
|
#TODO TASK 2
|
|
|
|
#cp ${CURDIR}/../docker/public.key ${CURDIR}/SOURCES/RPM-GPG-KEY-GITLFS
|
|
|
|
touch ${CURDIR}/SOURCES/RPM-GPG-KEY-GITLFS
|
|
|
|
|
|
|
|
|
2015-05-19 03:29:07 +00:00
|
|
|
echo "Build git-lfs rpm..." >&6
|
2015-07-24 02:57:39 +00:00
|
|
|
|
2015-07-18 04:42:13 +00:00
|
|
|
"${RPMBUILD[@]}" -ba ${CURDIR}/SPECS/git-lfs.spec
|
2015-05-19 03:29:07 +00:00
|
|
|
|
|
|
|
echo "All Done!" >&6
|