git-lfs/rpm/build_rpms.bsh

96 lines
2.5 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
set -eu
CURDIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
VERSION_ID=$(source /etc/os-release; echo ${VERSION_ID%%.*})
OS_NAME=$(source /etc/os-release; echo ${NAME})
OS_NAME=${OS_NAME,,}
case "${OS_NAME}" in
centos*|red*|almalinux|rocky*)
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}")
SUDO=${SUDO=`if command -v sudo > /dev/null 2>&1; then echo sudo; fi`}
export PATH=${PATH}:/usr/local/bin
set -vx
SPEC=${CURDIR}/SPECS/git-lfs.spec
$SUDO yum install -y rpm-build
mkdir -p ${CURDIR}/{BUILD,BUILDROOT,SOURCES,RPMS,SRPMS}
if ! command -v asciidoctor; then
echo "Downloading Asciidoctor ruby gem..."
pushd ${CURDIR}/SOURCES
curl -L -O https://rubygems.org/downloads/asciidoctor-2.0.17.gem
popd
echo "Building Asciidoctor ruby gem..."
"${RPMBUILD[@]}" -ba ${CURDIR}/SPECS/rubygem-asciidoctor.spec
echo "Installing Asciidoctor ruby gem..."
$SUDO yum install -y --nogpgcheck $(ls ${CURDIR}/RPMS/noarch/rubygem-*.rpm | grep -v debuginfo)
fi
rm -fr ${CURDIR}/{BUILD,BUILDROOT}
mkdir -p ${CURDIR}/{BUILD,BUILDROOT}
pushd ${CURDIR}/..
#Yes, compile lfs before compiling lfs...
FORCE_LOCALIZE=true make
2016-07-27 13:48:02 +00:00
#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}"'|' "$SPEC"
popd
#Prep the SOURCES dir for git-lfs
2015-10-30 23:27:12 +00:00
echo "Zipping up current checkout of git-lfs..."
2016-07-27 13:48:02 +00:00
echo "Cleaning ${CURDIR}/tmptar"
rm -rf ${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
tar -zcf ${CURDIR}/SOURCES/git-lfs-${LFS_VERSION}.tar.gz git-lfs-${LFS_VERSION}
popd
2016-07-27 13:48:02 +00:00
echo "Cleaning ${CURDIR}/tmptar again"
rm -rf ${CURDIR}/tmptar
#TODO TASK 2
#cp ${CURDIR}/../docker/public.key ${CURDIR}/SOURCES/RPM-GPG-KEY-GITLFS
touch ${CURDIR}/SOURCES/RPM-GPG-KEY-GITLFS
rpm/build_rpms.bsh: also build i686 RPMs In commit c2d25ee6b6d89425cf39dbc3be7a215d3d0fc050 of PR #511 we added support for building RPM packages for 32-bit platforms by updating the docker/centos_script.bsh script which was present at that time to call rpmbuild with a --target=i686 argument. Since commit 56ffe420b787ba2f738287e07d6af9f177e51b4f of PR #555 both that script and the rpm/build_rpms.bsh script contained the same logic to parse the OS name and version in order to set a short suffix for the RPM filenames. However, the docker/centos_script.bsh script was subsequently moved into the git-lfs/build-dockers repository, where it has not been updated to match the rpm/build_rpms.bsh script, such as when parsing of the OS major version was added in commit e93940960ee0e1749a2de6616150cd10061b18e2 of PR #5054, which allows us to properly parse the version number on CentOS/Rocky Linux 8 and above, or when parsing of the Rocky Linux OS name was added in commit 723be34bd0e9802c0dc5fa728edf86cc16bc62b0 of PR #5144. The result is that at present we build 32-bit RPMs for CentOS 8 and Rocky Linux 9 (el8 and el9, respectively) without the platform short name suffix in their filenames, e.g., git-lfs-3.3.0-1.i686.rpm and git-lfs-3.3.0-1.i686.rpm, and then upload them to Packagecloud with those names. To resolve this problem and avoid later regressions between the two sets of parsing logic, we move the rpmbuild command for 32-bit packages into our rpm/build_rpms.bsh script, which ensures they will be built with the same context as our 64-bit packages. To do this we introduce an rpmbuild command with the --target=i686 argument into rpm/build_rpms.bsh, which allows us to also remove the rpmbuild command from the centos_script.bsh script in the git-lfs/build-dockers repository in PR git-lfs/build-dockers#54.
2022-12-28 03:48:11 +00:00
echo "Build git-lfs RPMs..."
2015-07-24 02:57:39 +00:00
2019-07-24 07:17:40 +00:00
#--no-deps added for now so you can compile without official rpms installed
"${RPMBUILD[@]}" --nodeps -ba "$SPEC"
rpm/build_rpms.bsh: also build i686 RPMs In commit c2d25ee6b6d89425cf39dbc3be7a215d3d0fc050 of PR #511 we added support for building RPM packages for 32-bit platforms by updating the docker/centos_script.bsh script which was present at that time to call rpmbuild with a --target=i686 argument. Since commit 56ffe420b787ba2f738287e07d6af9f177e51b4f of PR #555 both that script and the rpm/build_rpms.bsh script contained the same logic to parse the OS name and version in order to set a short suffix for the RPM filenames. However, the docker/centos_script.bsh script was subsequently moved into the git-lfs/build-dockers repository, where it has not been updated to match the rpm/build_rpms.bsh script, such as when parsing of the OS major version was added in commit e93940960ee0e1749a2de6616150cd10061b18e2 of PR #5054, which allows us to properly parse the version number on CentOS/Rocky Linux 8 and above, or when parsing of the Rocky Linux OS name was added in commit 723be34bd0e9802c0dc5fa728edf86cc16bc62b0 of PR #5144. The result is that at present we build 32-bit RPMs for CentOS 8 and Rocky Linux 9 (el8 and el9, respectively) without the platform short name suffix in their filenames, e.g., git-lfs-3.3.0-1.i686.rpm and git-lfs-3.3.0-1.i686.rpm, and then upload them to Packagecloud with those names. To resolve this problem and avoid later regressions between the two sets of parsing logic, we move the rpmbuild command for 32-bit packages into our rpm/build_rpms.bsh script, which ensures they will be built with the same context as our 64-bit packages. To do this we introduce an rpmbuild command with the --target=i686 argument into rpm/build_rpms.bsh, which allows us to also remove the rpmbuild command from the centos_script.bsh script in the git-lfs/build-dockers repository in PR git-lfs/build-dockers#54.
2022-12-28 03:48:11 +00:00
"${RPMBUILD[@]}" --nodeps --target=i686 -bb "$SPEC"
2015-10-30 23:27:12 +00:00
echo "All Done!"