From a6a9e50be4101a5529c08e9c8c1cf31a9ea0309a Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jun 10 2014 17:29:28 +0000 Subject: Find true dist macro value --- diff --git a/return_disttag.sh b/return_disttag.sh index f2e5287..f7dc610 100755 --- a/return_disttag.sh +++ b/return_disttag.sh @@ -66,6 +66,26 @@ else exit 1 fi -tag=$(echo ${thispkg} | awk -F"-" '{print $NF}' | tr '.' '\012'| grep -e el[[:digit:]]) +# strip .src.rpm if present +nvr1="${pkg%.src.rpm}" -echo ${tag} +#now get nvr from spec with placeholder dist +mydist="XXXjsdf9ur7qlkasdh4gygXXX" +nvr2=$(rpm --define "dist $mydist" -q --specfile "SPECS/$packagename.spec" --qf '%{n}-%{v}-%{r}\n' 2>/dev/null | head -n 1) + +#use our placeholder dist to split the nvr +head=${nvr2%$mydist*} + +if [ ".$head" = ".$nvr2" ] +then + #no dist tag + echo "" + exit +fi + +tail=${nvr2#*$mydist} + +frag=${nvr1#$head} +dist=${frag%$tail} + +echo "$dist"