[CentOS-devel] [PATCH] Added script for extracting what I think is the dist tag

Pat Riehecky riehecky at fnal.gov
Tue Jun 10 14:08:31 UTC 2014


From: Pat Riehecky <riehecky at fnal.gov>

---
 return_disttag.sh |   71 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)
 create mode 100755 return_disttag.sh

diff --git a/return_disttag.sh b/return_disttag.sh
new file mode 100755
index 0000000..cc4829c
--- /dev/null
+++ b/return_disttag.sh
@@ -0,0 +1,71 @@
+#!/bin/bash -u
+#
+# Extracts what appears to be the value of %{dist} from the commit message
+#
+# Might want to drop this in ~/bin/ and chmod u+x it
+
+#####################################################################
+usage() {
+    echo ''                                               >&2
+    echo "$0 [-hr]"                                       >&2
+    echo ''                                               >&2
+    echo ' -h: This help message'                         >&2
+    echo ' -r: Use the Redhat tag rather than centos tag' >&2
+    echo ''                                               >&2
+    echo '  Attempt to extract what appears to be the value of %{dist}' >&2
+    echo '  from the git.centos.org commit message'       >&2
+    exit 1
+}
+
+
+#####################################################################
+# setup args in the right order for making getopt evaluation
+# nice and easy.  You'll need to read the manpages for more info
+args=$(getopt -o hr -- "$@")
+if [[ $? -ne 0 ]]; then
+    usage
+fi
+eval set -- "$args"
+
+RHELTAG=0
+for arg in $@; do
+    case $1 in
+        -- )
+            # end of getopt args, shift off the -- and get out of the loop
+            shift
+            break 2
+           ;;
+         -r )
+            # skip any package with 'centos' in the dist area
+            RHELTAG=1
+           ;;
+         -h )
+            # get help
+            usage
+           ;;
+    esac
+done
+
+packagename=$(basename `pwd`)
+metadata=.${packagename}.metadata
+
+if [[ ! -e ${metadata} ]] ||  [[ ! -d .git ]] || [[ ! -d SOURCES ]]; then
+    echo 'You need to run this from inside a sources git repo'
+    exit 1
+fi
+
+msg=$(git log --pretty=format:"%s")
+pkg=$(echo ${msg} | cut -d' ' -f2)
+
+if [[ ${RHELTAG} -eq 0 ]]; then
+    thispkg=(echo ${pkg} | head -1)
+elif [[ ${RHELTAG} -eq 1 ]]; then
+    thispkg=(echo ${pkg} grep -v centos | head -1)
+else
+    echo 'Something went terribly wrong'
+    exit 1
+fi
+
+tag=$(echo ${thispkg} | awk -F"-" '{print $NF}' | tr '.' '\012'| grep -e el[[:digit:]])
+
+echo ${tag}
-- 
1.7.1




More information about the CentOS-devel mailing list