Debian Codegraph @

rpm/build_rpms.bsh

raw
1 #!/usr/bin/env bash
2
3 set -eu
4
5 CURDIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
6
7 VERSION_ID=$(source /etc/os-release; echo ${VERSION_ID%%.*})
8 OS_NAME=$(source /etc/os-release; echo ${NAME})
9 OS_NAME=${OS_NAME,,}
10
11 case "${OS_NAME}" in
12 centos*|red*|almalinux|rocky*)
13 RPM_DIST=".el${VERSION_ID}"
14 ;;
15 fedora)
16 RPM_DIST=".fc${VERSION_ID}"
17 ;;
18 sles)
19 RPM_DIST=".sles${VERSION_ID}"
20 ;;
21 opensuse)
22 RPM_DIST=".opensuse${VERSION_ID}"
23 ;;
24 *)
25 RPM_DIST="%{nil}"
26 ;;
27 esac
28
29 RPMBUILD=(rpmbuild --define "_topdir ${CURDIR}" --define "dist ${RPM_DIST}")
30
31 SUDO=${SUDO=`if command -v sudo > /dev/null 2>&1; then echo sudo; fi`}
32 export PATH=${PATH}:/usr/local/bin
33
34 set -vx
35
36 SPEC=${CURDIR}/SPECS/git-lfs.spec
37
38 $SUDO yum install -y rpm-build
39
40 mkdir -p ${CURDIR}/{BUILD,BUILDROOT,SOURCES,RPMS,SRPMS}
41
42 rm -fr ${CURDIR}/{BUILD,BUILDROOT}
43 mkdir -p ${CURDIR}/{BUILD,BUILDROOT}
44
45 pushd ${CURDIR}/..
46 #Yes, compile lfs before compiling lfs...
47 FORCE_LOCALIZE=true make
48 #Use the version output to grab the version number and short sha
49 #(that yes, I could have gotten from git myself)
50 LFS_VERSION=$(./bin/git-lfs version | sed -r 's|.*/([0-9.]*).*|\1|')
51 sed -i 's|\(^Version:\s*\).*|\1'"${LFS_VERSION}"'|' "$SPEC"
52 popd
53
54 #Prep the SOURCES dir for git-lfs
55 echo "Zipping up current checkout of git-lfs..."
56
57 echo "Cleaning ${CURDIR}/tmptar"
58 rm -rf ${CURDIR}/tmptar
59
60 mkdir -p ${CURDIR}/tmptar/git-lfs-${LFS_VERSION}
61 pushd ${CURDIR}/..
62 #I started running out of space in the docker, so I needed to copy a little less waste
63 tar -c --exclude tmptar --exclude repos . | tar -x -C ${CURDIR}/tmptar/git-lfs-${LFS_VERSION}/
64 popd
65 pushd ${CURDIR}/tmptar
66 tar -zcf ${CURDIR}/SOURCES/git-lfs-${LFS_VERSION}.tar.gz git-lfs-${LFS_VERSION}
67 popd
68
69 echo "Cleaning ${CURDIR}/tmptar again"
70 rm -rf ${CURDIR}/tmptar
71
72 echo "Build git-lfs RPMs..."
73
74 #--no-deps added for now so you can compile without official rpms installed
75 "${RPMBUILD[@]}" --nodeps -ba "$SPEC"
76
77 if [ "$#" -eq 1 ] && [ "$1" = "--add-i386" ]; then
78 "${RPMBUILD[@]}" --nodeps --target=i686 -bb "$SPEC"
79 fi
80
81 echo "All Done!"