English
Automatic Filtering of Provides and Requires
Summary
The auto requires and provides system contained in RPM is quite useful; however, it sometimes picks up "private" package capabilities that shouldn't be advertised as global, things that are "just wrong", or things prohibited by policy (e.g. deps from inside `+%{_docdir}+`).
For example:
Various "plugin" packages (e.g. Pidgin, Perl, Apache, KDE) are marked as "providing" private shared libraries outside the system path.
Files in `+%{_docdir}+` are routinely scanned, and can trigger prov/req when this is explicitly forbidden by policy.
This Guideline describes how to filter provides and requires on Fedora.
*MUST:* Packages must not provide RPM dependency information
when that information is not global in nature,
or are otherwise handled (e.g. through a virtual provides system).
e.g. a plugin package containing a binary shared library
must not "provide" that library
unless it is accessible through the system library paths.
*MUST:* When filtering automatically generated RPM dependency information,
the filtering system implemented by Fedora must be used,
except where there is a compelling reason to deviate from it.
Usage
Location of macro invocation
It's strongly recommended that these filtering macros be invoked before `+%description+`, but after any other definitions. This will keep them in a consistent place across packages, and help prevent them from being mixed up with other sections.
Regular Expression Variant
These filters use regular expressions. The regular expression variant used for these filters follows the `POSIX.2` regular expression standard (see the `+regex(7)` manpage). In this variant, the literal characters `+^.[$()|*+?{+` need to be backslash escaped. Because rpm interprets backslashes as part of its parsing of spec files, you will need to use a *double backslash* for any escapes. A literal backslash ("`+\+`") is represented by four backslashes.
The regex engine is only passed the final string, after RPM macro expansion. So you can't use unescaped data via RPM macros. For instance, if you generate a list of files to match in a macro and that list contains `+libfoo.so+` you'll have to use `+libfoo\\.so+` to escape the ("`+.+`"). Example:
%global to_exclude libfoo\\.so
%global __requires_exclude_from ^%{_datadir}/%{to_exclude}$
Preventing files/directories from being scanned for deps (pre-scan filtering)
The macros `+%__requires_exclude_from+` and `+%__provides_exclude_from+` can be defined in a spec file to keep the dependency generator from scanning specific files or directories for deps. These macros should be defined with a regular expression that matches all of the directories or files. For instance:
# Do not check any files in docdir for requires
%global __requires_exclude_from ^%{_docdir}/.*$
# Do not check .so files in an application-specific library directory
# or any files in the application's data directory for provides
%global __provides_exclude_from ^(%{_libdir}/%{name}/.*\\.so.*|%{_datadir}/myapp/.*)$