Unify %verify and virtual file attribute handling

This commit is contained in:
Panu Matilainen 2012-05-28 08:54:30 +03:00
parent f69dd4ce18
commit 487f26633f
1 changed files with 17 additions and 20 deletions

View File

@ -280,6 +280,19 @@ static VFA_t const verifyAttrs[] = {
{ NULL, 0 } { NULL, 0 }
}; };
static rpmFlags vfaMatch(VFA_t *attrs, const char *token, rpmFlags *flags)
{
VFA_t *vfa;
for (vfa = attrs; vfa->attribute != NULL; vfa++) {
if (rstreq(token, vfa->attribute)) {
*flags |= vfa->flag;
break;
}
}
return vfa->flag;
}
/** /**
* Parse %verify and %defverify from file manifest. * Parse %verify and %defverify from file manifest.
* @param buf current spec file line * @param buf current spec file line
@ -338,16 +351,8 @@ static rpmRC parseForVerify(char * buf, FileEntry cur, FileEntry def)
if (*pe != '\0') if (*pe != '\0')
*pe++ = '\0'; *pe++ = '\0';
{ VFA_t *vfa; if (vfaMatch(verifyAttrs, p, &verifyFlags))
for (vfa = verifyAttrs; vfa->attribute != NULL; vfa++) { continue;
if (!rstreq(p, vfa->attribute))
continue;
verifyFlags |= vfa->flag;
break;
}
if (vfa->attribute)
continue;
}
if (rstreq(p, "not")) { if (rstreq(p, "not")) {
negated ^= 1; negated ^= 1;
@ -810,7 +815,7 @@ exit:
} }
/** /**
*/ */
static VFA_t const virtualFileAttributes[] = { static VFA_t const virtualAttrs[] = {
{ "%dir", RPMFILE_DIR }, { "%dir", RPMFILE_DIR },
{ "%docdir", RPMFILE_DOCDIR }, { "%docdir", RPMFILE_DOCDIR },
{ "%doc", RPMFILE_DOC }, { "%doc", RPMFILE_DOC },
@ -837,18 +842,10 @@ static rpmRC parseForSimple(char * buf, FileEntry cur, ARGV_t * fileNames)
t = buf; t = buf;
while ((s = strtokWithQuotes(t, " \t\n")) != NULL) { while ((s = strtokWithQuotes(t, " \t\n")) != NULL) {
VFA_t *vfa;
t = NULL; t = NULL;
/* Set flags for virtual file attributes */ /* Set flags for virtual file attributes */
for (vfa = virtualFileAttributes; vfa->attribute != NULL; vfa++) { if (vfaMatch(virtualAttrs, s, &(cur->attrFlags)))
if (rstreq(s, vfa->attribute)) {
cur->attrFlags |= vfa->flag;
break;
}
}
/* if we got an attribute, continue with next token */
if (vfa->attribute != NULL)
continue; continue;
/* normally paths need to be absolute */ /* normally paths need to be absolute */