f9efe2
# Computes forge-related variables for use in the rest of the spec file
f9efe2
# Control variables, flags and arguments:
f9efe2
#   %{forgeurl<number>}  the project url on the target forge
f9efe2
#   %{tag<number>}       the packaged tag, OR
f9efe2
#   %{commit<number>}    the packaged commit, OR
f9efe2
#   %{version<number>}   the packaged version
f9efe2
#                          – %{version}/%{version0} are set via:
f9efe2
#                              Version:
f9efe2
#                          – because git is lacking a built-in version
f9efe2
#                            reference, %{version<number>} will be translated
f9efe2
#                            into %{tag<number>} using unreliable heuristics;
f9efe2
#                            set %{tag<number>} directly if those fail
f9efe2
#   %{date<number>}      the packaged timestamp
f9efe2
#   …                    %forgemeta will compute a huge number of variables:
f9efe2
#                          — the packager can override it by setting some of
f9efe2
#                            those before the %forgemeta call
f9efe2
#                          – use the -i flag to list those variables
f9efe2
#   -z <number>          only process the zth block of definitions
f9efe2
#                        "" for the no-suffix block
f9efe2
#   -i                   list the resulting variable values
f9efe2
#   -s                   silently ignore problems in %{forgeurl<number>}
f9efe2
#   -v                   be verbose
f9efe2
#   -a                   process all sources in one go, instead of using
f9efe2
#                        separate -z calls
f9efe2
%forgemeta(z:isva) %{lua:
f9efe2
local      fedora = require "fedora.common"
f9efe2
local       forge = require "fedora.srpm.forge"
f9efe2
local     verbose =  rpm.expand("%{-v}") ~= ""
f9efe2
local informative =  rpm.expand("%{-i}") ~= ""
f9efe2
local      silent =  rpm.expand("%{-s}") ~= ""
f9efe2
local  processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "")
f9efe2
if processall then
f9efe2
  for _,s in pairs(fedora.getsuffixes("forgeurl")) do
f9efe2
    forge.meta(s,verbose,informative,silent)
f9efe2
  end
f9efe2
else
f9efe2
  forge.meta(rpm.expand("%{-z*}"),verbose,informative,silent)
f9efe2
end
f9efe2
}
f9efe2
f9efe2
# Unpacks sources computed by %forgemeta
f9efe2
# Control variables, flags and arguments:
f9efe2
#   %{forgesource<number>}       the source archive that will be processed
f9efe2
#   %{forgesetupargs<number>}    %setup arguments
f9efe2
f9efe2
#   -z <number>                  only process the zth block of definitions
f9efe2
#                                "" for the no-suffix block
f9efe2
#   -v                           be verbose
f9efe2
#   -a                   process all sources in one go, instead of using
f9efe2
#                        separate -z calls
f9efe2
%forgesetup(z:va) %{lua:
f9efe2
local fedora = require "fedora.common"
f9efe2
if (rpm.expand("%{-z}") == "") and (rpm.expand("%{-a}") ~= "") then
f9efe2
  for _,s in pairs(fedora.getsuffixes("forgesetupargs")) do
f9efe2
    print(rpm.expand("%setup %{!-v:-q} %{?forgesetupargs" .. s                     .. "}\\n"))
f9efe2
  end
f9efe2
else
f9efe2
  print(  rpm.expand("%setup %{!-v:-q} %{?forgesetupargs" .. rpm.expand("%{-z*}") .. "}\\n"))
f9efe2
end
f9efe2
}
f9efe2
f9efe2
# Calls %autosetup using %forgemeta results
f9efe2
#   – this will probably be removed since it is unsafe in presence of multiple
f9efe2
#     sources
f9efe2
# Control variables, flags and arguments:
f9efe2
#   -z <number>  process the zth block of definitions
f9efe2
#   -v -N -S -p  relayed to %autosetup
f9efe2
%forgeautosetup(z:vNS:p:q) %{lua:
f9efe2
print(rpm.expand("%autosetup %{-v} %{-N} %{?-S} %{?-p} %{?forgesetupargs" .. rpm.expand("%{-z*}") .. "}\\n"))
f9efe2
}