From: Pat Riehecky riehecky@fnal.gov
Just adding a few simple features to into_srpm.sh
It now works with software collecions, but only if you want.
I've also added a switch for "preserving" the timestamps of srpms created by this script, based on the the commit timestamp. It is off by default as I'm not sure how comfortable various users are with this script making 'old' files. I've found it useful to be able to 'ls -ltr' in a source directory.
Pat Riehecky (2): Added switch to preserve timestamps on creation of SRPMs for ls -ltr Now (optionally) supports software collections
into_srpm.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 63 insertions(+), 7 deletions(-)
From: Pat Riehecky riehecky@fnal.gov
--- into_srpm.sh | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/into_srpm.sh b/into_srpm.sh index 32f02b2..4b8c9ea 100755 --- a/into_srpm.sh +++ b/into_srpm.sh @@ -13,12 +13,13 @@ ##################################################################### usage() { echo '' >&2 - echo "$0 [-hq] [-b branch] [-c shasum]" >&2 + echo "$0 [-htq] [-b branch] [-c shasum]" >&2 echo '' >&2 echo 'You need to run this from inside a sources git repo' >&2 echo '' >&2 echo ' -h: This help message' >&2 echo ' -q: Suppress warnings' >&2 + echo ' -t: Set srpm timestamp to commit date' >&2 echo '' >&2 echo ' -b: specify a branch to examine' >&2 echo " defaults to repo's current branch" >&2 @@ -39,6 +40,7 @@ usage() { #####################################################################
QUIET=0 +KEEPTIMESTAMP=0 COMMITHASH="" BRANCH=""
@@ -47,7 +49,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 hqb:c: -- "$@") +args=$(getopt -o htqb:c: -- "$@") eval set -- "$args"
while [[ 0 -eq 0 ]]; do @@ -57,6 +59,11 @@ while [[ 0 -eq 0 ]]; do shift break ;; + -t ) + # suppress warnings + KEEPTIMESTAMP=1 + shift + ;; -q ) # suppress warnings QUIET=1 @@ -144,6 +151,11 @@ else RC=$? fi
+if [[ ${KEEPTIMESTAMP} -eq 1 ]]; then + timestamp=$(git log --pretty=%ai -1) + find . -type f -name *.src.rpm -exec touch -d "${timestamp}" {} ; +fi + if [[ ${RC} -ne 0 ]]; then if [[ $QUIET -eq 1 ]]; then echo "$0 failed to recreate srpm" >&2
From: Pat Riehecky riehecky@fnal.gov
--- into_srpm.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 51 insertions(+), 7 deletions(-)
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
On 07/10/2014 10:35 AM, Pat Riehecky wrote:
From: Pat Riehecky riehecky@fnal.gov
Just adding a few simple features to into_srpm.sh
It now works with software collecions, but only if you want.
I've also added a switch for "preserving" the timestamps of srpms created by this script, based on the the commit timestamp. It is off by default as I'm not sure how comfortable various users are with this script making 'old' files. I've found it useful to be able to 'ls -ltr' in a source directory.
Pat Riehecky (2): Added switch to preserve timestamps on creation of SRPMs for ls -ltr Now (optionally) supports software collections
into_srpm.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 63 insertions(+), 7 deletions(-)
All pushed