repodata: check for duplicated SRPM packages

This commit is contained in:
Silvan Calarco 2021-03-12 17:08:02 +01:00
parent b94d504063
commit 10e111f785

View File

@ -1049,6 +1049,35 @@ int addToSourceHeaderList(struct configTag *ct, int mode, int altrepository) {
filelists_node = filelists_node->next,
other_node = other_node->next) {
if (!strcmp((char*)package_node->name, "package")) {
char *package_name = strdup((char*)
findXMLPropertyByName(package_node, "name")->children->content);
xmlNode *version = findXMLPropertyByName(package_node, "version");
tmp = (char*)findXMLAttributeByName(version, "epoch");
int package_epoch = atoi(tmp);
free(tmp);
char *package_version = (char*)findXMLAttributeByName(version, "ver");
char *package_release = (char*)findXMLAttributeByName(version, "rel");
// Check next package for duplicates
xmlNode *next_package = package_node->next;
while (next_package && strcmp((char*)next_package->name, "package")) {
next_package = next_package->next;
}
if (next_package) {
char *next_package_name = strdup((char*)
findXMLPropertyByName(next_package, "name")->children->content);
if (!strcmp(package_name, next_package_name)) {
// Assuming that older packages come first
logmsg(LOG_WARNING,"skipping older duplicated SRPM package %s(%d:%s:%s)",
package_name, package_epoch, package_version, package_release);
free(next_package_name);
free(package_name);
free(package_version);
free(package_release);
continue;
}
}
newheadersourcelist = malloc(sizeof(struct headerSourceList));
if (newheadersourcelist == NULL) return 1;
@ -1063,14 +1092,10 @@ int addToSourceHeaderList(struct configTag *ct, int mode, int altrepository) {
newheadersourcelist->old = NULL;
newheadersourcelist->id = ++sourceid;
newheadersourcelist->name = strdup((char*)
findXMLPropertyByName(package_node, "name")->children->content);
xmlNode *version = findXMLPropertyByName(package_node, "version");
tmp = (char*)findXMLAttributeByName(version, "epoch");
newheadersourcelist->epoch = atoi(tmp);
free(tmp);
newheadersourcelist->version = (char*)findXMLAttributeByName(version, "ver");
newheadersourcelist->release = (char*)findXMLAttributeByName(version, "rel");
newheadersourcelist->name = package_name;
newheadersourcelist->epoch = package_epoch;
newheadersourcelist->version = package_version;
newheadersourcelist->release = package_release;
newheadersourcelist->summary = strdup((char*)
findXMLPropertyByName(package_node, "summary")->children->content);
newheadersourcelist->arch = strdup((char*)