From ae7f795c6886cb553720d04312c4570044ef702a Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Apr 04 2019 14:56:01 +0000 Subject: AutoDepFiltering: basic review, added TOC, formatting fixes --- diff --git a/guidelines/modules/ROOT/pages/AutoProvidesAndRequiresFiltering.adoc b/guidelines/modules/ROOT/pages/AutoProvidesAndRequiresFiltering.adoc index be80678..e7f9409 100644 --- a/guidelines/modules/ROOT/pages/AutoProvidesAndRequiresFiltering.adoc +++ b/guidelines/modules/ROOT/pages/AutoProvidesAndRequiresFiltering.adoc @@ -1,3 +1,8 @@ += Automatic Filtering of Provides and Requires + +:last-reviewed: 2019-04-04 +:toc: + == 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}+`). @@ -16,11 +21,11 @@ This Guideline describes how to filter provides and requires on Fedora. === 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. +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 follow the POSIX.2 regular expression standard (see man regex(7) ). 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. +These filters use regular expressions. The regular expression variant used for these filters follow the `POSIX.2` regular expression standard (see man regex(7) ). 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: @@ -45,7 +50,7 @@ The macros `+%__requires_exclude_from+` and `+%__provides_exclude_from+` can be Note that this macro replaces the `+%filter_provides_in+` macro from the old filtering guidelines but it does not do the same thing. In particular: * The old macro could be invoked multiple times. This one will only use the regex defined last. -* The old macro advised against anchoring the beginning of the regex (Using "^"). This macro recommends anchoring as it doesn't suffer from the compatibility problems of the old one. +* The old macro advised against anchoring the beginning of the regex (Using `+^+`). This macro recommends anchoring as it doesn't suffer from the compatibility problems of the old one. * With the old macro it was common to specify a directory name to match everything in a directory recursively. With the new macro you may need to specify `+.*+` because you should be anchoring your regular expressions. === Filtering provides and requires after scanning @@ -115,7 +120,7 @@ foo = 1.0-1.fc19 foo(x86-64) = 1.0-1.fc19 .... -* See that "`+libprivate.so()(64bit)+`" appears to be the only symbol that rpm extracted for this package. Note that on 32 bit, the provides will be `+libprivate.so+` so your regex needs to capture both. +* See that `+libprivate.so()(64bit)+` appears to be the only symbol that rpm extracted for this package. Note that on 32bit, the provides will be `+libprivate.so+` so your regex needs to capture both. + * Add the excludes to the spec file for both requires and provides: @@ -131,16 +136,16 @@ You can take a look at a http://lists.fedoraproject.org/pipermail/devel/2012-Jun === Arch-specific extensions to scripting languages -e.g. to ensure an arch-specific perl-* package won't provide or require things that it shouldn't, we could use an invocation as such: +e.g. to ensure an arch-specific `perl-*` package won't provide or require things that it shouldn't, we could use an invocation as such: .... # we don't want to provide private Perl extension libs %{?perl_default_filter} .... -=== %_docdir filtering +=== `+%{_docdir}+` filtering -By policy, nothing under `+%_docdir+` is allowed to either "provide" or "require" anything. We can prevent this from happening by preventing anything under `+%_docdir+` from being scanned: +By policy, nothing under `+%{_docdir}+` is allowed to either "provide" or "require" anything. We can prevent this from happening by preventing anything under `+%{_docdir}+` from being scanned: .... # we don't want to either provide or require anything from _docdir, per policy