From ebf873317582043c3a83e66a7b58b78bd79d0088 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 10 Dec 2010 16:18:15 +0200 Subject: [PATCH] Implement filtering of autogenerated dependencies - This allows both excluding entire paths from dependency generation and also excluding individual generated dependencies by regexes settable from spec or other configuration. - %__(provides|requires)_exclude regex controls is matched against generated dependencies, %__(provides|requires)_exclude_from is matched against the currently processed path, with buildroot stripped out. - We'll probably want some "higher level" macros to go with this, but the mechanism is usable as-is already. (cherry picked from commit 185de185262b2772fa692efc69633f41afc5832a) --- build/rpmfc.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/build/rpmfc.c b/build/rpmfc.c index 2efe0eb..56bcb12 100644 --- a/build/rpmfc.c +++ b/build/rpmfc.c @@ -455,6 +455,8 @@ static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char * nsdep) rpmsenseFlags dsContext; rpmTagVal tagN; int pac; + regex_t *exclude = NULL; + regex_t *exclude_from = NULL; switch (deptype) { default: @@ -478,9 +480,17 @@ static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char * nsdep) break; } + /* If the entire path is filtered out, there's nothing more to do */ + exclude_from = rpmfcAttrReg(depname, "exclude_from"); + if (regMatch(exclude_from, fn+fc->brlen)) + goto exit; + pav = runCmd(nsdep, depname, fc->buildRoot, fn); pac = argvCount(pav); + if (pav) + exclude = rpmfcAttrReg(depname, "exclude"); + for (int i = 0; i < pac; i++) { rpmds ds = NULL; const char *N = pav[i]; @@ -509,17 +519,20 @@ static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char * nsdep) ds = rpmdsSingle(tagN, N, EVR, Flags); - /* Add to package dependencies. */ - (void) rpmdsMerge(depsp, ds); - - /* Add to file dependencies. */ - rpmfcAddFileDep(&fc->ddict, fc->ix, ds, deptype); + /* Add to package and file dependencies unless filtered */ + if (regMatch(exclude, rpmdsDNEVR(ds)+2) == 0) { + (void) rpmdsMerge(depsp, ds); + rpmfcAddFileDep(&fc->ddict, fc->ix, ds, deptype); + } ds = rpmdsFree(ds); } argvFree(pav); +exit: + regFree(exclude); + regFree(exclude_from); return 0; } -- 2.7.4