Code reformatting
This commit is contained in:
parent
9a546f52b9
commit
4f566ceec3
593
src/headerlist.c
593
src/headerlist.c
@ -1183,335 +1183,309 @@ generateSourceHeaderList(struct configTag *ct, int mode, int incremental)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads all headers and generates a structure based on struct headerList */
|
* Reads all headers and generates a structure based on struct headerList */
|
||||||
int
|
int addToHeaderList(struct configTag *ct,
|
||||||
addToHeaderList(struct configTag *ct,
|
|
||||||
const char *scanpath, /*int mode,*/
|
const char *scanpath, /*int mode,*/
|
||||||
const char *scantag,
|
const char *scantag,
|
||||||
const char *altscanpath[ALT_REPS_MAX],
|
const char *altscanpath[ALT_REPS_MAX],
|
||||||
const char *altscantag[ALT_REPS_MAX],
|
const char *altscantag[ALT_REPS_MAX],
|
||||||
int arch)
|
int arch) {
|
||||||
{
|
struct headerList *currheaderlist, *newheaderlist, *currbrother;
|
||||||
|
struct providedList *provided;
|
||||||
/*#headerList **headerlist,
|
struct headerList ** newprovider;
|
||||||
# struct headerSourceList *headersourcelist,
|
struct dirent **namelist, **altnamelist[ALT_REPS_MAX];
|
||||||
# struct providedList **firstprovided,
|
Header h;
|
||||||
*/
|
char filepath[bufsize + 1], currname[bufsize + 1];
|
||||||
|
char *filename=NULL;
|
||||||
struct headerList *currheaderlist, *newheaderlist, *currbrother;
|
long i ,j , k, n, altn[ALT_REPS_MAX];
|
||||||
struct providedList *provided;
|
int altrepository=0, obsoletecount, providecount, requirecount,
|
||||||
struct headerList ** newprovider;
|
filenamecount, dirnamecount;
|
||||||
struct dirent **namelist, **altnamelist[ALT_REPS_MAX];
|
int_16 *fileflags;
|
||||||
Header h;
|
char **obsoletename, **obsoleteversion,
|
||||||
char filepath[bufsize + 1], currname[bufsize + 1];
|
**providename, **provideversion,
|
||||||
char *filename=NULL;
|
**requirename, **requireversion,
|
||||||
long i ,j , k, n, altn[ALT_REPS_MAX];
|
**basename, **dirname, **newversion,
|
||||||
int altrepository=0, obsoletecount, providecount, requirecount,
|
**fileusername, **filegroupname;
|
||||||
filenamecount, dirnamecount;
|
const char* errstr;
|
||||||
int_16 *fileflags;
|
uint_32 *dirindex, *requireflags, *obsoleteflags, *provideflags;
|
||||||
char **obsoletename, **obsoleteversion,
|
|
||||||
**providename, **provideversion,
|
|
||||||
**requirename, **requireversion,
|
|
||||||
**basename, **dirname, **newversion,
|
|
||||||
**fileusername, **filegroupname;
|
|
||||||
const char* errstr;
|
|
||||||
uint_32 *dirindex, *requireflags, *obsoleteflags, *provideflags;
|
|
||||||
#if RPM_VERSION >= 0x050000
|
#if RPM_VERSION >= 0x050000
|
||||||
rpmts ts = rpmtsCreate();
|
rpmts ts = rpmtsCreate();
|
||||||
#else
|
#else
|
||||||
rpmts ts = NULL;
|
rpmts ts = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
currheaderlist = ct->headerlist[arch];
|
currheaderlist = ct->headerlist[arch];
|
||||||
|
|
||||||
n = scansdir(scanpath, &namelist, rpmselector, scanrpmnamecmp);
|
n = scansdir(scanpath, &namelist, rpmselector, scanrpmnamecmp);
|
||||||
|
if (n < 0) {
|
||||||
if (n < 0) {
|
errstr = strerror(errno);
|
||||||
errstr = strerror(errno);
|
logmsg(LOG_ERROR, "%s: cannot scan directory '%s' (%s)", scantag, scanpath, errstr);
|
||||||
logmsg(LOG_ERROR, "%s: cannot scan directory '%s' (%s)", scantag, scanpath, errstr);
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
logmsg(LOG_DEBUG, "%s scan directory is '%s'", scantag, scanpath);
|
||||||
logmsg(LOG_DEBUG, "%s scan directory is '%s'", scantag, scanpath);
|
for (i = 0; i < ALT_REPS_MAX; i++) {
|
||||||
for (i = 0; i < ALT_REPS_MAX; i++) {
|
if (altscanpath[i]) {
|
||||||
if (altscanpath[i]) {
|
altn[i] = scansdir(altscanpath[i], &altnamelist[i], rpmselector, scanrpmnamecmp);
|
||||||
altn[i] = scansdir(altscanpath[i], &altnamelist[i], rpmselector, scanrpmnamecmp);
|
logmsg(LOG_DEBUG, "%s scan directory is '%s'", altscantag[i], altscanpath[i]);
|
||||||
logmsg(LOG_DEBUG, "%s scan directory is '%s'", altscantag[i], altscanpath[i]);
|
if (altn[i] < 0) {
|
||||||
if (altn[i] < 0) {
|
|
||||||
errstr = strerror(errno);
|
|
||||||
logmsg(LOG_ERROR, "%s: cannot scan directory '%s' (%s)", altscantag[i], altscanpath[i], errstr);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else { break; }
|
|
||||||
}
|
|
||||||
if (i < ALT_REPS_MAX) {
|
|
||||||
altnamelist[i]=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int cnt = 0, altcnt[ALT_REPS_MAX];
|
|
||||||
for (i = 0; i < ALT_REPS_MAX; i++) {
|
|
||||||
altcnt[i]=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
/* if (cnt>=n) { break; }
|
|
||||||
for (i = 0; i < ALT_REPS_MAX; i++) {
|
|
||||||
if altcnt[i] >= altn[i]
|
|
||||||
}*/
|
|
||||||
/* check for duplicates in main repository */
|
|
||||||
|
|
||||||
if ((cnt < n - 1) &&
|
|
||||||
(!rpmnamecmp(namelist[cnt]->d_name,namelist[cnt+1]->d_name,0))) {
|
|
||||||
logmsg(LOG_WARNING, "%s: duplicated RPM package in %s repository (skipped)",namelist[cnt]->d_name, scantag);
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
/* find next package in all repositories */
|
|
||||||
if (cnt < n) {
|
|
||||||
strncpy(currname, namelist[cnt]->d_name, bufsize);
|
|
||||||
} else {
|
|
||||||
currname[0] = '\0';
|
|
||||||
}
|
|
||||||
for (i = 0; i < ALT_REPS_MAX; i++) {
|
|
||||||
/* scan alternate repositories to find any package which comes first according to name sorting */
|
|
||||||
if (altscanpath[i] && (altcnt[i] < altn[i]) &&
|
|
||||||
((rpmnamecmp(currname, altnamelist[i][altcnt[i]]->d_name,0) >= 0) || (currname[0] == '\0'))) {
|
|
||||||
strncpy(currname, altnamelist[i][altcnt[i]]->d_name,bufsize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cnt < n && (rpmnamecmp(currname, namelist[cnt]->d_name, 0) == 0)) {
|
|
||||||
/* selected package exists in base repository */
|
|
||||||
memcpy(filepath, scanpath, strlen(scanpath) + 1);
|
|
||||||
filename=&filepath[strlen(scanpath)];
|
|
||||||
strncpy(filename, namelist[cnt]->d_name,bufsize-strlen(scanpath));
|
|
||||||
altrepository=0;
|
|
||||||
cnt++;
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < ALT_REPS_MAX; i++) {
|
|
||||||
if (altscanpath[i] && (altcnt[i] < altn[i]) &&
|
|
||||||
(strncmp(currname, altnamelist[i][altcnt[i]]->d_name, bufsize) == 0)) {
|
|
||||||
/* selected package exists in this repository */
|
|
||||||
memcpy(filepath, altscanpath[i], strlen(altscanpath[i]) + 1);
|
|
||||||
filename=&filepath[strlen(altscanpath[i])];
|
|
||||||
strncpy(filename, (altnamelist[i])[altcnt[i]]->d_name, bufsize-strlen(altscanpath[i]));
|
|
||||||
altrepository=i+1;
|
|
||||||
altcnt[i]++;
|
|
||||||
/* check for duplicates in alternate repository */
|
|
||||||
if ((altcnt[i] < altn[i] - 1) &&
|
|
||||||
(!rpmnamecmp(altnamelist[i][altcnt[i]]->d_name,altnamelist[i][altcnt[i]+1]->d_name,0))) {
|
|
||||||
if (i == ct->repository_level-1) {
|
|
||||||
logmsg(LOG_WARNING, "%s: duplicated RPM package (skipped)",
|
|
||||||
altnamelist[i][altcnt[i]]->d_name, altscantag[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* break while loop when no more packages are found */
|
|
||||||
if (currname[0] == '\0') { break; }
|
|
||||||
/* process package */
|
|
||||||
logmsg(LOG_DEBUG, "getting header for %s", filepath);
|
|
||||||
|
|
||||||
if (getHeader(&ts, filepath, &h)) {
|
|
||||||
errstr = strerror(errno);
|
errstr = strerror(errno);
|
||||||
logmsg(LOG_WARNING,
|
logmsg(LOG_ERROR, "%s: cannot scan directory '%s' (%s)", altscantag[i], altscanpath[i], errstr);
|
||||||
"%s: unable to read header (%s); skipping.",filename, errstr);
|
return 1;
|
||||||
} else {
|
}
|
||||||
|
} else { break; }
|
||||||
|
}
|
||||||
|
if (i < ALT_REPS_MAX) {
|
||||||
|
altnamelist[i]=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
getPackageObsoletes(h, &obsoletename, &obsoleteflags,
|
int cnt = 0, altcnt[ALT_REPS_MAX];
|
||||||
&obsoleteversion, &obsoletecount);
|
for (i = 0; i < ALT_REPS_MAX; i++) {
|
||||||
getPackageProvides(h, &providename, &provideflags,
|
altcnt[i]=0;
|
||||||
&provideversion, &providecount);
|
}
|
||||||
getPackageRequires(h, &requirename, &requireflags,
|
|
||||||
&requireversion, &requirecount);
|
|
||||||
getPackageFiles(h, &dirindex, &dirname, &dirnamecount,
|
|
||||||
&basename, &filenamecount,
|
|
||||||
&fileusername, &filegroupname, &fileflags);
|
|
||||||
|
|
||||||
newheaderlist = malloc(sizeof(struct headerList));
|
while (1) {
|
||||||
if (newheaderlist == NULL) {
|
/* check for duplicates in main repository */
|
||||||
logmsg(LOG_ERROR,"header in file %s is corrupted; aborting.\n",filepath);
|
if ((cnt < n - 1) &&
|
||||||
return 1;
|
(!rpmnamecmp(namelist[cnt]->d_name,namelist[cnt+1]->d_name,0))) {
|
||||||
}
|
logmsg(LOG_WARNING, "%s: duplicated RPM package in %s repository (skipped)",namelist[cnt]->d_name, scantag);
|
||||||
memset(newheaderlist, 0, sizeof(struct headerList));
|
cnt++;
|
||||||
getPackageInfoIntoHeaderList(h, newheaderlist);
|
}
|
||||||
|
/* find next package in all repositories */
|
||||||
|
if (cnt < n) {
|
||||||
|
strncpy(currname, namelist[cnt]->d_name, bufsize);
|
||||||
|
} else {
|
||||||
|
currname[0] = '\0';
|
||||||
|
}
|
||||||
|
for (i = 0; i < ALT_REPS_MAX; i++) {
|
||||||
|
/* scan alternate repositories to find any package which comes first according to name sorting */
|
||||||
|
if (altscanpath[i] && (altcnt[i] < altn[i]) &&
|
||||||
|
((rpmnamecmp(currname, altnamelist[i][altcnt[i]]->d_name,0) >= 0) || (currname[0] == '\0'))) {
|
||||||
|
strncpy(currname, altnamelist[i][altcnt[i]]->d_name,bufsize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!newheaderlist->sourcename) {
|
if (cnt < n && (rpmnamecmp(currname, namelist[cnt]->d_name, 0) == 0)) {
|
||||||
logmsg(LOG_WARNING,
|
/* selected package exists in base repository */
|
||||||
"sourcename undefined in RPM file %s, it might be a source RPM with wrong filename; skipping package.",
|
memcpy(filepath, scanpath, strlen(scanpath) + 1);
|
||||||
filepath);
|
filename=&filepath[strlen(scanpath)];
|
||||||
newheaderlist->sourceheader = NULL;
|
strncpy(filename, namelist[cnt]->d_name,bufsize-strlen(scanpath));
|
||||||
(void) headerFree(h);
|
altrepository=0;
|
||||||
free(newheaderlist);
|
cnt++;
|
||||||
continue;
|
} else {
|
||||||
} else {
|
for (i = 0; i < ALT_REPS_MAX; i++) {
|
||||||
if (getPackageNameFromFile(newheaderlist->sourcename)) {
|
if (altscanpath[i] && (altcnt[i] < altn[i]) &&
|
||||||
logmsg(LOG_WARNING,
|
(strncmp(currname, altnamelist[i][altcnt[i]]->d_name, bufsize) == 0)) {
|
||||||
"file %s doesn't have a standard format; skipping package.");
|
/* selected package exists in this repository */
|
||||||
newheaderlist->sourceheader = NULL;
|
memcpy(filepath, altscanpath[i], strlen(altscanpath[i]) + 1);
|
||||||
(void) headerFree(h);
|
filename=&filepath[strlen(altscanpath[i])];
|
||||||
free(newheaderlist);
|
strncpy(filename, (altnamelist[i])[altcnt[i]]->d_name, bufsize-strlen(altscanpath[i]));
|
||||||
continue;
|
altrepository=i+1;
|
||||||
} else {
|
altcnt[i]++;
|
||||||
newheaderlist->sourceheader =
|
/* check for duplicates in alternate repository */
|
||||||
findSourcePackage(ct->headersourcelist,
|
if ((altcnt[i] < altn[i] - 1) &&
|
||||||
|
(!rpmnamecmp(altnamelist[i][altcnt[i]]->d_name,altnamelist[i][altcnt[i]+1]->d_name,0))) {
|
||||||
|
if (i == ct->repository_level-1) {
|
||||||
|
logmsg(LOG_WARNING, "%s: duplicated RPM package (skipped)",
|
||||||
|
altnamelist[i][altcnt[i]]->d_name, altscantag[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* break while loop when no more packages are found */
|
||||||
|
if (currname[0] == '\0') { break; }
|
||||||
|
/* process package */
|
||||||
|
logmsg(LOG_DEBUG, "getting header for %s", filepath);
|
||||||
|
|
||||||
|
if (getHeader(&ts, filepath, &h)) {
|
||||||
|
errstr = strerror(errno);
|
||||||
|
logmsg(LOG_WARNING,
|
||||||
|
"%s: unable to read header (%s); skipping.",filename, errstr);
|
||||||
|
} else {
|
||||||
|
getPackageObsoletes(h, &obsoletename, &obsoleteflags,
|
||||||
|
&obsoleteversion, &obsoletecount);
|
||||||
|
getPackageProvides(h, &providename, &provideflags,
|
||||||
|
&provideversion, &providecount);
|
||||||
|
getPackageRequires(h, &requirename, &requireflags,
|
||||||
|
&requireversion, &requirecount);
|
||||||
|
getPackageFiles(h, &dirindex, &dirname, &dirnamecount,
|
||||||
|
&basename, &filenamecount,
|
||||||
|
&fileusername, &filegroupname, &fileflags);
|
||||||
|
|
||||||
|
newheaderlist = malloc(sizeof(struct headerList));
|
||||||
|
if (newheaderlist == NULL) {
|
||||||
|
logmsg(LOG_ERROR,"header in file %s is corrupted; aborting.\n",filepath);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
memset(newheaderlist, 0, sizeof(struct headerList));
|
||||||
|
getPackageInfoIntoHeaderList(h, newheaderlist);
|
||||||
|
|
||||||
|
if (!newheaderlist->sourcename) {
|
||||||
|
logmsg(LOG_WARNING,
|
||||||
|
"sourcename undefined in RPM file %s, it might be a source RPM with wrong filename; skipping package.",
|
||||||
|
filepath);
|
||||||
|
newheaderlist->sourceheader = NULL;
|
||||||
|
(void) headerFree(h);
|
||||||
|
free(newheaderlist);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
if (getPackageNameFromFile(newheaderlist->sourcename)) {
|
||||||
|
logmsg(LOG_WARNING,
|
||||||
|
"file %s doesn't have a standard format; skipping package.");
|
||||||
|
newheaderlist->sourceheader = NULL;
|
||||||
|
(void) headerFree(h);
|
||||||
|
free(newheaderlist);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
newheaderlist->sourceheader =
|
||||||
|
findSourcePackage(ct->headersourcelist,
|
||||||
newheaderlist->sourcename,
|
newheaderlist->sourcename,
|
||||||
newheaderlist->version,
|
newheaderlist->version,
|
||||||
newheaderlist->release,
|
newheaderlist->release,
|
||||||
altrepository);
|
altrepository);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newheaderlist->sourceheader) {
|
if (newheaderlist->sourceheader) {
|
||||||
if (!newheaderlist->sourceheader->firstchild[arch]) {
|
if (!newheaderlist->sourceheader->firstchild[arch]) {
|
||||||
newheaderlist->sourceheader->firstchild[arch] = newheaderlist;
|
newheaderlist->sourceheader->firstchild[arch] = newheaderlist;
|
||||||
} else {
|
} else {
|
||||||
currbrother =
|
currbrother =
|
||||||
newheaderlist->sourceheader->firstchild[arch];
|
newheaderlist->sourceheader->firstchild[arch];
|
||||||
while (currbrother->nextbrother) {
|
while (currbrother->nextbrother) {
|
||||||
currbrother = currbrother->nextbrother;
|
currbrother = currbrother->nextbrother;
|
||||||
}
|
|
||||||
currbrother->nextbrother = newheaderlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
newheaderlist->recursed = 0;
|
|
||||||
|
|
||||||
if (currheaderlist) {
|
|
||||||
currheaderlist->next = newheaderlist;
|
|
||||||
}
|
|
||||||
currheaderlist = newheaderlist;
|
|
||||||
|
|
||||||
if (!ct->headerlist[arch]) {
|
|
||||||
/* set first pointer of the list */
|
|
||||||
ct->headerlist[arch] = newheaderlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (newheaderlist->sourcename) /* missing source header */ {
|
|
||||||
|
|
||||||
if ((!newheaderlist->sourceheader) ||
|
|
||||||
(newheaderlist->sourceheader->altrepository) <= altrepository)
|
|
||||||
{
|
|
||||||
logmsg(LOG_WARNING,"%s(%s,%s): missing SRPM %s-%s-%s; skipping.",
|
|
||||||
newheaderlist->name,
|
|
||||||
ct->arch[arch],
|
|
||||||
ct->repository[altrepository]->tag,
|
|
||||||
newheaderlist->sourcename,
|
|
||||||
newheaderlist->version, newheaderlist->release);
|
|
||||||
(void) headerFree(h);
|
|
||||||
free(newheaderlist);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} // if newheaderlist->sourceheader
|
|
||||||
|
|
||||||
newheaderlist->provided = malloc(sizeof(struct providedList*)*providecount);
|
|
||||||
for (i=0; i < providecount; i++) {
|
|
||||||
provided = findOrCreateProvidedListEntry((struct providedList **) &(ct->providedlist_idx[arch]),
|
|
||||||
providename[i],1,arch);
|
|
||||||
newheaderlist->provided[i]=provided;
|
|
||||||
if (provided && (provided->numproviders == 0)) {
|
|
||||||
provided->flags=provideflags[i];
|
|
||||||
provided->numproviders++;
|
|
||||||
provided->provider=malloc(sizeof(struct headerList*));
|
|
||||||
provided->provider[0]=newheaderlist;
|
|
||||||
provided->version=malloc(sizeof(char *));
|
|
||||||
provided->version[0]=strdup(provideversion[i]);
|
|
||||||
} else if (provided && (provided->numproviders > 0)) {
|
|
||||||
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] = newheaderlist;
|
|
||||||
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(provideversion[i]);
|
|
||||||
free(provided->version);
|
|
||||||
provided->version=newversion;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
fprintf(stderr,"%s has %d providers but is ignored\n",provided->name,provided->numproviders);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
newheaderlist->providename = providename;
|
|
||||||
newheaderlist->provideflags = provideflags;
|
|
||||||
newheaderlist->provideversion = provideversion;
|
|
||||||
newheaderlist->providecount = providecount;
|
|
||||||
|
|
||||||
newheaderlist->obsoletename = obsoletename;
|
|
||||||
newheaderlist->obsoleteflags = obsoleteflags;
|
|
||||||
newheaderlist->obsoleteversion = obsoleteversion;
|
|
||||||
newheaderlist->obsoletecount = obsoletecount;
|
|
||||||
|
|
||||||
newheaderlist->altrepository = altrepository;
|
|
||||||
|
|
||||||
newheaderlist->require = malloc(requirecount * sizeof(struct Require *));
|
|
||||||
for (j=0; j < requirecount; j++) {
|
|
||||||
newheaderlist->require[j] = malloc(sizeof(struct Require));
|
|
||||||
newheaderlist->require[j]->name = requirename[j];
|
|
||||||
newheaderlist->require[j]->flags = requireflags[j];
|
|
||||||
newheaderlist->require[j]->version = requireversion[j];
|
|
||||||
newheaderlist->require[j]->resolved = NULL;
|
|
||||||
}
|
|
||||||
newheaderlist->requirecount = requirecount;
|
|
||||||
|
|
||||||
newheaderlist->file =
|
|
||||||
malloc(sizeof(struct fileTree*) * filenamecount);
|
|
||||||
newheaderlist->fileflags =
|
|
||||||
malloc(sizeof(int_16 *) * filenamecount);
|
|
||||||
newheaderlist->fileuser =
|
|
||||||
malloc(sizeof(struct fileUserList *) * filenamecount);
|
|
||||||
newheaderlist->filegroup =
|
|
||||||
malloc(sizeof(char *) * filenamecount);
|
|
||||||
for (j=0; j<filenamecount; j++) {
|
|
||||||
snprintf(filename,bufsize,"%s%s",dirname[dirindex[j]],basename[j]);
|
|
||||||
newheaderlist->file[j] = findOrCreateFileTreeEntry(&ct->filetree[arch], filename, arch);
|
|
||||||
newheaderlist->fileflags[j] = fileflags[j];
|
|
||||||
newheaderlist->fileuser[j] = findOrCreateFileUserListEntry(&ct->fileuserlist[arch], fileusername[j], arch);
|
|
||||||
free(fileusername[j]);
|
|
||||||
newheaderlist->filegroup[j] = findOrCreateFileGroupListEntry(&ct->filegrouplist[arch], filegroupname[j], arch);
|
|
||||||
free(filegroupname[j]);
|
|
||||||
if (newheaderlist->file[j]->numproviders == 0) {
|
|
||||||
newheaderlist->file[j]->numproviders++;
|
|
||||||
newheaderlist->file[j]->provider=malloc(sizeof(struct headerList*));
|
|
||||||
newheaderlist->file[j]->provider[0]=newheaderlist;
|
|
||||||
} else {
|
|
||||||
/* check if the package is already providing it... */
|
|
||||||
for (k = 0; k < newheaderlist->file[j]->numproviders; k++) {
|
|
||||||
if (newheaderlist->file[j]->provider[k] == newheaderlist)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if not add to the list of providers */
|
|
||||||
if (k == newheaderlist->file[j]->numproviders) {
|
|
||||||
newheaderlist->file[j]->numproviders++;
|
|
||||||
newprovider=malloc(sizeof(struct headerList*)*newheaderlist->file[j]->numproviders);
|
|
||||||
for (k = 0; k < newheaderlist->file[j]->numproviders-1; k++) {
|
|
||||||
newprovider[k]=newheaderlist->file[j]->provider[k];
|
|
||||||
}
|
|
||||||
newprovider[newheaderlist->file[j]->numproviders-1] = newheaderlist;
|
|
||||||
free(newheaderlist->file[j]->provider);
|
|
||||||
newheaderlist->file[j]->provider=newprovider;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
currbrother->nextbrother = newheaderlist;
|
||||||
newheaderlist->filenamecount = filenamecount;
|
}
|
||||||
(void) headerFree(h);
|
newheaderlist->recursed = 0;
|
||||||
} // if getHeader()
|
if (currheaderlist) {
|
||||||
if (altrepository > 0) {
|
currheaderlist->next = newheaderlist;
|
||||||
free(altnamelist[altrepository-1][altcnt[altrepository-1]-1]); }
|
}
|
||||||
else free(namelist[cnt-1]);
|
currheaderlist = newheaderlist;
|
||||||
} // main while
|
|
||||||
|
if (!ct->headerlist[arch]) {
|
||||||
|
/* set first pointer of the list */
|
||||||
|
ct->headerlist[arch] = newheaderlist;
|
||||||
|
}
|
||||||
|
} else if (newheaderlist->sourcename) /* missing source header */ {
|
||||||
|
if ((!newheaderlist->sourceheader) ||
|
||||||
|
(newheaderlist->sourceheader->altrepository) <= altrepository) {
|
||||||
|
logmsg(LOG_WARNING,"%s(%s,%s): missing SRPM %s-%s-%s; skipping.",
|
||||||
|
newheaderlist->name,
|
||||||
|
ct->arch[arch],
|
||||||
|
ct->repository[altrepository]->tag,
|
||||||
|
newheaderlist->sourcename,
|
||||||
|
newheaderlist->version, newheaderlist->release);
|
||||||
|
(void) headerFree(h);
|
||||||
|
free(newheaderlist);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} // if newheaderlist->sourceheader
|
||||||
|
|
||||||
|
newheaderlist->provided = malloc(sizeof(struct providedList*)*providecount);
|
||||||
|
for (i=0; i < providecount; i++) {
|
||||||
|
provided = findOrCreateProvidedListEntry(
|
||||||
|
(struct providedList **) &(ct->providedlist_idx[arch]),
|
||||||
|
providename[i],1,arch);
|
||||||
|
newheaderlist->provided[i]=provided;
|
||||||
|
if (provided && (provided->numproviders == 0)) {
|
||||||
|
provided->flags=provideflags[i];
|
||||||
|
provided->numproviders++;
|
||||||
|
provided->provider=malloc(sizeof(struct headerList*));
|
||||||
|
provided->provider[0]=newheaderlist;
|
||||||
|
provided->version=malloc(sizeof(char *));
|
||||||
|
provided->version[0]=strdup(provideversion[i]);
|
||||||
|
} else if (provided && (provided->numproviders > 0)) {
|
||||||
|
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] = newheaderlist;
|
||||||
|
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(provideversion[i]);
|
||||||
|
free(provided->version);
|
||||||
|
provided->version=newversion;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr,"%s has %d providers but is ignored\n",provided->name,provided->numproviders);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newheaderlist->providename = providename;
|
||||||
|
newheaderlist->provideflags = provideflags;
|
||||||
|
newheaderlist->provideversion = provideversion;
|
||||||
|
newheaderlist->providecount = providecount;
|
||||||
|
newheaderlist->obsoletename = obsoletename;
|
||||||
|
newheaderlist->obsoleteflags = obsoleteflags;
|
||||||
|
newheaderlist->obsoleteversion = obsoleteversion;
|
||||||
|
newheaderlist->obsoletecount = obsoletecount;
|
||||||
|
newheaderlist->altrepository = altrepository;
|
||||||
|
newheaderlist->require = malloc(requirecount * sizeof(struct Require *));
|
||||||
|
for (j=0; j < requirecount; j++) {
|
||||||
|
newheaderlist->require[j] = malloc(sizeof(struct Require));
|
||||||
|
newheaderlist->require[j]->name = requirename[j];
|
||||||
|
newheaderlist->require[j]->flags = requireflags[j];
|
||||||
|
newheaderlist->require[j]->version = requireversion[j];
|
||||||
|
newheaderlist->require[j]->resolved = NULL;
|
||||||
|
}
|
||||||
|
newheaderlist->requirecount = requirecount;
|
||||||
|
newheaderlist->file =
|
||||||
|
malloc(sizeof(struct fileTree*) * filenamecount);
|
||||||
|
newheaderlist->fileflags =
|
||||||
|
malloc(sizeof(int_16 *) * filenamecount);
|
||||||
|
newheaderlist->fileuser =
|
||||||
|
malloc(sizeof(struct fileUserList *) * filenamecount);
|
||||||
|
newheaderlist->filegroup =
|
||||||
|
malloc(sizeof(char *) * filenamecount);
|
||||||
|
for (j=0; j<filenamecount; j++) {
|
||||||
|
snprintf(filename,bufsize,"%s%s",dirname[dirindex[j]],basename[j]);
|
||||||
|
newheaderlist->file[j] = findOrCreateFileTreeEntry(&ct->filetree[arch], filename, arch);
|
||||||
|
newheaderlist->fileflags[j] = fileflags[j];
|
||||||
|
newheaderlist->fileuser[j] = findOrCreateFileUserListEntry(&ct->fileuserlist[arch], fileusername[j], arch);
|
||||||
|
free(fileusername[j]);
|
||||||
|
newheaderlist->filegroup[j] = findOrCreateFileGroupListEntry(&ct->filegrouplist[arch], filegroupname[j], arch);
|
||||||
|
free(filegroupname[j]);
|
||||||
|
if (newheaderlist->file[j]->numproviders == 0) {
|
||||||
|
newheaderlist->file[j]->numproviders++;
|
||||||
|
newheaderlist->file[j]->provider=malloc(sizeof(struct headerList*));
|
||||||
|
newheaderlist->file[j]->provider[0]=newheaderlist;
|
||||||
|
} else {
|
||||||
|
/* check if the package is already providing it... */
|
||||||
|
for (k = 0; k < newheaderlist->file[j]->numproviders; k++) {
|
||||||
|
if (newheaderlist->file[j]->provider[k] == newheaderlist)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* if not add to the list of providers */
|
||||||
|
if (k == newheaderlist->file[j]->numproviders) {
|
||||||
|
newheaderlist->file[j]->numproviders++;
|
||||||
|
newprovider=malloc(
|
||||||
|
sizeof(struct headerList*)*newheaderlist->file[j]->numproviders);
|
||||||
|
for (k = 0; k < newheaderlist->file[j]->numproviders-1; k++) {
|
||||||
|
newprovider[k]=newheaderlist->file[j]->provider[k];
|
||||||
|
}
|
||||||
|
newprovider[newheaderlist->file[j]->numproviders-1] = newheaderlist;
|
||||||
|
free(newheaderlist->file[j]->provider);
|
||||||
|
newheaderlist->file[j]->provider=newprovider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newheaderlist->filenamecount = filenamecount;
|
||||||
|
(void) headerFree(h);
|
||||||
|
} // if getHeader()
|
||||||
|
if (altrepository > 0)
|
||||||
|
free(altnamelist[altrepository-1][altcnt[altrepository-1]-1]);
|
||||||
|
else free(namelist[cnt-1]);
|
||||||
|
} // main while
|
||||||
#if RPM_VERSION >= 0x050000
|
#if RPM_VERSION >= 0x050000
|
||||||
rpmtsFree(ts);
|
rpmtsFree(ts);
|
||||||
#endif
|
#endif
|
||||||
free(namelist);
|
free(namelist);
|
||||||
createProvidedListIndex((struct providedList **)&(ct->providedlist_idx[arch]), arch);
|
createProvidedListIndex((struct providedList **)&(ct->providedlist_idx[arch]), arch);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -1552,6 +1526,5 @@ generateHeaderList(struct configTag* ct, int arch, int incremental)
|
|||||||
logmsg(LOG_ERROR,"Error scanning RPMs repository");
|
logmsg(LOG_ERROR,"Error scanning RPMs repository");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user