ebd01c
# Some miscellaneous Fedora-related macros
ebd01c
ebd01c
# List files matching inclusion globs, excluding files matching exclusion blogs
ebd01c
# Optional parameters:
ebd01c
#  – -i "<globs>" inclusion globs
ebd01c
#  – -x "<globs>" exclusion globs
ebd01c
# Globs are space-separated lists of shell globs. Such lists require %{quote:}
ebd01c
# use for safe rpm argument passing.
ebd01c
# Alternatively, set the following rpm variables before calling the macro:
ebd01c
#  – “listfiles_include” inclusion globs
ebd01c
#  — “listfiles_exclude” exclusion globs
ebd01c
# Arguments passed to the macro without flags will be interpreted as inclusion
ebd01c
# globs.
ebd01c
%listfiles(i:x:) %{expand:
ebd01c
%if %{lua: print(string.len(rpm.expand("%{?-i*}%{?listfiles_include}%*")))}
ebd01c
  listfiles_include=$(realpath -e --relative-base=. %{?-i*} %{?listfiles_include} %* | sort -u)
ebd01c
  %if  %{lua: print(string.len(rpm.expand("%{?-x*}%{?listfiles_exclude}")))}
ebd01c
    while IFS= read -r finc ; do
ebd01c
      realpath -qe --relative-base=. %{?-x*} %{?listfiles_exclude} \\
ebd01c
        | sort -u | grep -q "${finc}" || echo "${finc}"
ebd01c
    done <<< "${listfiles_include}"
ebd01c
  %else
ebd01c
    echo "${listfiles_include}"
ebd01c
  %endif
ebd01c
%endif
ebd01c
}
ebd01c
ebd01c
# https://github.com/rpm-software-management/rpm/issues/581
ebd01c
# Write the contents of a list of rpm variables to a macro file.
ebd01c
# The target file must contain the corresponding anchors.
ebd01c
# For example %writevars -f myfile foo bar will replace:
ebd01c
#  @@FOO@@ with the rpm evaluation of %{foo} and
ebd01c
#  @@BAR@@ with the rpm evaluation of %{bar}
ebd01c
# in myfile
ebd01c
%writevars(f:) %{lua:
ebd01c
local    fedora = require "fedora.common"
ebd01c
local macrofile = rpm.expand("%{-f*}")
ebd01c
local   rpmvars = {}
ebd01c
for i = 1, rpm.expand("%#") do
ebd01c
  table.insert(rpmvars, rpm.expand("%" .. i))
ebd01c
end
ebd01c
fedora.writevars(macrofile,rpmvars)
ebd01c
}
ebd01c
ebd01c
# gpgverify verifies signed sources. There is documentation in the script.
ebd01c
%gpgverify(k:s:d:) %{lua:
ebd01c
local script = rpm.expand("%{_rpmconfigdir}/redhat/gpgverify ")
ebd01c
local keyring = rpm.expand("%{-k*}")
ebd01c
local signature = rpm.expand("%{-s*}")
ebd01c
local data = rpm.expand("%{-d*}")
ebd01c
print(script)
ebd01c
if keyring ~= "" then
ebd01c
  print(rpm.expand("--keyring='%{SOURCE" .. keyring ..  "}' "))
ebd01c
end
ebd01c
if signature ~= "" then
ebd01c
  print(rpm.expand("--signature='%{SOURCE" .. signature ..  "}' "))
ebd01c
end
ebd01c
if data ~= "" then
ebd01c
  print(rpm.expand("--data='%{SOURCE" .. data ..  "}' "))
ebd01c
end
ebd01c
}
ebd01c
ebd01c
# gpgverify verifies signed sources. There is documentation in the script.
ebd01c
%gpgverify(k:s:d:) %{lua:
ebd01c
local script = rpm.expand("%{_rpmconfigdir}/redhat/gpgverify ")
ebd01c
local keyring = rpm.expand("%{-k*}")
ebd01c
local signature = rpm.expand("%{-s*}")
ebd01c
local data = rpm.expand("%{-d*}")
ebd01c
print(script)
ebd01c
if keyring ~= "" then
ebd01c
  print(rpm.expand("--keyring='%{SOURCE" .. keyring ..  "}' "))
ebd01c
end
ebd01c
if signature ~= "" then
ebd01c
  print(rpm.expand("--signature='%{SOURCE" .. signature ..  "}' "))
ebd01c
end
ebd01c
if data ~= "" then
ebd01c
  print(rpm.expand("--data='%{SOURCE" .. data ..  "}' "))
ebd01c
end
ebd01c
}