handleObsoletedPackages(): fix: prevent upper repositories packages to obsolete packages in current repository; code formatting fixes

This commit is contained in:
Silvan Calarco 2020-06-20 19:12:42 +02:00
parent fac5730549
commit 93936cac50
3 changed files with 134 additions and 136 deletions

View File

@ -1 +1 @@
1.5.0 1.5.0.1

View File

@ -235,13 +235,14 @@ int generateSQLite_provided(struct configTag* ct, sqlite3 *db, int arch) {
provided->flags, provided->flags,
provided->numproviders); provided->numproviders);
if (sqlite3_prepare_v3(db, sqlite3_query, -1, 0, &stmt, NULL)) { if (sqlite3_prepare_v3(db, sqlite3_query, -1, 0, &stmt, NULL)) {
fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query); fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n",
sqlite3_errmsg(db), sqlite3_query);
return 1; return 1;
} }
sqlite3_bind_text(stmt, 1, provided->name, -1, SQLITE_STATIC); sqlite3_bind_text(stmt, 1, provided->name, -1, SQLITE_STATIC);
if (sqlite3_step(stmt) != SQLITE_DONE) { if (sqlite3_step(stmt) != SQLITE_DONE) {
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); fprintf(stderr, "ERROR: SQLite: (%s %s) %s; ignoring\n", sqlite3_query,
return 3; provided->name, sqlite3_errmsg(db));
} }
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
} }

View File

