Blame SOURCES/macros.fedora-misc

f9efe2
# Fedora macros, safe to use after the SRPM build stage
f9efe2
f9efe2
# Lists files matching inclusion globs, excluding files matching exclusion
f9efe2
# globs
f9efe2
#   – globs are space-separated lists of shell globs. Such lists require
f9efe2
#     %{quote:} use when passed as rpm arguments or flags.
f9efe2
# Control variables, flags and arguments:
f9efe2
#   %{listfiles_include}  inclusion globs
f9efe2
#   %{listfiles_exclude}  exclusion globs
f9efe2
#   -i <globs>            inclusion globs
f9efe2
#   -x <globs>            exclusion globs
f9efe2
#   …                     arguments passed to the macro without flags will be
f9efe2
#                         interpreted as inclusion globs
f9efe2
%listfiles(i:x:) %{expand:
f9efe2
%if %{lua: print(string.len(rpm.expand("%{?-i*}%{?listfiles_include}%*")))}
f9efe2
  listfiles_include=$(realpath -e --relative-base=. %{?-i*} %{?listfiles_include} %* | sort -u)
f9efe2
  %if  %{lua: print(string.len(rpm.expand("%{?-x*}%{?listfiles_exclude}")))}
f9efe2
    while IFS= read -r finc ; do
f9efe2
      realpath -qe --relative-base=. %{?-x*} %{?listfiles_exclude} \\
f9efe2
        | sort -u | grep -q "${finc}" || echo "${finc}"
f9efe2
    done <<< "${listfiles_include}"
f9efe2
  %else
f9efe2
    echo "${listfiles_include}"
f9efe2
  %endif
f9efe2
%endif
f9efe2
}
f9efe2
f9efe2
# https://github.com/rpm-software-management/rpm/issues/581
f9efe2
# Writes the contents of a list of rpm variables to a macro file
f9efe2
# Control variables, flags and arguments:
f9efe2
#   -f <filename>  the macro file to process:
f9efe2
#                    – it must contain corresponding anchors
f9efe2
#                    – for example %writevars -f myfile foo bar will replace:
f9efe2
#                        @@FOO@@ with the rpm evaluation of %{foo} and
f9efe2
#                        @@BAR@@ with the rpm evaluation of %{bar}
f9efe2
#                      in myfile
f9efe2
%writevars(f:) %{lua:
f9efe2
local    fedora = require "fedora.common"
f9efe2
local macrofile = rpm.expand("%{-f*}")
f9efe2
local   rpmvars = {}
f9efe2
for i = 1, rpm.expand("%#") do
f9efe2
  table.insert(rpmvars, rpm.expand("%" .. i))
f9efe2
end
f9efe2
fedora.writevars(macrofile,rpmvars)
f9efe2
}
f9efe2
f9efe2
# gpgverify verifies signed sources. There is documentation in the script.
f9efe2
%gpgverify(k:s:d:) %{lua:
f9efe2
local script = rpm.expand("%{_rpmconfigdir}/redhat/gpgverify ")
f9efe2
local keyring = rpm.expand("%{-k*}")
f9efe2
local signature = rpm.expand("%{-s*}")
f9efe2
local data = rpm.expand("%{-d*}")
f9efe2
print(script)
f9efe2
if keyring ~= "" then
f9efe2
  print(rpm.expand("--keyring='%{SOURCE" .. keyring ..  "}' "))
f9efe2
end
f9efe2
if signature ~= "" then
f9efe2
  print(rpm.expand("--signature='%{SOURCE" .. signature ..  "}' "))
f9efe2
end
f9efe2
if data ~= "" then
f9efe2
  print(rpm.expand("--data='%{SOURCE" .. data ..  "}' "))
f9efe2
end
f9efe2
}