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