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
|
# Some miscellaneous Fedora-related macros
|
||||||
|
|
||||||
# List files matching inclusion globs, excluding files matching exclusion blogs
|
# List files matching inclusion globs, excluding files matching exclusion blogs
|
||||||
# Parameters:
|
# Optional parameters:
|
||||||
# -i "<globs>" include shell globs (also takes all other macro arguments)
|
# – -i "<globs>" inclusion globs
|
||||||
# -x "<globs>" exclude shell 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:
|
%listfiles(i:x:) %{expand:
|
||||||
while IFS= read -r -d $'\\n' finc ; do
|
while IFS= read -r finc ; do
|
||||||
printf "%s\\n" %{?-x*} \\
|
realpath -qe --relative-base=. "" %{?-x*} %{?listfiles_exclude} \\
|
||||||
| xargs -i realpath --relative-base=. '{}' \\
|
| sort -u | grep -q "${finc}" || echo "${finc}"
|
||||||
| grep "${finc}" >/dev/null || echo "${finc}"
|
done <<< $(realpath -e --relative-base=. %{?-i*} %{?listfiles_include} %* | sort -u)
|
||||||
done <<< $(printf "%s\\n" %{?-i*} %* | xargs -i realpath --relative-base=. '{}' | sort -u)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# https://github.com/rpm-software-management/rpm/issues/581
|
# https://github.com/rpm-software-management/rpm/issues/581
|
||||||
|
Loading…
Reference in New Issue
Block a user