From 7d07afc0cc4ead23c333e577acc709111f865ab9 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 20 Mar 2021 12:21:11 +0100 Subject: [PATCH] distromatic.c: indentation fixes --- src/distromatic.c | 540 +++++++++++++++++++++++----------------------- 1 file changed, 270 insertions(+), 270 deletions(-) diff --git a/src/distromatic.c b/src/distromatic.c index f90fc0a..c5a103e 100644 --- a/src/distromatic.c +++ b/src/distromatic.c @@ -401,290 +401,290 @@ handleObsoletedPackages(struct configTag *ct, int archidx) static int resolveFirstLevelDependencies(struct configTag *ct, int archidx) { - struct headerList *currheader, *scanheader, **newprovider; - struct providedList *provided; - struct fileTree *file; - int i,j,k,found,foundprovider, foundupstreamprovider; - char warning[PATH_MAX]; - char ** newversion; + struct headerList *currheader, *scanheader, **newprovider; + struct providedList *provided; + struct fileTree *file; + int i,j,k,found,foundprovider, foundupstreamprovider; + char warning[PATH_MAX]; + char ** newversion; - currheader = ct->headerlist[archidx]; + currheader = ct->headerlist[archidx]; - logmsg(LOG_DEBUG,"resolveFirstLevelDependencies - binaries"); + logmsg(LOG_DEBUG,"resolveFirstLevelDependencies - binaries"); - while (currheader) { - scanheader = ct->headerlist[archidx]; - currheader->requirelist = NULL; - if ((!currheader->obsoleted) && (currheader->next) && (currheader->sourceheader->updatingparent)) { - // mark obsoleted any package with same name in upper level repositories - if (currheader->altrepository < currheader->sourceheader->updatingparent->altrepository) { - currheader->obsoleted = 1; - if (checkVersionWithFlags( - currheader->version, - RPMSENSE_GREATER & RPMSENSE_EQUAL, - currheader->next->version)) { - snprintf(warning,PATH_MAX,"%s(%s,%s): same or higher version than package with same name in %s (%s >= %s)", - currheader->name, - ct->arch[archidx], - ct->repository[currheader->altrepository]->tag, - ct->repository[currheader->next->altrepository]->tag, - currheader->version, - currheader->next->version); - fprintf(stderr,"Warning: %s\n",warning); - addWarning(currheader->sourceheader,warning); - } - } else if (currheader->altrepository >= currheader->sourceheader->updatingparent->altrepository) { - currheader->next->obsoleted = 1; - if (checkVersionWithFlags( - currheader->version, - RPMSENSE_LESS & RPMSENSE_EQUAL, - currheader->next->version)) { - snprintf(warning,PATH_MAX,"%s(%s,%s): same or higher version than package with same name in %s (%s >= %s)", - currheader->next->name, - ct->arch[archidx], - ct->repository[currheader->next->altrepository]->tag, - ct->repository[currheader->altrepository]->tag, - currheader->next->version, - currheader->version); - fprintf(stderr,"Warning: %s\n",warning); - addWarning(currheader->sourceheader,warning); - } - } - } + while (currheader) { + scanheader = ct->headerlist[archidx]; + currheader->requirelist = NULL; + if ((!currheader->obsoleted) && (currheader->next) && (currheader->sourceheader->updatingparent)) { + // mark obsoleted any package with same name in upper level repositories + if (currheader->altrepository < currheader->sourceheader->updatingparent->altrepository) { + currheader->obsoleted = 1; + if (checkVersionWithFlags( + currheader->version, + RPMSENSE_GREATER & RPMSENSE_EQUAL, + currheader->next->version)) { + snprintf(warning,PATH_MAX,"%s(%s,%s): same or higher version than package with same name in %s (%s >= %s)", + currheader->name, + ct->arch[archidx], + ct->repository[currheader->altrepository]->tag, + ct->repository[currheader->next->altrepository]->tag, + currheader->version, + currheader->next->version); + fprintf(stderr,"Warning: %s\n",warning); + addWarning(currheader->sourceheader,warning); + } + } else if (currheader->altrepository >= currheader->sourceheader->updatingparent->altrepository) { + currheader->next->obsoleted = 1; + if (checkVersionWithFlags( + currheader->version, + RPMSENSE_LESS & RPMSENSE_EQUAL, + currheader->next->version)) { + snprintf(warning,PATH_MAX,"%s(%s,%s): same or higher version than package with same name in %s (%s >= %s)", + currheader->next->name, + ct->arch[archidx], + ct->repository[currheader->next->altrepository]->tag, + ct->repository[currheader->altrepository]->tag, + currheader->next->version, + currheader->version); + fprintf(stderr,"Warning: %s\n",warning); + addWarning(currheader->sourceheader,warning); + } + } + } - if (currheader->obsoleted || currheader->sourceheader->updatingparent) { - currheader = currheader->next; - continue; - } -// currheader->require.resolved = malloc(sizeof(struct providedList*)*currheader->requirecount); - for (i = 0; i < currheader->requirecount; i++) { - if (!strncmp("executable(",currheader->require[i]->name,11)) { - /* dynamic requirement for executable file */ -/* fprintf(stderr,"Warning: skipping unhandled requirement %s for package %s\n", - currheader->require[i]->name,currheader->name);*/ - currheader->require[i]->resolved=NULL; - } else if (strncmp("rpmlib(",currheader->require[i]->name,7) && - strncmp("debuginfo(build-id)",currheader->require[i]->name,20)) { - provided=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx], - currheader->require[i]->name,1,archidx); - if (provided->numproviders == 0) { - // check if require[i]->name requirement is met - scanheader = ct->headerlist[archidx]; - - if ((currheader->require[i]->name)[0] == '/') { - /* requirement is a file, find who provides it */ - file=findOrCreateFileTreeEntry(&ct->filetree[archidx],currheader->require[i]->name, archidx); - if (file->numproviders > 0) { - scanheader=file->provider[0]; - provided->numproviders=file->numproviders; - provided->numbuildproviders=0; - provided->provider=file->provider; - provided->flags=0; - } else { - scanheader=NULL; - } - } else { - /* requirement is not a file, cross-check with provides */ - while (scanheader && - !checkRequireWithProvides( - currheader->require[i]->name, - scanheader)) scanheader = scanheader->next; - if (scanheader) { - provided->numproviders=1; - provided->numbuildproviders=0; - provided->provider=malloc(sizeof(struct headerList*)); - provided->provider[0]=scanheader; - provided->flags=0; - } - } - if (!scanheader && incremental_mode) { - snprintf(warning,PATH_MAX,"%s(%s,%s): missing provider for %s", - currheader->name, - ct->arch[archidx], - ct->repository[currheader->altrepository]->tag, - currheader->require[i]->name); - fprintf(stderr,"Warning: %s\n",warning); - addWarning(currheader->sourceheader,warning); - } - } else { /* provided->numproviders > 0 */ - /* warn about provides only provided by older packages */ - k=0; - for (j = 0; j < provided->numproviders; j++) { - if (provided->provider[j]->sourceheader->updatingparent && - provided->provider[j]->sourceheader->updatingparent->firstchild[archidx] && /* skip if not built for arch */ - !currheader->obsoleted) k++; - } - if (k == provided->numproviders) { // all provides are from older packages - snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s which is only provided by older package(s):", - currheader->name, - currheader->arch, - ct->repository[currheader->altrepository]->tag, - provided->name); - for (j = 0; j < provided->numproviders; j++) { - snprintf(&warning[strlen(warning)], PATH_MAX - strlen(warning), " %s(%s,%s)", - provided->provider[j]->name, - provided->provider[j]->arch, - ct->repository[provided->provider[j]->altrepository]->tag); - addRebuild(provided->provider[j]->sourceheader,currheader->sourceheader,provided->provider[j]); - addWarning(provided->provider[j]->sourceheader,warning); - } - fprintf(stderr,"Warning: %s\n",warning); - } else { - /* warn about provides provided by obsoleted packages */ - k=0; - for (j = 0; j < provided->numproviders; j++) { - if (provided->provider[j]->obsoleted && - !provided->provider[j]->sourceheader->updatingparent && // don't fall in case above - !currheader->obsoleted) k++; - } - if (k == provided->numproviders) { // all provides are obsoleted - snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s which is only provided by obsoleted package(s):", - currheader->name, - currheader->arch, - ct->repository[currheader->altrepository]->tag, - provided->name); - for (j = 0; j < provided->numproviders; j++) { - snprintf(&warning[strlen(warning)], PATH_MAX - strlen(warning), " %s(%s,%s)", - provided->provider[j]->name, - provided->provider[j]->arch, - ct->repository[provided->provider[j]->altrepository]->tag); - } - fprintf(stderr,"Warning: %s\n",warning); - addWarning(currheader->sourceheader,warning); - for (j = 0; j < provided->numproviders; j++) { - addWarning(provided->provider[j]->sourceheader,warning); - } - } - } - if ((currheader->require[i]->name)[0] == '/') { - /* when there is a Requires: /file/requirement add provide from file tree as well */ - file=findOrCreateFileTreeEntry(&ct->filetree[archidx],currheader->require[i]->name, archidx); - for (k = 0; k < file->numproviders; k++) { - for (j = 0, found = 0; j < provided->numproviders; j++) { - /* avoid duplicates */ - if (file->provider[k] == provided->provider[j]) { - found = 1; - break; - } - } - if (! found) { - //printf("%s also provided by %s\n", currheader->require[i]->name, file->provider[k]->name); - provided->numproviders++; - newprovider=malloc(sizeof(struct headerList*)*provided->numproviders); - for (j = 0; j < provided->numproviders-1; j++) { - newprovider[j]=provided->provider[j]; - } - newprovider[provided->numproviders-1] = file->provider[k]; - 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->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])) { + if (currheader->obsoleted || currheader->sourceheader->updatingparent) { + currheader = currheader->next; + continue; + } + // currheader->require.resolved = malloc(sizeof(struct providedList*)*currheader->requirecount); + for (i = 0; i < currheader->requirecount; i++) { + if (!strncmp("executable(",currheader->require[i]->name,11)) { + /* dynamic requirement for executable file */ + /*fprintf(stderr,"Warning: skipping unhandled requirement %s for package %s\n", + currheader->require[i]->name,currheader->name);*/ + currheader->require[i]->resolved=NULL; + } else if (strncmp("rpmlib(",currheader->require[i]->name,7) && + strncmp("debuginfo(build-id)",currheader->require[i]->name,20)) { + provided=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx], + currheader->require[i]->name,1,archidx); + if (provided->numproviders == 0) { + // check if require[i]->name requirement is met + scanheader = ct->headerlist[archidx]; + if ((currheader->require[i]->name)[0] == '/') { + /* requirement is a file, find who provides it */ + file=findOrCreateFileTreeEntry(&ct->filetree[archidx],currheader->require[i]->name, archidx); + if (file->numproviders > 0) { + scanheader=file->provider[0]; + provided->numproviders=file->numproviders; + provided->numbuildproviders=0; + provided->provider=file->provider; + provided->flags=0; + } else { + scanheader=NULL; + } + } else { + /* requirement is not a file, cross-check with provides */ + while (scanheader && !checkRequireWithProvides( + currheader->require[i]->name, scanheader)) + scanheader = scanheader->next; + if (scanheader) { + provided->numproviders=1; + provided->numbuildproviders=0; + provided->provider=malloc(sizeof(struct headerList*)); + provided->provider[0]=scanheader; + provided->flags=0; + } + } + if (!scanheader && incremental_mode) { + snprintf(warning,PATH_MAX,"%s(%s,%s): missing provider for %s", + currheader->name, + ct->arch[archidx], + ct->repository[currheader->altrepository]->tag, + currheader->require[i]->name); + fprintf(stderr,"Warning: %s\n",warning); + addWarning(currheader->sourceheader,warning); + } + } else { /* provided->numproviders > 0 */ + /* warn about provides only provided by older packages */ + k=0; + for (j = 0; j < provided->numproviders; j++) { + if (provided->provider[j]->sourceheader->updatingparent && + provided->provider[j]->sourceheader->updatingparent->firstchild[archidx] && /* skip if not built for arch */ + !currheader->obsoleted) k++; + } + if (k == provided->numproviders) { // all provides are from older packages + snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s which is only provided by older package(s):", + currheader->name, + currheader->arch, + ct->repository[currheader->altrepository]->tag, + provided->name); + for (j = 0; j < provided->numproviders; j++) { + snprintf(&warning[strlen(warning)], PATH_MAX - strlen(warning), " %s(%s,%s)", + provided->provider[j]->name, + provided->provider[j]->arch, + ct->repository[provided->provider[j]->altrepository]->tag); + addRebuild(provided->provider[j]->sourceheader,currheader->sourceheader,provided->provider[j]); + addWarning(provided->provider[j]->sourceheader,warning); + } + fprintf(stderr,"Warning: %s\n",warning); + } else { + /* warn about provides provided by obsoleted packages */ + k=0; + for (j = 0; j < provided->numproviders; j++) { + if (provided->provider[j]->obsoleted && + !provided->provider[j]->sourceheader->updatingparent && // don't fall in case above + !currheader->obsoleted) k++; + } + if (k == provided->numproviders) { // all provides are obsoleted + snprintf(warning, PATH_MAX, "%s(%s,%s) requires %s which is only provided by obsoleted package(s):", + currheader->name, + currheader->arch, + ct->repository[currheader->altrepository]->tag, + provided->name); + for (j = 0; j < provided->numproviders; j++) { + snprintf(&warning[strlen(warning)], PATH_MAX - strlen(warning), " %s(%s,%s)", + provided->provider[j]->name, + provided->provider[j]->arch, + ct->repository[provided->provider[j]->altrepository]->tag); + } + fprintf(stderr,"Warning: %s\n",warning); + addWarning(currheader->sourceheader,warning); + for (j = 0; j < provided->numproviders; j++) { + addWarning(provided->provider[j]->sourceheader,warning); + } + } + } + if ((currheader->require[i]->name)[0] == '/') { + /* when there is a Requires: /file/requirement add provide from file tree as well */ + file=findOrCreateFileTreeEntry(&ct->filetree[archidx],currheader->require[i]->name, archidx); + for (k = 0; k < file->numproviders; k++) { + for (j = 0, found = 0; j < provided->numproviders; j++) { + /* avoid duplicates */ + if (file->provider[k] == provided->provider[j]) { + found = 1; + break; + } + } + if (! found) { + //printf("%s also provided by %s\n", currheader->require[i]->name, file->provider[k]->name); + provided->numproviders++; + newprovider=malloc(sizeof(struct headerList*)*provided->numproviders); + for (j = 0; j < provided->numproviders-1; j++) { + newprovider[j]=provided->provider[j]; + } + newprovider[provided->numproviders-1] = file->provider[k]; + 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->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; - } - } - } /* 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); - } + } 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); + } + } + } + } /* for */ + } } - } - } - currheader->require[i]->resolved=provided; - } else { - currheader->require[i]->resolved=NULL; - } - } + } + currheader->require[i]->resolved=provided; + } else { + currheader->require[i]->resolved=NULL; + } /* if */ + } /* for currheader->requirecount */ // sort required list by first provider's name qsort((void *) &currheader->require[0], - currheader->requirecount, - sizeof(struct Require *), - compareRequiredList); + currheader->requirecount, + sizeof(struct Require *), + compareRequiredList); currheader = currheader->next; - } - logmsg(LOG_DEBUG,"resolveFirstLevelDependencies - done"); - return 0; + } + logmsg(LOG_DEBUG,"resolveFirstLevelDependencies - done"); + return 0; } static int