Added switch to preserve timestamps on creation of SRPMs for ls -ltr

This commit is contained in:
From: Pat Riehecky 2014-07-10 10:46:03 -05:00 committed by Johnny Hughes
parent 01a821d933
commit c429fbdd94

View file

@ -13,12 +13,13 @@
##################################################################### #####################################################################
usage() { usage() {
echo '' >&2 echo '' >&2
echo "$0 [-hq] [-b branch] [-c shasum]" >&2 echo "$0 [-htq] [-b branch] [-c shasum]" >&2
echo '' >&2 echo '' >&2
echo 'You need to run this from inside a sources git repo' >&2 echo 'You need to run this from inside a sources git repo' >&2
echo '' >&2 echo '' >&2
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 '' >&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
@ -39,6 +40,7 @@ usage() {
##################################################################### #####################################################################
QUIET=0 QUIET=0
KEEPTIMESTAMP=0
COMMITHASH="" COMMITHASH=""
BRANCH="" BRANCH=""
@ -47,7 +49,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 hqb:c: -- "$@") args=$(getopt -o htqb:c: -- "$@")
eval set -- "$args" eval set -- "$args"
while [[ 0 -eq 0 ]]; do while [[ 0 -eq 0 ]]; do
@ -57,6 +59,11 @@ while [[ 0 -eq 0 ]]; do
shift shift
break break
;; ;;
-t )
# suppress warnings
KEEPTIMESTAMP=1
shift
;;
-q ) -q )
# suppress warnings # suppress warnings
QUIET=1 QUIET=1
@ -144,6 +151,11 @@ else
RC=$? RC=$?
fi 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 [[ ${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