From db2f8e733dc9408b0b981178a2461eba10c40f0e Mon Sep 17 00:00:00 2001 From: From: Pat Riehecky Date: Jul 10 2014 15:47:06 +0000 Subject: Now (optionally) supports software collections --- diff --git a/into_srpm.sh b/into_srpm.sh index 4b8c9ea..6ff2260 100755 --- a/into_srpm.sh +++ b/into_srpm.sh @@ -20,6 +20,7 @@ usage() { echo ' -h: This help message' >&2 echo ' -q: Suppress warnings' >&2 echo ' -t: Set srpm timestamp to commit date' >&2 + echo ' -s: Allow building as a SCL style package' >&2 echo '' >&2 echo ' -b: specify a branch to examine' >&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 '' >&2 echo " $0" >&2 - echo " $0 -b c7" >&2 + echo " $0 -b c7 -t" >&2 echo " $0 -b remotes/origin/c7" >&2 echo " $0 -c 865ae5909b2b5d5fb37971b7ad7960f1fd5a5ffa" >&2 echo " $0 -b c7 -c 865ae5909b2b5d5fb37971b7ad7960f1fd5a5ffa" >&2 @@ -41,6 +42,7 @@ usage() { QUIET=0 KEEPTIMESTAMP=0 +ALLOWSCL=0 COMMITHASH="" BRANCH="" @@ -49,7 +51,7 @@ BRANCH="" # nice and easy. You'll need to read the manpages for more info # utilizing 'while' construct rather than 'for arg' to avoid unnecessary # shifting of program args -args=$(getopt -o htqb:c: -- "$@") +args=$(getopt -o htsqb:c: -- "$@") eval set -- "$args" while [[ 0 -eq 0 ]]; do @@ -60,7 +62,7 @@ while [[ 0 -eq 0 ]]; do break ;; -t ) - # suppress warnings + # keep timestamps of commit on srpm KEEPTIMESTAMP=1 shift ;; @@ -69,6 +71,11 @@ while [[ 0 -eq 0 ]]; do QUIET=1 shift ;; + -s ) + # try to detect if this was an SCL and build as such + ALLOWSCL=1 + shift + ;; -c ) # Use this commit id COMMITHASH=$2 @@ -117,6 +124,13 @@ if [[ $? -ne 0 ]]; then exit 1 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 [[ $QUIET -eq 1 ]]; then git fetch >/dev/null @@ -127,6 +141,7 @@ if [[ "x${BRANCH}" != 'x' ]]; then fi fi +# Set us to requested commit for further operations if [[ "x${COMMITHASH}" != 'x' ]]; then if [[ $QUIET -eq 1 ]]; then git fetch >/dev/null @@ -137,17 +152,46 @@ if [[ "x${COMMITHASH}" != 'x' ]]; then fi fi +# Download archive from git.centos.org if [[ $QUIET -eq 1 ]]; then get_sources.sh else get_sources.sh -q fi -if [[ $QUIET -eq 1 ]]; then - rpmbuild --define "%_topdir `pwd`" --define "%dist `return_disttag.sh -q`" -bs --nodeps SPECS/*.spec +SPECFILE=$(cd SPECS; ls *.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=$? 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=$? fi @@ -157,7 +201,7 @@ if [[ ${KEEPTIMESTAMP} -eq 1 ]]; then fi if [[ ${RC} -ne 0 ]]; then - if [[ $QUIET -eq 1 ]]; then + if [[ ${QUIET} -eq 1 ]]; then echo "$0 failed to recreate srpm" >&2 fi exit 1