Replace __foo_exeonly attribute with a more generic mechanism

- Use a list of text keyword tokens to allow for more flags without
  requiring adding special processing for every new flag we make
This commit is contained in:
Panu Matilainen 2010-10-05 09:35:45 +03:00
parent 152d1f0bc4
commit fb4bc9b7d7
4 changed files with 9 additions and 8 deletions

View File

@ -23,7 +23,7 @@ typedef struct rpmfcAttr_s {
char *name;
regex_t *pattern;
regex_t *magic;
int exeonly;
ARGV_t flags;
} * rpmfcAttr;
/**
@ -84,9 +84,9 @@ static rpmfcAttr rpmfcAttrNew(const char *name)
{
rpmfcAttr attr = xcalloc(1, sizeof(*attr));
char *eom = rpmfcAttrMacro(name, "exeonly");
attr->exeonly = rpmExpandNumeric(eom);
free(eom);
char *flags = rpmfcAttrMacro(name, "flags");
attr->flags = argvSplitString(flags, ",", ARGV_SKIPEMPTY);
free(flags);
attr->name = xstrdup(name);
attr->pattern = rpmfcAttrReg(name, "pattern");
@ -106,6 +106,7 @@ static rpmfcAttr rpmfcAttrFree(rpmfcAttr attr)
regfree(attr->magic);
rfree(attr->magic);
}
argvFree(attr->flags);
rfree(attr->name);
rfree(attr);
}
@ -592,7 +593,7 @@ static void rpmfcAttributes(rpmfc fc, const char *ftype, const char *fullpath)
for (rpmfcAttr *attr = fc->atypes; attr && *attr; attr++) {
/* Filter out by file modes if set */
if ((*attr)->exeonly && !is_executable)
if (hasAttr((*attr)->flags, "exeonly") && !is_executable)
continue;
/* Add attributes on libmagic type & path pattern matches */

View File

@ -1,4 +1,4 @@
%__elf_provides %{_rpmconfigdir}/elfdeps --provides %{?__filter_GLIBC_PRIVATE:--filter-private}
%__elf_requires %{_rpmconfigdir}/elfdeps --requires %{?__filter_GLIBC_PRIVATE:--filter-private}
%__elf_magic ^ELF (32|64)-bit.*$
%__elf_exeonly 1
%__elf_flags exeonly

View File

@ -1,3 +1,3 @@
%__perl_requires %{_rpmconfigdir}/perl.req
%__perl_magic ^.*perl .*$
%__perl_exeonly 1
%__perl_flags exeonly

View File

@ -1,3 +1,3 @@
%__script_requires %{_rpmconfigdir}/script.req
%__script_magic ^.* script text.*$
%__script_exeonly 1
%__script_flags exeonly