Fix version requirements checks with multiple providers

Also make providedList more linear by removing numversions and using numproviders for provider[] and version[] vectors
This commit is contained in:
Silvan Calarco 2013-10-06 16:31:06 +02:00
parent f49e684c64
commit 57786153d2
3 changed files with 50 additions and 34 deletions

View File

@ -417,10 +417,11 @@ static int
resolveFirstLevelDependencies(struct configTag *ct, int archidx)
{
struct headerList *currheader, *scanheader, **newprovider;
struct providedList *provided;
struct providedList *provided, *foundverprovided;
struct fileTree *file;
int i,j,k,found;
char warning[PATH_MAX];
char ** newversion;
currheader = ct->headerlist[archidx];
@ -593,51 +594,76 @@ resolveFirstLevelDependencies(struct configTag *ct, int archidx)
newprovider[j]=provided->provider[j];
}
newprovider[provided->numproviders-1] = file->provider[k];
free(provided->provider);
if (provided->provider) free(provided->provider);
provided->provider=newprovider;
newversion=malloc(sizeof(char *)*provided->numproviders);
for (j = 0; j < provided->numproviders-1; j++) {
newversion[j]=provided->version[j];
}
newversion[provided->numproviders-1] = strdup(provided->provider[j]->version);
if (provided->version) free(provided->version);
provided->version=newversion;
}
}
}
}
if (provided->numversions > 0) {
if (provided->numproviders > 0) {
if (strcmp(currheader->require[i]->version,"") &&
(currheader->require[i]->flags & (RPMSENSE_LESS|RPMSENSE_GREATER|RPMSENSE_EQUAL))) {
found = 0;
for (j = 0; j < provided->numversions; j++) {
foundverprovided = NULL;
for (j = 0; j < provided->numproviders; j++) {
if (foundverprovided && !strcmp(foundverprovided->name,provided->name)) {
found = 0;
foundverprovided = NULL;
}
if (!strcmp(provided->version[j],"")) {
/* provider with no version; assume ok */
found = 1;
foundverprovided=provided;
} else {
if (checkVersionWithFlags(
currheader->require[i]->version,
currheader->require[i]->flags,
provided->version[j])) found = 1;
provided->version[j])) {
found = 1;
foundverprovided=provided;
}
}
} /* for */
if (!found) {
for (j = 0; j < provided->numversions; j++) {
snprintf(warning, PATH_MAX, "%s = %s fails to provide %s ",
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)",
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);
for (k = 0; k < provided->numproviders; k++) {
if (provided->provider[k]->sourceheader &&
(provided->provider[k]->altrepository == ct->repository_level)) {
for (k = 0; k < provided->numproviders; k++) {
if (provided->provider[k]->sourceheader &&
(provided->provider[k]->altrepository == ct->repository_level)) {
fprintf(stderr,"Warning: %s\n", warning);
addWarning(provided->provider[k]->sourceheader, warning);
addWarning(provided->provider[k]->sourceheader, warning);
}
}
}
}
}
}
@ -738,7 +764,7 @@ resolveFirstLevelSourceDependencies(struct configTag *ct, int archidx)
if (strcmp(currsourceheader->require[i]->version,"") &&
(currsourceheader->require[i]->flags & (RPMSENSE_LESS+RPMSENSE_GREATER+RPMSENSE_EQUAL))) {
found = 0;
for (j = 0; j < provided->numversions; j++) {
for (j = 0; j < provided->numproviders; j++) {
if (!strcmp(provided->version[j],"")) {
/* provider with no version; assume ok */
found = 1;

View File

@ -456,7 +456,6 @@ findOrCreateProvidedListEntry(struct providedList* *idx,
newprovided->provider = NULL;
newprovided->numproviders = 0;
newprovided->numbuildproviders = 0;
newprovided->numversions = 0;
newprovided->buildprovider = NULL;
newprovided->name = strdup(findname);
newprovided->id = ++providedListId;
@ -1003,7 +1002,6 @@ addToHeaderList(struct configTag *ct,
provided->numproviders++;
provided->provider=malloc(sizeof(struct headerList*));
provided->provider[0]=newheaderlist;
provided->numversions++;
provided->version=malloc(sizeof(char *));
provided->version[0]=strdup(provideversion[i]);
} else if (provided && (provided->numproviders > 0)) {
@ -1016,21 +1014,14 @@ addToHeaderList(struct configTag *ct,
free(provided->provider);
provided->provider=newprovider;
// check if version is already provided
for (j = 0; j < provided->numversions; j++) {
if (!strcmp(provided->version[j],provideversion[i])) break;
}
// if not add to the list of versions
if (j == provided->numversions) {
provided->numversions++;
newversion=malloc(sizeof(char *)*provided->numversions);
for (j = 0; j < provided->numversions-1; j++) {
newversion[j]=provided->version[j];
}
newversion[provided->numversions-1] = strdup(provideversion[i]);
free(provided->version);
provided->version=newversion;
newversion=malloc(sizeof(char *)*provided->numproviders);
for (j = 0; j < provided->numproviders-1; j++) {
newversion[j]=provided->version[j];
}
newversion[provided->numproviders-1] = strdup(provideversion[i]);
free(provided->version);
provided->version=newversion;
} else {
fprintf(stderr,"%s has %d providers but is ignored\n",provided->name,provided->numproviders);
}

View File

@ -29,7 +29,6 @@ struct providedList {
struct headerList **provider;
int numbuildproviders;
struct headerList **buildprovider;
int numversions;
char **version;
int buildpriority;
struct providedList *next;