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