gen headerlist with repodata: fix the way packages in alternate repositories are processed to match the previous (working correcly) behaviour

This commit is contained in:
Silvan Calarco 2021-02-17 20:37:44 +01:00
parent 80d1ad8e46
commit 6a5bfecb6d

View File

@ -922,7 +922,7 @@ void addNewToSourceHeaderList(struct headerSourceList *newheadersourcelist,
currheadersourcelist = ct->headersourcelist;
prevheadersourcelist = NULL;
while ((currheadersourcelist) &&
(strcasecmp(currheadersourcelist->name,newheadersourcelist->name) < 0)) {
(strcmp(currheadersourcelist->name,newheadersourcelist->name) < 0)) {
prevheadersourcelist = currheadersourcelist;
currheadersourcelist = currheadersourcelist->next;
}
@ -931,6 +931,7 @@ void addNewToSourceHeaderList(struct headerSourceList *newheadersourcelist,
(!strcmp(currheadersourcelist->name,newheadersourcelist->name))) {
/* the package is both in main and alternate repositories.
override main repository package */
if ((currheadersourcelist->epoch > newheadersourcelist->epoch) ||
((currheadersourcelist->epoch == newheadersourcelist->epoch) &&
(rpmvercmp(currheadersourcelist->version,
@ -1349,18 +1350,10 @@ int addNewToHeaderList(struct headerList **currheaderlist,
return 0;
}
char* advanceXMLPackageNode(char* prevname, xmlNode **primary_node,
xmlNode **filelists_node) {
char* advanceXMLPackageNode(xmlNode **primary_node, xmlNode **filelists_node) {
char* currname;
// check if already currname > prevname
if (*primary_node && !strcmp((char*)(*primary_node)->name, "package")) {
currname = strdup((char*)
findXMLPropertyByName(*primary_node, "name")->children->content);
// primary_node is already advanced
if (strcmp(prevname, currname) < 0) return currname;
free(currname);
}
// nope: go to next package
if (*primary_node) {
*primary_node = (*primary_node)->next;
*filelists_node = (*filelists_node)->next;
@ -1384,6 +1377,7 @@ char* advanceXMLPackageNode(char* prevname, xmlNode **primary_node,
struct repoData* repodata[ALT_REPS_MAX + 1];
xmlNode *primary_node[ALT_REPS_MAX + 1], *filelists_node[ALT_REPS_MAX + 1];
char *currnames[ALT_REPS_MAX + 1];
char nextname[bufsize + 1];
char scanpath[bufsize + 1], *altscanpath[ALT_REPS_MAX];
@ -1470,6 +1464,10 @@ char* advanceXMLPackageNode(char* prevname, xmlNode **primary_node,
primary_node[i] = xmlDocGetRootElement(repodata[i]->primary_doc)->children;
filelists_node[i] = xmlDocGetRootElement(repodata[i]->filelists_doc)->children;
}
// Setup all repo nodes to first package
for (i = 0; i <= alt_reps_num; i++)
currnames[i] = advanceXMLPackageNode(&(primary_node[i]),
&(filelists_node[i]));
} else {
n = scansdir(scanpath, &namelist, rpmselector, scanrpmnamecmp);
if (n < 0) {
@ -1492,23 +1490,28 @@ char* advanceXMLPackageNode(char* prevname, xmlNode **primary_node,
}
}
int altidx = -1;
currname[0] = '\0';
while (1) {
if (repodata[0]) {
/* Use repodata */
int altidx = -1;
char *newname = NULL;
if (altidx >= 0) {
// Advance name in repo with current package just done
free(currnames[altidx]);
currnames[altidx] = advanceXMLPackageNode(&(primary_node[altidx]),
&(filelists_node[altidx]));
}
altidx = -1;
nextname[0] = '\0';
for (i = 0; i <= alt_reps_num; i++) {
newname = advanceXMLPackageNode(currname, &(primary_node[i]),
&(filelists_node[i]));
if (newname) {
if (nextname[0] == '\0' || strcmp(nextname, newname) >= 0) {
strncpy(nextname, newname, bufsize);
altidx = i;
}
free(newname);
if (currnames[i] &&
(nextname[0] == '\0' || strcmp(nextname, currnames[i]) >= 0)) {
strncpy(nextname, currnames[i], bufsize);
altidx = i;
}
}
if (altidx >=0) {
strncpy(currname, nextname, bufsize);
//printf("alt%d %s\n", altidx, currname);
@ -1607,7 +1610,7 @@ char* advanceXMLPackageNode(char* prevname, xmlNode **primary_node,
newheaderlist->obsoleteflags = obsoleteflags;
newheaderlist->obsoleteversion = obsoleteversion;
newheaderlist->obsoletecount = obsoletecount;
newheaderlist->altrepository = altrepository;
newheaderlist->altrepository = altidx;
// Requires
newheaderlist->require = malloc(requirecount * sizeof(struct Require *));
for (j=0; j < requirecount; j++) {