5335ee5
# Some miscellaneous Fedora-related macros
5335ee5
5335ee5
# List files matching inclusion globs, excluding files matching exclusion blogs
c6773c1
# Optional parameters:
c6773c1
#  – -i "<globs>" inclusion globs
c6773c1
#  – -x "<globs>" exclusion globs
c6773c1
# Globs are space-separated lists of shell globs. Such lists require %{quote:}
c6773c1
# use for safe rpm argument passing.
c6773c1
# Alternatively, set the following rpm variables before calling the macro:
c6773c1
#  – “listfiles_include” inclusion globs
c6773c1
#  — “listfiles_exclude” exclusion globs
c6773c1
# Arguments passed to the macro without flags will be interpreted as inclusion
c6773c1
# globs.
5335ee5
%listfiles(i:x:) %{expand:
9deb068
%if "%{?-i*}%{expand:%{?listfiles_include}}%*" != ""
02f4a20
  listfiles_include=$(realpath -e --relative-base=. %{?-i*} %{?listfiles_include} %* | sort -u)
9deb068
  %if "%{?-x*}%{expand:%{?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
5335ee5
# Write the contents of a list of rpm variables to a macro file.
5335ee5
# The target file must contain the corresponding anchors.
5335ee5
# For example %writevars -f myfile foo bar will replace:
5335ee5
#  @@FOO@@ with the rpm evaluation of %{foo} and
5335ee5
#  @@BAR@@ with the rpm evaluation of %{bar}
5335ee5
# 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.
Björn Persson 3da0ad5
%gpgverify %{_rpmconfigdir}/redhat/gpgverify