#rpm-macros-branch macros

# Release: %branch_release <prefix><number>[.<suffix>]
%branch_release() %(if [ "%{?branch_switch}" = "" ]; then echo "%1"; else echo "%1"|sed -rn -e 's@^([^[:space:]]+[^0-9])([0-9]+)(|(\\.[^[:space:]]+))$@\\1/\\2/\\3@p'|awk -v FS='/' -v branch_name='%{?branch_switch}' -v branch_release_num='%{?branch_release_num}' 'BEGIN {if (branch_release_num == "") {num="1"} else {num=branch_release_num}; suf=("." branch_name "." num) }; {print $1 ($2-1) suf $3}'; fi)
