10:229 "ˆl–Ü4ý()¨‰P@Š7åÀ…LZ7ÿ¿ ƒh¹ÂÁ10:242  �ÃÂÁ File not found.  �ÃÂÁ File not found.  �ÃÂÁ File not found. �ÃÂÁFile not found. "ˆl–äY>” ªn-jm@;p-Üi•1hßÀ ƒ}ÑÃÂ%ù-- Convenience Lua functions that can be used within rpm macros -- Reads an rpm variable. Unlike a basic rpm.expand("{?foo}"), returns nil if -- the variable is unset, which is convenient in lua tests and enables -- differentiating unset variables from variables set to "" local function read(rpmvar) if not rpmvar or (rpm.expand("%{" .. rpmvar .. "}") == "%{" .. rpmvar .. "}") then return nil else return rpm.expand("%{?" .. rpmvar .. "}") end end -- Returns true if the macro that called this function had flag set -- – for example, hasflag("z") would give the following results: -- %foo -z bar → true -- %foo -z → true -- %foo → false local function hasflag(flag) return (rpm.expand("%{-" .. flag .. "}") ~= "") end -- Returns the argument passed to flag in the macro that called this function -- – for example, readflag("z") would give the following results: -- %foo -z bar → bar -- %foo → nil -- %foo -z "" → empty string -- %foo -z '' → empty string local function readflag(flag) if not hasflag(flag) then return nil else local a = rpm.expand("%{-" .. flag .. "*}") -- Handle "" and '' as empty strings if (a == '""') or (a == "''") then a = '' end return a end end -- Sets a spec variable; echoes the result if verbose local function explicitset(rpmvar, value, verbose) local value = value if (value == nil) or (value == "") then value = "%{nil}" end rpm.define(rpmvar .. " " .. value) if verbose then rpm.expand("%{warn:Setting %%{" .. rpmvar .. "} = " .. value .. "}") end end -- Unsets a spec variable if it is defined; echoes the result if verbose local function explicitunset(rpmvar, verbose) if (rpm.expand("%{" .. rpmvar .. "}") ~= "%{" .. rpmvar .. "}") then rpm.define(rpmvar .. " %{nil}") if verbose then rpm.expand("%{warn:Unsetting %%{" .. rpmvar .. "}}") end end end -- Sets a spec variable, if not already set; echoes the result if verbose local function safeset(rpmvar, value, verbose) if (rpm.expand("%{" .. rpmvar .. "}") == "%{" .. rpmvar .. "}") then explicitset(rpmvar,value,verbose) end end -- Aliases a list of rpm variables to the same variables suffixed with 0 (and -- vice versa); echoes the result if verbose local function zalias(rpmvars, verbose) for _, sfx in ipairs({{"","0"},{"0",""}}) do for _, rpmvar in ipairs(rpmvars) do local toalias = "%{?" .. rpmvar .. sfx[1] .. "}" if (rpm.expand(toalias) ~= "") then safeset(rpmvar .. sfx[2], toalias, verbose) end end end end -- Takes a list of rpm variable roots and a suffix and alias current to -- 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 rpmvar = rpmvar .. suffix local header = string.sub(" " .. rpmvar .. ": ",1,21) rpm.expand("%{?" .. rpmvar .. ":%{echo:" .. header .. "%{?" .. rpmvar .. "}}}") end end -- Returns an array, indexed by suffix, containing the non-empy values of -- , with suffix an integer string or the empty string local function getsuffixed(rpmvar) local suffixes = {} zalias({rpmvar}) for suffix=0,9999 do local value = rpm.expand("%{?" .. rpmvar .. suffix .. "}") if (value ~= "") then suff