misc: listfiles: improve argument passing, simplify it and make it more robust
This commit is contained in:
parent
61ec2ef5ba
commit
c6773c14ed
@ -1,15 +1,21 @@
|
||||
# Some miscellaneous Fedora-related macros
|
||||
|
||||
# List files matching inclusion globs, excluding files matching exclusion blogs
|
||||
# Parameters:
|
||||
# -i "<globs>" include shell globs (also takes all other macro arguments)
|
||||
# -x "<globs>" exclude shell globs
|
||||
# Optional parameters:
|
||||
# – -i "<globs>" inclusion globs
|
||||
# – -x "<globs>" 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
|
||||
|
Loading…
Reference in New Issue
Block a user