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 */
|
||||
int
|
||||
addToHeaderList(struct configTag *ct,
|
||||
int addToHeaderList(struct configTag *ct,
|
||||
const char *scanpath, /*int mode,*/
|
||||
const char *scantag,
|
||||
const char *altscanpath[ALT_REPS_MAX],
|
||||
const char *altscantag[ALT_REPS_MAX],
|
||||
int arch)
|
||||
{
|
||||
|
||||
/*#headerList **headerlist,
|
||||
# struct headerSourceList *headersourcelist,
|
||||
# struct providedList **firstprovided,
|
||||
*/
|
||||
|
||||
struct headerList *currheaderlist, *newheaderlist, *currbrother;
|
||||
struct providedList *provided;
|
||||
struct headerList ** newprovider;
|
||||
struct dirent **namelist, **altnamelist[ALT_REPS_MAX];
|
||||
Header h;
|
||||
char filepath[bufsize + 1], currname[bufsize + 1];
|
||||
char *filename=NULL;
|
||||
long i ,j , k, n, altn[ALT_REPS_MAX];
|
||||
int altrepository=0, obsoletecount, providecount, requirecount,
|
||||
filenamecount, dirnamecount;
|
||||
int_16 *fileflags;
|
||||
char **obsoletename, **obsoleteversion,
|
||||
**providename, **provideversion,
|
||||
**requirename, **requireversion,
|
||||
**basename, **dirname, **newversion,
|
||||
**fileusername, **filegroupname;
|
||||
const char* errstr;
|
||||
uint_32 *dirindex, *requireflags, *obsoleteflags, *provideflags;
|
||||
int arch) {
|
||||
struct headerList *currheaderlist, *newheaderlist, *currbrother;
|
||||
struct providedList *provided;
|
||||
struct headerList ** newprovider;
|
||||
struct dirent **namelist, **altnamelist[ALT_REPS_MAX];
|
||||
Header h;
|
||||
char filepath[bufsize + 1], currname[bufsize + 1];
|
||||
char *filename=NULL;
|
||||
long i ,j , k, n, altn[ALT_REPS_MAX];
|
||||
int altrepository=0, obsoletecount, providecount, requirecount,
|
||||
filenamecount, dirnamecount;
|
||||
int_16 *fileflags;
|
||||
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
|
||||
rpmts ts = rpmtsCreate();
|
||||
rpmts ts = rpmtsCreate();
|
||||
#else
|
||||
rpmts ts = NULL;
|
||||
rpmts ts = NULL;
|
||||
#endif
|
||||
|
||||
currheaderlist = ct->headerlist[arch];
|
||||
currheaderlist = ct->headerlist[arch];
|
||||
|
||||
n = scansdir(scanpath, &namelist, rpmselector, scanrpmnamecmp);
|
||||
|
||||
if (n < 0) {
|
||||
errstr = strerror(errno);
|
||||
logmsg(LOG_ERROR, "%s: cannot scan directory '%s' (%s)", scantag, scanpath, errstr);
|
||||
return 1;
|
||||
}
|
||||
logmsg(LOG_DEBUG, "%s scan directory is '%s'", scantag, scanpath);
|
||||
for (i = 0; i < ALT_REPS_MAX; i++) {
|
||||
if (altscanpath[i]) {
|
||||
altn[i] = scansdir(altscanpath[i], &altnamelist[i], rpmselector, scanrpmnamecmp);
|
||||
logmsg(LOG_DEBUG, "%s scan directory is '%s'", altscantag[i], altscanpath[i]);
|
||||
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)) {
|
||||
n = scansdir(scanpath, &namelist, rpmselector, scanrpmnamecmp);
|
||||
if (n < 0) {
|
||||
errstr = strerror(errno);
|
||||
logmsg(LOG_ERROR, "%s: cannot scan directory '%s' (%s)", scantag, scanpath, errstr);
|
||||
return 1;
|
||||
}
|
||||
logmsg(LOG_DEBUG, "%s scan directory is '%s'", scantag, scanpath);
|
||||
for (i = 0; i < ALT_REPS_MAX; i++) {
|
||||
if (altscanpath[i]) {
|
||||
altn[i] = scansdir(altscanpath[i], &altnamelist[i], rpmselector, scanrpmnamecmp);
|
||||
logmsg(LOG_DEBUG, "%s scan directory is '%s'", altscantag[i], altscanpath[i]);
|
||||
if (altn[i] < 0) {
|
||||
errstr = strerror(errno);
|
||||
logmsg(LOG_WARNING,
|
||||
"%s: unable to read header (%s); skipping.",filename, errstr);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
int cnt = 0, altcnt[ALT_REPS_MAX];
|
||||
for (i = 0; i < ALT_REPS_MAX; i++) {
|
||||
altcnt[i]=0;
|
||||
}
|
||||
|
||||
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);
|
||||
while (1) {
|
||||
/* 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 (!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,
|
||||
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);
|
||||
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->version,
|
||||
newheaderlist->release,
|
||||
altrepository);
|
||||
}
|
||||
}
|
||||
if (newheaderlist->sourceheader) {
|
||||
if (!newheaderlist->sourceheader->firstchild[arch]) {
|
||||
newheaderlist->sourceheader->firstchild[arch] = newheaderlist;
|
||||
} else {
|
||||
currbrother =
|
||||
newheaderlist->sourceheader->firstchild[arch];
|
||||
while (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newheaderlist->sourceheader) {
|
||||
if (!newheaderlist->sourceheader->firstchild[arch]) {
|
||||
newheaderlist->sourceheader->firstchild[arch] = newheaderlist;
|
||||
} else {
|
||||
currbrother =
|
||||
newheaderlist->sourceheader->firstchild[arch];
|
||||
while (currbrother->nextbrother) {
|
||||
currbrother = currbrother->nextbrother;
|
||||
}
|
||||
}
|
||||
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
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
rpmtsFree(ts);
|
||||
rpmtsFree(ts);
|
||||
#endif
|
||||
free(namelist);
|
||||
createProvidedListIndex((struct providedList **)&(ct->providedlist_idx[arch]), arch);
|
||||
return 0;
|
||||
free(namelist);
|
||||
createProvidedListIndex((struct providedList **)&(ct->providedlist_idx[arch]), arch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
@ -1552,6 +1526,5 @@ generateHeaderList(struct configTag* ct, int arch, int incremental)
|
||||
logmsg(LOG_ERROR,"Error scanning RPMs repository");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user