This patch adds support for a new fileattrs flag, "magic_and_path".
Normally files get fed into the dependency helper if either the
path regexp or the magic regexp matches. With the flag, both
have to match.

(If you don't like the name, feel free to choose a better one.)

Cheers,
  Michael.

-- 
Michael Schroeder                                   m...@suse.de
SUSE LINUX Products GmbH,  GF Jeff Hawn, HRB 16746 AG Nuernberg
main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}
Allow "magic_and_path" flag to configure that files must
match both regexpes to be sent to the dependency generator.

--- build/rpmfc.c.orig	2011-05-16 10:46:20.000000000 +0000
+++ build/rpmfc.c	2011-05-16 11:02:56.000000000 +0000
@@ -613,6 +613,7 @@ static void rpmfcAttributes(rpmfc fc, co
     const char *path = fullpath + fc->brlen;
     int is_executable = 0;
     struct stat st;
+    int magic_and_path;
     if (stat(fullpath, &st) == 0) {
 	is_executable = (S_ISREG(st.st_mode)) &&
 			(st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH));
@@ -630,10 +631,13 @@ static void rpmfcAttributes(rpmfc fc, co
 	    continue;
 
 	/* Add attributes on libmagic type & path pattern matches */
-	if (regMatch((*attr)->magic, ftype))
-	    argvAddTokens(&fc->fattrs[fc->ix], (*attr)->name);
-	if (regMatch((*attr)->path, path))
-	    argvAddTokens(&fc->fattrs[fc->ix], (*attr)->name);
+	if ((*attr)->magic && (*attr)->path && hasAttr((*attr)->flags, "magic_and_path")) {
+	    if (regMatch((*attr)->magic, ftype) && regMatch((*attr)->path, path))
+		argvAddTokens(&fc->fattrs[fc->ix], (*attr)->name);
+	} else {
+	    if (regMatch((*attr)->magic, ftype) || regMatch((*attr)->path, path))
+		argvAddTokens(&fc->fattrs[fc->ix], (*attr)->name);
+	}
     }
 }
 
_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to