implemented %__find_{requires,provides}_filter and %filter_from_{requires,provides}

The first two macros provide general mechanism for find-requires
and find-provides filtering.  Any valid command or shell syntax can
be used - the command will be executed using "eval" within find-*
script.  The implementation in %___build_pre is not particular
beautiful (as it uses here-docs), but there seems to be no easy
way to quote for eval yet.

The second two commands are built on top of the first: they use
sed as a filtering tool.  The implementation is compatible with Fedora:
http://fedoraproject.org/wiki/Packaging:AutoProvidesAndRequiresFiltering
This commit is contained in:
Alexey Tourbin 2011-01-22 23:35:34 +03:00
parent 7247ecbda7
commit 82f7aeb283
3 changed files with 32 additions and 2 deletions

View File

@ -116,4 +116,15 @@ RunMethod()
Info "running scripts ($methods)"
RunMethods prov "$methods" RunMethod
[ -z "$found" ] || (set +f; LC_COLLATE=C sort -u -m "$workdir"/*.deps) || exit 1
if [ -n "$found" ]; then
(set +f && LC_ALL=C sort -u -m "$workdir"/*.deps) >"$workdir"/find-provides-deps || false
if [ -n "${RPM_FIND_PROVIDES_FILTER-}" ]; then
(eval "set -x; $RPM_FIND_PROVIDES_FILTER") <"$workdir"/find-provides-deps >"$workdir"/filter-provides-deps
[ $? = 0 ] || Fatal "filter failed"
(cd "$workdir" && diff -U1 find-provides-deps filter-provides-deps) >&2 ||:
cat "$workdir"/filter-provides-deps
else
cat "$workdir"/find-provides-deps
fi
fi

View File

@ -109,7 +109,18 @@ export RPM_FINDPACKAGE_COMMANDS_LOG="$RPM_BUILD_ROOT"/.findpackage-commands
Info "running scripts ($methods)"
RunMethods req "$methods" RunMethod
[ -z "$found" ] || (set +f; LC_COLLATE=C sort -u -m "$workdir"/*.deps) || exit 1
if [ -n "$found" ]; then
(set +f && LC_ALL=C sort -u -m "$workdir"/*.deps) >"$workdir"/find-requires-deps || false
if [ -n "${RPM_FIND_REQUIRES_FILTER-}" ]; then
(eval "set -x; $RPM_FIND_REQUIRES_FILTER") <"$workdir"/find-requires-deps >"$workdir"/filter-requires-deps
[ $? = 0 ] || Fatal "filter failed"
(cd "$workdir" && diff -U1 find-requires-deps filter-requires-deps) >&2 ||:
cat "$workdir"/filter-requires-deps
else
cat "$workdir"/find-requires-deps
fi
fi
if [ -s "$RPM_FINDPACKAGE_COMMANDS_LOG" ]; then
LC_ALL=C sort -u -o "$RPM_FINDPACKAGE_COMMANDS_LOG"{,}

View File

@ -227,6 +227,12 @@
@alt@ %{?_scripts_debug:export RPM_SCRIPTS_DEBUG=\"%_scripts_debug\"}\
@alt@ %{?_keep_libtool_files:export RPM_KEEP_LIBTOOL_FILES=\"%_keep_libtool_files\"}\
@alt@ \
@alt@ %{?__find_requires_filter:export RPM_FIND_REQUIRES_FILTER=$(cat <<'!FIND!REQUIRES!FILTER!'\
@alt@%__find_requires_filter\
@alt@!FIND!REQUIRES!FILTER!)}\
@alt@ %{?__find_provides_filter:export RPM_FIND_PROVIDES_FILTER=$(cat <<'!FIND!PROVIDES!FILTER!'\
@alt@%__find_provides_filter\
@alt@!FIND!PROVIDES!FILTER!)}\
@alt@ unset LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL ||:\
@alt@ %{?_build_lang:export LANG=\"%_build_lang\"\
@alt@ export LANGUAGE=\"%_build_lang\"\
@ -492,6 +498,8 @@
@alt@%add_findreq_skiplist() %global _findreq_skiplist %_findreq_skiplist %*
@alt@%add_findprov_skiplist() %global _findprov_skiplist %_findprov_skiplist %*
@alt@
@alt@%filter_from_requires() %global __find_requires_filter %{?!__find_requires_filter:%__sed}%{?__find_requires_filter} -e '%*'
@alt@%filter_from_provides() %global __find_provides_filter %{?!__find_provides_filter:%__sed}%{?__find_provides_filter} -e '%*'
@alt@
@alt@%add_findpackage_path() %global _findpackage_path %_findpackage_path %*
@alt@%add_findprov_lib_path() %global _findprov_lib_path %_findprov_lib_path %*