## START: Automatic release macro
%define autorel(e:s:hp) %{lua:
  has_extraver = rpm.expand("%{-e}") ~= ""
  has_snapinfo = rpm.expand("%{-s}") ~= ""
  is_prerelease = rpm.expand("%{-p}") ~= ""
  is_hotfix = rpm.expand("%{-h}") ~= ""

  if has_extraver
  then
    rpm.define("_autorel_extraver .%{-e*}")
  else
    rpm.define("_autorel_extraver %{nil}")
  end

  if has_snapinfo
  then
    rpm.define("_autorel_snapinfo .%{-s*}")
  else
    rpm.define("_autorel_snapinfo %{nil}")
  end

  if is_prerelease
  then
    if is_hotfix
    then
      option = "prerel_hotfix_cadence"
    else
      option = "prerel_cadence"
    end
  else
    if is_hotfix
    then
      option = "hotfix_cadence"
    else
      option = "normal_cadence"
    end
  end

  print(rpm.expand("%_autorel_" .. option))
}
## END: Automatic release macro
