diff --git a/macros.fedora-misc b/macros.fedora-misc index ca54197..f91f55c 100644 --- a/macros.fedora-misc +++ b/macros.fedora-misc @@ -1,15 +1,21 @@ # Some miscellaneous Fedora-related macros # List files matching inclusion globs, excluding files matching exclusion blogs -# Parameters: -# -i "" include shell globs (also takes all other macro arguments) -# -x "" exclude shell globs +# Optional parameters: +# – -i "" inclusion globs +# – -x "" exclusion globs +# Globs are space-separated lists of shell globs. Such lists require %{quote:} +# use for safe rpm argument passing. +# Alternatively, set the following rpm variables before calling the macro: +# – “listfiles_include” inclusion globs +# — “listfiles_exclude” exclusion globs +# Arguments passed to the macro without flags will be interpreted as inclusion +# globs. %listfiles(i:x:) %{expand: -while IFS= read -r -d $'\\n' finc ; do - printf "%s\\n" %{?-x*} \\ - | xargs -i realpath --relative-base=. '{}' \\ - | grep "${finc}" >/dev/null || echo "${finc}" -done <<< $(printf "%s\\n" %{?-i*} %* | xargs -i realpath --relative-base=. '{}' | sort -u) +while IFS= read -r finc ; do + realpath -qe --relative-base=. "" %{?-x*} %{?listfiles_exclude} \\ + | sort -u | grep -q "${finc}" || echo "${finc}" +done <<< $(realpath -e --relative-base=. %{?-i*} %{?listfiles_include} %* | sort -u) } # https://github.com/rpm-software-management/rpm/issues/581