[CentOS-devel] [PATCH 1/2] Added switch to preserve timestamps on creation of SRPMs for ls -ltr
Pat Riehecky
riehecky at fnal.gov
Thu Jul 10 15:35:53 UTC 2014
From: Pat Riehecky <riehecky at 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
--
1.7.1
More information about the CentOS-devel
mailing list