@ -255,26 +255,26 @@ handleObsoletedPackages(struct configTag *ct, int archidx)
} }
if (prov->numproviders > 1) { if (prov->numproviders > 1) {
for (i = 0; i < prov->numproviders; i++) obs[i]=-1; for (i = 0; i < prov->numproviders; i++) obs[i]=-1;
for (i = 0; i < prov->numproviders; i++) for (i = 0; i < prov->numproviders; i++)
for (j = 0; j < prov->provider[i]->obsoletecount; j++) for (j = 0; j < prov->provider[i]->obsoletecount; j++)
for (k = 0; k < prov->numproviders; k++) for (k = 0; k < prov->numproviders; k++)
if (!strcmp(prov->provider[i]->obsoletename[j],prov->provider[k]->name) if (!strcmp(prov->provider[i]->obsoletename[j],prov->provider[k]->name)
&& strcmp(prov->provider[i]->name,prov->provider[k]->name)) { && strcmp(prov->provider[i]->name,prov->provider[k]->name)) {
if (prov->provider[i]->obsoleteflags[j] & (RPMSENSE_EQUAL|RPMSENSE_GREATER|RPMSENSE_LESS)) { if (prov->provider[i]->obsoleteflags[j] & (RPMSENSE_EQUAL|RPMSENSE_GREATER|RPMSENSE_LESS)) {
snprintf(buf, PATH_MAX, "%s-%s",prov->provider[k]->version,prov->provider[k]->release); snprintf(buf, PATH_MAX, "%s-%s",prov->provider[k]->version,prov->provider[k]->release);
if (!checkVersionWithFlags( if (!checkVersionWithFlags(
prov->provider[i]->obsoleteversion[j], prov->provider[i]->obsoleteversion[j],
prov->provider[i]->obsoleteflags[j], prov->provider[i]->obsoleteflags[j],
buf)) continue; buf)) continue;
} }
/* print 'obsoletes' warning for binary packages belonging to target repository, /* print 'obsoletes' warning for binary packages belonging to target repository,
and 'obsoleted by' for all obsoletions in upper level repositories */ and 'obsoleted by' for all obsoletions in upper level repositories */
if (prov->provider[k]->altrepository != ct->repository_level) { if (prov->provider[k]->altrepository != ct->repository_level) {
currheader = prov->provider[k]->sourceheader->firstchild[archidx]; currheader = prov->provider[k]->sourceheader->firstchild[archidx];
while (currheader) { while (currheader) {
if (!strcmp(currheader->name, prov->provider[k]->name)) { if (!strcmp(currheader->name, prov->provider[k]->name)) {
prov->provider[k]->obsoleted = 1; prov->provider[k]->obsoleted = 1;
snprintf(buf, PATH_MAX, "%s(%s,%s) obsoleted by %s(%s,%s)", snprintf(buf, PATH_MAX, "%s(%s,%s) obsoleted by %s(%s,%s)",
prov->provider[k]->name, prov->provider[k]->name,
prov->provider[k]->arch, prov->provider[k]->arch,
@ -283,25 +283,27 @@ handleObsoletedPackages(struct configTag *ct, int archidx)
prov->provider[i]->arch, prov->provider[i]->arch,
ct->repository[prov->provider[i]->altrepository]->tag); ct->repository[prov->provider[i]->altrepository]->tag);
addWarning(prov->provider[k]->sourceheader, buf); addWarning(prov->provider[k]->sourceheader, buf);
logmsg(LOG_WARNING,"%s", buf); logmsg(LOG_WARNING,"%s", buf);
break; break;
} }
currheader = currheader -> nextbrother; currheader = currheader -> nextbrother;
} }
} else { obs[k]=i;
prov->provider[k]->obsoleted = 1; } else if (prov->provider[i]->altrepository == ct->repository_level) {
snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s(%s,%s)", // NOTE: don't obsolete if it comes from an upper level repository
prov->provider[i]->name, prov->provider[k]->obsoleted = 1;
prov->provider[i]->arch, snprintf(buf, PATH_MAX, "%s(%s,%s) obsoletes %s(%s,%s)",
ct->repository[prov->provider[i]->altrepository]->tag, prov->provider[i]->name,
prov->provider[k]->name, prov->provider[i]->arch,
prov->provider[k]->arch, ct->repository[prov->provider[i]->altrepository]->tag,
ct->repository[prov->provider[k]->altrepository]->tag); prov->provider[k]->name,
addWarning(prov->provider[i]->sourceheader, buf); prov->provider[k]->arch,
logmsg(LOG_WARNING,"%s", buf); ct->repository[prov->provider[k]->altrepository]->tag);
} addWarning(prov->provider[i]->sourceheader, buf);
obs[k]=i; logmsg(LOG_WARNING,"%s", buf);
} obs[k]=i;
}
}
// now delete found obsoleted providers // now delete found obsoleted providers
j = prov->numproviders; j = prov->numproviders;
@ -325,7 +327,6 @@ handleObsoletedPackages(struct configTag *ct, int archidx)
prov->numproviders = j; prov->numproviders = j;
} }
} }
prov=prov->next; prov=prov->next;
} }
@ -584,111 +585,107 @@ resolveFirstLevelDependencies(struct configTag *ct, int archidx)
provided->version=newversion; provided->version=newversion;
} }
} }
} }
} }
if (provided->numproviders > 0) { if (provided->numproviders > 0) {
if (strcmp(currheader->require[i]->version,"") && if (strcmp(currheader->require[i]->version,"") &&
(currheader->require[i]->flags & (RPMSENSE_LESS|RPMSENSE_GREATER|RPMSENSE_EQUAL))) { (currheader->require[i]->flags & (RPMSENSE_LESS|RPMSENSE_GREATER|RPMSENSE_EQUAL))) {
found = 0; found = 0;
foundprovider = -1; foundprovider = -1;
foundupstreamprovider = 0; foundupstreamprovider = 0;
for (j = 0; j < provided->numproviders; j++) { for (j = 0; j < provided->numproviders; j++) {
/* updated packages: ignore check with upstream package */ /* updated packages: ignore check with upstream package */
if ((foundprovider >= 0) && if ((foundprovider >= 0) &&
!strcmp(provided->provider[foundprovider]->name,provided->provider[j]->name) && !strcmp(provided->provider[foundprovider]->name,provided->provider[j]->name) &&
provided->provider[foundprovider]->altrepository < provided->provider[j]->altrepository) { provided->provider[foundprovider]->altrepository < provided->provider[j]->altrepository)
found -= 1; {
foundupstreamprovider = foundprovider; found -= 1;
foundprovider = -1; foundupstreamprovider = foundprovider;
} foundprovider = -1;
if (!strcmp(provided->version[j],"")) { }
/* provider with no version; assume ok */ if (!strcmp(provided->version[j],"")) {
found += 1; /* provider with no version; assume ok */
foundupstreamprovider = foundprovider; found += 1;
foundprovider = j; foundupstreamprovider = foundprovider;
} else { foundprovider = j;
if (checkVersionWithFlags( } else {
currheader->require[i]->version, if (checkVersionWithFlags(
currheader->require[i]->flags, currheader->require[i]->version,
provided->version[j])) { currheader->require[i]->flags,
found += 1; provided->version[j])) {
foundupstreamprovider = foundprovider; found += 1;
foundprovider = j; foundupstreamprovider = foundprovider;
} foundprovider = j;
} }
/*if (!strcmp(provided->name,"pkgconfig(gio-2.0)")) }
printf("provided->name=pkgconfig(gio-2.0) found=%d foundprovider=%d foundupstreamprovider=%d provided->version[j]=%s\n", } /* for */
found, foundprovider, foundupstreamprovider, provided->version[j]);*/ if ((found >= 1) && (!foundupstreamprovider) &&
} /* for */ (currheader->altrepository != 0) &&
if ((found >= 1) && (!foundupstreamprovider) && (currheader->altrepository = ct->repository_level) &&
(currheader->altrepository != 0) && (provided->provider[foundprovider]->sourceheader != currheader->sourceheader) &&
(currheader->altrepository = ct->repository_level) && (provided->provider[foundprovider]->altrepository == currheader->altrepository)) {
(provided->provider[foundprovider]->sourceheader != currheader->sourceheader) && snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s(%s,%s) because it needs %s=%s",
(provided->provider[foundprovider]->altrepository == currheader->altrepository)) { currheader->name, currheader->arch,
snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s(%s,%s) because it needs %s=%s", ct->repository[currheader->altrepository]->tag,
currheader->name, provided->provider[foundprovider]->name,
currheader->arch, provided->provider[foundprovider]->arch,
ct->repository[currheader->altrepository]->tag, ct->repository[provided->provider[foundprovider]->altrepository]->tag,
provided->provider[foundprovider]->name, provided->name,
provided->provider[foundprovider]->arch, provided->version[foundprovider]);
ct->repository[provided->provider[foundprovider]->altrepository]->tag, logmsg(LOG_WARNING,"%s", warning);
provided->name, addWarning(currheader->sourceheader, warning);
provided->version[foundprovider]); } else if (!found) {
logmsg(LOG_WARNING,"%s", warning); for (j = 0; j < provided->numproviders; j++) {
addWarning(currheader->sourceheader, warning); if (!checkVersionWithFlags(
} else if (!found) { currheader->require[i]->version,
for (j = 0; j < provided->numproviders; j++) { currheader->require[i]->flags,
if (!checkVersionWithFlags( provided->version[j])) {
currheader->require[i]->version, snprintf(warning, PATH_MAX, "%s=%s from %s(%s,%s) fails to provide %s",
currheader->require[i]->flags, provided->name,
provided->version[j])) { provided->version[j],
snprintf(warning, PATH_MAX, "%s=%s from %s(%s,%s) fails to provide %s", provided->provider[j]->name,
provided->name, provided->provider[j]->arch,
provided->version[j], ct->repository[provided->provider[j]->altrepository]->tag,
provided->provider[j]->name, provided->name);
provided->provider[j]->arch, if (currheader->require[i]->flags & RPMSENSE_LESS) snprintf(&warning[strlen(warning)], PATH_MAX,"<");
ct->repository[provided->provider[j]->altrepository]->tag, if (currheader->require[i]->flags & RPMSENSE_GREATER) snprintf(&warning[strlen(warning)], PATH_MAX, ">");
provided->name); if (currheader->require[i]->flags & RPMSENSE_EQUAL) snprintf(&warning[strlen(warning)], PATH_MAX, "=");
if (currheader->require[i]->flags & RPMSENSE_LESS) snprintf(&warning[strlen(warning)], PATH_MAX,"<"); snprintf(&warning[strlen(warning)], PATH_MAX, "%s to %s(%s,%s)",
if (currheader->require[i]->flags & RPMSENSE_GREATER) snprintf(&warning[strlen(warning)], PATH_MAX, ">");
if (currheader->require[i]->flags & RPMSENSE_EQUAL) snprintf(&warning[strlen(warning)], PATH_MAX, "=");
snprintf(&warning[strlen(warning)], PATH_MAX, "%s to %s(%s,%s)",
currheader->require[i]->version, currheader->require[i]->version,
currheader->name, currheader->name,
currheader->arch, currheader->arch,
ct->repository[currheader->altrepository]->tag); ct->repository[currheader->altrepository]->tag);
logmsg(LOG_WARNING,"%s", warning); logmsg(LOG_WARNING,"%s", warning);
for (k = 0; k < provided->numproviders; k++) { for (k = 0; k < provided->numproviders; k++) {
if (provided->provider[k]->sourceheader && if (provided->provider[k]->sourceheader &&
(provided->provider[k]->altrepository == ct->repository_level)) { (provided->provider[k]->altrepository == ct->repository_level)) {
addWarning(provided->provider[k]->sourceheader, warning); addWarning(provided->provider[k]->sourceheader, warning);
} }
if ((currheader->altrepository == ct->repository_level)) { if ((currheader->altrepository == ct->repository_level)) {
addWarning(currheader->sourceheader, warning); addWarning(currheader->sourceheader, warning);
} }
} }
} }
} } /* for */
} }
}
}
}
currheader->require[i]->resolved=provided;
} else {
currheader->require[i]->resolved=NULL;
}
} }
// sort required list by first provider's name currheader->require[i]->resolved=provided;
qsort((void *) &currheader->require[0], } else {
currheader->requirecount, currheader->require[i]->resolved=NULL;
sizeof(struct Require *), }
compareRequiredList); }
currheader = currheader->next; // sort required list by first provider's name
} qsort((void *) &currheader->require[0],
logmsg(LOG_DEBUG,"resolveFirstLevelDependencies - done"); currheader->requirecount,
return 0; sizeof(struct Require *),
compareRequiredList);
currheader = currheader->next;
}
logmsg(LOG_DEBUG,"resolveFirstLevelDependencies - done");
return 0;
} }
static int static int