common: add a setcurrent helper
This commit is contained in:
parent
7b6ec4668c
commit
353f8b9faf
13
common.lua
13
common.lua
@ -45,6 +45,18 @@ local function zalias(rpmvars,verbose)
|
||||
end
|
||||
end
|
||||
|
||||
-- Takes a list of rpm variable roots and a suffix and alias current<root> to
|
||||
-- <root><suffix> if it resolves to something not empty
|
||||
local function setcurrent(rpmvars, suffix, verbose)
|
||||
for _, rpmvar in ipairs(rpmvars) do
|
||||
if (rpm.expand("%{?" .. rpmvar .. suffix .. "}") ~= "") then
|
||||
explicitset( "current" .. rpmvar, "%{" .. rpmvar .. suffix .. "}", verbose)
|
||||
else
|
||||
explicitunset("current" .. rpmvar, verbose)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Echo the list of rpm variables, with suffix, if set
|
||||
local function echovars(rpmvars, suffix)
|
||||
for _, rpmvar in ipairs(rpmvars) do
|
||||
@ -106,6 +118,7 @@ return {
|
||||
explicitunset = explicitunset,
|
||||
safeset = safeset,
|
||||
zalias = zalias,
|
||||
setcurrent = setcurrent,
|
||||
echovars = echovars,
|
||||
getsuffixed = getsuffixed,
|
||||
getsuffixes = getsuffixes,
|
||||
|
@ -66,7 +66,7 @@ end
|
||||
-- The forgemeta macro main processing function
|
||||
-- See the documentation in the macros.forge file for argument description
|
||||
-- Also called directly by gometa
|
||||
local function forgemeta(suffix, verbose, informative, silent)
|
||||
local function meta(suffix, verbose, informative, silent)
|
||||
local fedora = require "fedora.common"
|
||||
local ismain = (suffix == "") or (suffix == "0")
|
||||
if ismain then
|
||||
@ -250,6 +250,6 @@ local function forgemeta(suffix, verbose, informative, silent)
|
||||
end
|
||||
|
||||
return {
|
||||
forgemeta = forgemeta,
|
||||
meta = meta,
|
||||
}
|
||||
|
||||
|
@ -53,10 +53,10 @@ local silent = rpm.expand("%{-s}") ~= ""
|
||||
local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "")
|
||||
if processall then
|
||||
for _,s in pairs(fedora.getsuffixes("forgeurl")) do
|
||||
forge.forgemeta(s,verbose,informative,silent)
|
||||
forge.meta(s,verbose,informative,silent)
|
||||
end
|
||||
else
|
||||
forge.forgemeta(rpm.expand("%{-z*}"),verbose,informative,silent)
|
||||
forge.meta(rpm.expand("%{-z*}"),verbose,informative,silent)
|
||||
end
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user