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->numproviders);
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;
}
sqlite3_bind_text(stmt, 1, provided->name, -1, SQLITE_STATIC);
if (sqlite3_step(stmt) != SQLITE_DONE) {
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
return 3;
fprintf(stderr, "ERROR: SQLite: (%s %s) %s; ignoring\n", sqlite3_query,
provided->name, sqlite3_errmsg(db));
}
sqlite3_finalize(stmt);
}

View File

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