Now (optionally) supports software collections

This commit is contained in:
From: Pat Riehecky 2014-07-10 10:47:06 -05:00 committed by Johnny Hughes
parent c429fbdd94
commit db2f8e733d

View file

@ -20,6 +20,7 @@ usage() {
echo ' -h: This help message' >&2 echo ' -h: This help message' >&2
echo ' -q: Suppress warnings' >&2 echo ' -q: Suppress warnings' >&2
echo ' -t: Set srpm timestamp to commit date' >&2 echo ' -t: Set srpm timestamp to commit date' >&2
echo ' -s: Allow building as a SCL style package' >&2
echo '' >&2 echo '' >&2
echo ' -b: specify a branch to examine' >&2 echo ' -b: specify a branch to examine' >&2
echo " defaults to repo's current branch" >&2 echo " defaults to repo's current branch" >&2
@ -30,7 +31,7 @@ usage() {
echo " NOTE: your repo will be set to this commit">&2 echo " NOTE: your repo will be set to this commit">&2
echo '' >&2 echo '' >&2
echo " $0" >&2 echo " $0" >&2
echo " $0 -b c7" >&2 echo " $0 -b c7 -t" >&2
echo " $0 -b remotes/origin/c7" >&2 echo " $0 -b remotes/origin/c7" >&2
echo " $0 -c 865ae5909b2b5d5fb37971b7ad7960f1fd5a5ffa" >&2 echo " $0 -c 865ae5909b2b5d5fb37971b7ad7960f1fd5a5ffa" >&2
echo " $0 -b c7 -c 865ae5909b2b5d5fb37971b7ad7960f1fd5a5ffa" >&2 echo " $0 -b c7 -c 865ae5909b2b5d5fb37971b7ad7960f1fd5a5ffa" >&2
@ -41,6 +42,7 @@ usage() {
QUIET=0 QUIET=0
KEEPTIMESTAMP=0 KEEPTIMESTAMP=0
ALLOWSCL=0
COMMITHASH="" COMMITHASH=""
BRANCH="" BRANCH=""
@ -49,7 +51,7 @@ BRANCH=""
# nice and easy. You'll need to read the manpages for more info # nice and easy. You'll need to read the manpages for more info
# utilizing 'while' construct rather than 'for arg' to avoid unnecessary # utilizing 'while' construct rather than 'for arg' to avoid unnecessary
# shifting of program args # shifting of program args
args=$(getopt -o htqb:c: -- "$@") args=$(getopt -o htsqb:c: -- "$@")
eval set -- "$args" eval set -- "$args"
while [[ 0 -eq 0 ]]; do while [[ 0 -eq 0 ]]; do
@ -60,7 +62,7 @@ while [[ 0 -eq 0 ]]; do
break break
;; ;;
-t ) -t )
# suppress warnings # keep timestamps of commit on srpm
KEEPTIMESTAMP=1 KEEPTIMESTAMP=1
shift shift
;; ;;
@ -69,6 +71,11 @@ while [[ 0 -eq 0 ]]; do
QUIET=1 QUIET=1
shift shift
;; ;;
-s )
# try to detect if this was an SCL and build as such
ALLOWSCL=1
shift
;;
-c ) -c )
# Use this commit id # Use this commit id
COMMITHASH=$2 COMMITHASH=$2
@ -117,6 +124,13 @@ if [[ $? -ne 0 ]]; then
exit 1 exit 1
fi fi
which show_possible_srpms.sh >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo 'You need show_possible_srpms.sh from centos-git-common in PATH' >&2
exit 1
fi
# Set us to requested branch for further operations
if [[ "x${BRANCH}" != 'x' ]]; then if [[ "x${BRANCH}" != 'x' ]]; then
if [[ $QUIET -eq 1 ]]; then if [[ $QUIET -eq 1 ]]; then
git fetch >/dev/null git fetch >/dev/null
@ -127,6 +141,7 @@ if [[ "x${BRANCH}" != 'x' ]]; then
fi fi
fi fi
# Set us to requested commit for further operations
if [[ "x${COMMITHASH}" != 'x' ]]; then if [[ "x${COMMITHASH}" != 'x' ]]; then
if [[ $QUIET -eq 1 ]]; then if [[ $QUIET -eq 1 ]]; then
git fetch >/dev/null git fetch >/dev/null
@ -137,17 +152,46 @@ if [[ "x${COMMITHASH}" != 'x' ]]; then
fi fi
fi fi
# Download archive from git.centos.org
if [[ $QUIET -eq 1 ]]; then if [[ $QUIET -eq 1 ]]; then
get_sources.sh get_sources.sh
else else
get_sources.sh -q get_sources.sh -q
fi fi
if [[ $QUIET -eq 1 ]]; then SPECFILE=$(cd SPECS; ls *.spec)
rpmbuild --define "%_topdir `pwd`" --define "%dist `return_disttag.sh -q`" -bs --nodeps SPECS/*.spec
# Determine if we are an SCL
ISSCL=0
if [[ ${ALLOWSCL} -eq 1 ]]; then
mytestsclname='DA39A3EE5E6B4B0D3255BFEF95601890AFD80709'
mysclcheck=$(rpm --define "dist el" --define "scl ${mytestsclname}" -q --specfile "SPECS/${SPECFILE}" --qf '%{n}-%{v}-%{r}\n' 2>/dev/null | head -n 1)
echo ${mysclcheck} | grep -q ${mytestsclname}
if [[ $? -eq 0 ]]; then
ISSCL=1
SCLNAME=$(show_possible_srpms.sh | cut -d'-' -f1 | sort -u)
if [[ $(echo ${SCLNAME} | wc -l) -ne 1 ]]; then
echo "$0 failed to determine unique SCL name" >&2
echo "Found:" >&2
echo "${SCLNAME}" >&2
fi
fi
fi
# build our rpmopts list
RPMOPTS="-bs --nodeps"
if [[ ${QUIET} -eq 1 ]]; then
DIST=$(return_disttag.sh -q)
else
DIST=$(return_disttag.sh)
fi
# put it all together
if [[ ${ISSCL} -eq 1 ]]; then
rpmbuild --define "%_topdir `pwd`" ${RPMOPTS} --define "%dist ${DIST}" --define "%scl ${SCLNAME}" SPECS/${SPECFILE}
RC=$? RC=$?
else else
rpmbuild --define "%_topdir `pwd`" --define "%dist `return_disttag.sh`" -bs --nodeps SPECS/*.spec rpmbuild --define "%_topdir `pwd`" ${RPMOPTS} --define "%dist ${DIST}" SPECS/${SPECFILE}
RC=$? RC=$?
fi fi
@ -157,7 +201,7 @@ if [[ ${KEEPTIMESTAMP} -eq 1 ]]; then
fi fi
if [[ ${RC} -ne 0 ]]; then if [[ ${RC} -ne 0 ]]; then
if [[ $QUIET -eq 1 ]]; then if [[ ${QUIET} -eq 1 ]]; then
echo "$0 failed to recreate srpm" >&2 echo "$0 failed to recreate srpm" >&2
fi fi
exit 1 exit 1