#
#
# This macro looks for a dist tag in the exact commit you
# checked out by cutting it into bits segmented by '.'
# and matching known values.
# If nothing is found it will fall back to a default
#
#
# The actual work is done inside of this function
# set the "DEFAULT" and save it
# look through our known suffix lists
#########
# suffix list:
# ae - Ansible Engine
# cf - Cloud Forms
# dsrv - Directory Server
# ev - Enterprise Virtulization
# op - Open Shift
# ost - Open Stack
# rhs - Storage Server
# rt - Real Time (MRG)
# sat - Satellite Server
#########
%__get_tag_from_git_repo %{expand:%%(DEFAULT="el%{rhel}.centos" \
result=${DEFAULT} \
for element in $( git describe --tags --exact-match 2>/dev/null | tr '.' ' ' ); do \
if [[ "$element" == "el%{rhel}" ]]; then \
result=$element \
elif [[ "$element" == "el%{rhel}ae" ]]; then \
result=$element \
elif [[ "$element" == "el%{rhel}cf" ]]; then \
result=$element \
elif [[ "$element" == "el%{rhel}dsrv" ]]; then \
result=$element \
elif [[ "$element" == "el%{rhel}ev" ]]; then \
result=$element \
elif [[ "$element" == "el%{rhel}op" ]]; then \
result=$element \
elif [[ "$element" == "el%{rhel}ost" ]]; then \
result=$element \
elif [[ "$element" == "el%{rhel}rhs" ]]; then \
result=$element \
elif [[ "$element" == "el%{rhel}rt" ]]; then \
result=$element \
elif [[ "$element" == "el%{rhel}sat" ]]; then \
result=$element \
else \
for minor in $(seq 0 11); do \
if [[ "$element" == "el%{rhel}_${minor}" ]]; then \
result=$element \
fi \
done \
fi \
done \
echo "### 'git based' dist-tag set to '.${result}' (default:.${DEFAULT})" >&2 \
echo .$result )}
%dist %__get_tag_from_git_repo