headerlist.c: getXMLPackageNFV: support of rich requirements containing 'or' (consider only the latter requirement with > or >=)

This commit is contained in:
Silvan Calarco 2021-09-04 13:04:48 +02:00
parent f5e33d9f50
commit 3197ec8cf7

View File

@ -85,7 +85,7 @@ struct warningList* addWarning(struct headerSourceList *pkg, char* text)
currwarning = currwarning->next;
}
currwarning=malloc(sizeof(currwarning));
currwarning=malloc(sizeof(struct warningList));
if (!currwarning) return NULL;
if (!pkg->firstwarning) pkg->firstwarning=currwarning;
@ -866,7 +866,7 @@ void getXMLPackageChangelog(xmlNode *parent,
}
void getXMLPackageNFV(xmlNode *parent, char ***name,
void getXMLPackageNFV(char* package_name, xmlNode *parent, char ***name,
uint_32 **flags, char ***version, int *count) {
char *n, buf[PATH_MAX];
@ -940,8 +940,17 @@ void getXMLPackageNFV(xmlNode *parent, char ***name,
(*name)[i] = strdup(n2);
(*flags)[i] = XMLFlagToInt(rel2);
(*version)[i] = strdup(v2);
} else if (ret == 7 && !strncmp(comp,"or",2)) {
// E.g. '(python3.7dist(requests) < 2.18 or python3.7dist(requests) > 2.18)'
// Considering the second part (> or >=)
free(n);
(*name)[i] = strdup(n2);
(*flags)[i] = XMLFlagToInt(rel2);
(*version)[i] = strdup(v2);
} else {
logmsg(LOG_WARNING,"getXMLPackageNFV: don't know how to process '%s'; ignoring", n);
logmsg(LOG_WARNING,
"%s: getXMLPackageNFV: don't know how to process '%s'; ignoring",
package_name, n);
(*name)[i] = n;
(*flags)[i] = RPMSENSE_ANY;
(*version)[i] = strdup(buf);
@ -1183,7 +1192,8 @@ int addToSourceHeaderList(struct configTag *ct, int mode, int altrepository) {
newheadersourcelist->patch = NULL;
// Requires
getXMLPackageNFV(findXMLPropertyByName(format, "requires"),
getXMLPackageNFV(package_name,
findXMLPropertyByName(format, "requires"),
&requirename, &requireflags, &requireversion, &requirecount);
newheadersourcelist->require = malloc(requirecount *
sizeof(struct Require *));
@ -1650,12 +1660,15 @@ char* advanceXMLPackageNode(xmlNode **primary_node, xmlNode **filelists_node) {
altidx, arch);
if (ret == 0) {
getXMLPackageNFV(findXMLPropertyByName(format, "obsoletes"),
getXMLPackageNFV(newheaderlist->name,
findXMLPropertyByName(format, "obsoletes"),
&obsoletename, &obsoleteflags, &obsoleteversion, &obsoletecount);
getXMLPackageNFV(findXMLPropertyByName(format, "provides"),
getXMLPackageNFV(newheaderlist->name,
findXMLPropertyByName(format, "provides"),
&providename, &provideflags, &provideversion, &providecount);
getXMLPackageNFV(findXMLPropertyByName(format, "requires"),
&requirename, &requireflags, &requireversion, &requirecount);
getXMLPackageNFV(newheaderlist->name,
findXMLPropertyByName(format, "requires"),
&requirename, &requireflags, &requireversion, &requirecount);
newheaderlist->provided = malloc(sizeof(struct providedList*)*providecount);
for (i=0; i < providecount; i++) {