Added per-arch multithreaded support for scanning binary packages
This commit is contained in:
parent
67b53d8af7
commit
babfe854ea
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include
|
AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include
|
||||||
|
|
||||||
LDFLAGS += $(SQLITE_LIBS)
|
LDFLAGS += $(SQLITE_LIBS) -lpthread
|
||||||
|
|
||||||
bin_PROGRAMS = distromatic
|
bin_PROGRAMS = distromatic
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#if HAVE_UNISTD_H
|
#if HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
@ -121,6 +122,12 @@ PROGRAMNAME " version " PROGRAMVERSION,
|
|||||||
(char *)0
|
(char *)0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
unsigned int quietmode = 0;
|
||||||
|
unsigned int genheader_mode = GENHEADER_BASE + GENHEADER_REQUIREMENTS;
|
||||||
|
unsigned int mode = 0;
|
||||||
|
unsigned int recursive_mode = 0;
|
||||||
|
unsigned int obsolete_packages = 1;
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
static const char *freelicense[] = {
|
static const char *freelicense[] = {
|
||||||
"This is free software; see the source for copying conditions. There is NO",
|
"This is free software; see the source for copying conditions. There is NO",
|
||||||
@ -324,7 +331,7 @@ handleObsoletedPackages(struct configTag *ct, int archidx)
|
|||||||
while (currheader) {
|
while (currheader) {
|
||||||
for (j = 0; j < currheader->obsoletecount; j++) {
|
for (j = 0; j < currheader->obsoletecount; j++) {
|
||||||
prov=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx],
|
prov=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx],
|
||||||
currheader->obsoletename[j],0);
|
currheader->obsoletename[j],0,archidx);
|
||||||
if (prov) {
|
if (prov) {
|
||||||
for (i = 0; i < prov->numproviders; i++) {
|
for (i = 0; i < prov->numproviders; i++) {
|
||||||
if (strcmp(currheader->name,prov->provider[i]->name)) {
|
if (strcmp(currheader->name,prov->provider[i]->name)) {
|
||||||
@ -431,7 +438,7 @@ resolveFirstLevelDependencies(struct configTag *ct, int archidx)
|
|||||||
currheader->require[i]->resolved=NULL;
|
currheader->require[i]->resolved=NULL;
|
||||||
} else if (strncmp("rpmlib(",currheader->require[i]->name,7) != 0) {
|
} else if (strncmp("rpmlib(",currheader->require[i]->name,7) != 0) {
|
||||||
provided=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx],
|
provided=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx],
|
||||||
currheader->require[i]->name,1);
|
currheader->require[i]->name,1,archidx);
|
||||||
if (provided->numproviders == 0) {
|
if (provided->numproviders == 0) {
|
||||||
// check if require[i]->name requirement is met
|
// check if require[i]->name requirement is met
|
||||||
scanheader = ct->headerlist[archidx];
|
scanheader = ct->headerlist[archidx];
|
||||||
@ -635,7 +642,7 @@ resolveFirstLevelSourceDependencies(struct configTag *ct, int archidx)
|
|||||||
}*/
|
}*/
|
||||||
if (strncmp("rpmlib(",currsourceheader->require[i]->name,7) != 0) {
|
if (strncmp("rpmlib(",currsourceheader->require[i]->name,7) != 0) {
|
||||||
provided=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx],
|
provided=findOrCreateProvidedListEntry((struct providedList**) &ct->providedlist_idx[archidx],
|
||||||
currsourceheader->require[i]->name,1);
|
currsourceheader->require[i]->name,1,archidx);
|
||||||
if (provided->numbuildproviders == 0) {
|
if (provided->numbuildproviders == 0) {
|
||||||
// check if require[i]->name requirement is met
|
// check if require[i]->name requirement is met
|
||||||
scanheader = ct->headerlist[archidx];
|
scanheader = ct->headerlist[archidx];
|
||||||
@ -1036,6 +1043,88 @@ read_configuration(const char *confFile, const char *tag)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *threadArchScan(void* arg) {
|
||||||
|
int arch = *(int *)arg;
|
||||||
|
|
||||||
|
if (!quietmode)
|
||||||
|
fprintf(stdout, "%s: scanning binary packages...\n",configtag->arch[arch]);
|
||||||
|
else
|
||||||
|
logmsg(LOG_MARK, "%s binary packages check for %s:", configtag->arch[arch],configtag->tag);
|
||||||
|
|
||||||
|
if (generateHeaderList(configtag,arch)) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Fatal error: could not generate header list\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (genheader_mode & GENHEADER_REQUIREMENTS) {
|
||||||
|
|
||||||
|
if (obsolete_packages) {
|
||||||
|
if (!quietmode) fprintf(stdout, "%s: handling obsoleted packages...\n",configtag->arch[arch]);
|
||||||
|
if (handleObsoletedPackages(configtag,arch)) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Fatal error: maximum number of multiple providing packages reached. Aborting.");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!quietmode) fprintf(stdout, "%s: resolving dependencies...\n",configtag->arch[arch]);
|
||||||
|
if (resolveFirstLevelDependencies(configtag, arch)) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Fatal error: could not generate first level requires table\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arch == 0) /* fixme? */ {
|
||||||
|
if (!quietmode) fprintf(stdout, "%s: resolving source dependencies\n",configtag->arch[arch]);
|
||||||
|
if (resolveFirstLevelSourceDependencies(configtag, arch)) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Fatal error: could not generate first level requires table\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recursive_mode) {
|
||||||
|
if (!quietmode) fprintf(stdout, "%s: resolving recursive dependencies...\n",configtag->arch[arch]);
|
||||||
|
|
||||||
|
if (resolveRecursiveDependencies
|
||||||
|
(configtag->headerlist[arch])) {
|
||||||
|
fprintf(stderr,"Fatal error: could not resolve recursive dependencies\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode & MODE_DATA_TABLES) {
|
||||||
|
if (!quietmode) fprintf(stdout,"%s: writing dependencies table...\n",configtag->arch[arch]);
|
||||||
|
print_datatables(configtag,arch);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (genheader_mode & GENHEADER_STATS) {
|
||||||
|
if (!quietmode) fprintf(stdout,"%s: generating statistics...\n",configtag->arch[arch]);
|
||||||
|
|
||||||
|
logmsg(LOG_DEBUG,"%s: generateHeaderStats - start",configtag->arch[arch]);
|
||||||
|
if (generateHeaderStats(configtag, arch)) {
|
||||||
|
fprintf(stderr,"Fatal error: could not generate statistic for headers\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
logmsg(LOG_DEBUG,"%s: generateHeaderStats - done",configtag->arch[arch]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode & MODE_HTML) {
|
||||||
|
// printf("Generating HTML files for binary RPMs...\n");
|
||||||
|
logmsg(LOG_DEBUG,"%s: generateHTMLFiles - start",configtag->arch[arch]);
|
||||||
|
generateHTMLFiles(configtag, arch);
|
||||||
|
logmsg(LOG_DEBUG,"%s: generateHTMLFiles - done",configtag->arch[arch]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode & MODE_GENPKGLIST) {
|
||||||
|
/* currheaderlist = headerlist; */
|
||||||
|
generatePkgList(configtag, arch);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -1046,12 +1135,8 @@ main(int argc, char *argv[])
|
|||||||
struct headerList *currheaderlist;
|
struct headerList *currheaderlist;
|
||||||
struct headerSourceList *currheadersourcelist = NULL;
|
struct headerSourceList *currheadersourcelist = NULL;
|
||||||
|
|
||||||
unsigned int mode = 0;
|
int i,hasbuilds[ARCHS_MAX],ptharg[ARCHS_MAX];
|
||||||
unsigned int recursive_mode = 0;
|
pthread_t pth[ARCHS_MAX];
|
||||||
unsigned int genheader_mode = GENHEADER_BASE + GENHEADER_REQUIREMENTS;
|
|
||||||
unsigned int quietmode = 0;
|
|
||||||
unsigned int obsolete_packages = 1;
|
|
||||||
int i,hasbuilds[ARCHS_MAX];
|
|
||||||
char warning[PATH_MAX];
|
char warning[PATH_MAX];
|
||||||
|
|
||||||
time_t start_time, stop_time;
|
time_t start_time, stop_time;
|
||||||
@ -1238,95 +1323,14 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) {
|
for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) {
|
||||||
|
ptharg[i]=i;
|
||||||
|
pthread_create(&pth[i],NULL,threadArchScan,&ptharg[i]);
|
||||||
|
} // archs threads loop
|
||||||
|
|
||||||
if (!quietmode)
|
for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) {
|
||||||
fprintf(stdout, "Scanning binary packages for %s arch...\n",configtag->arch[i]);
|
pthread_join(pth[i], NULL);
|
||||||
else
|
|
||||||
logmsg(LOG_MARK, "%s binary packages check for %s:", configtag->arch[i],configtag->tag);
|
|
||||||
|
|
||||||
if (generateHeaderList(configtag,i)) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Fatal error: could not generate header list\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (genheader_mode & GENHEADER_REQUIREMENTS) {
|
|
||||||
|
|
||||||
if (obsolete_packages) {
|
|
||||||
if (!quietmode)
|
|
||||||
fprintf(stdout, " - handling obsoleted packages...\n");
|
|
||||||
if (handleObsoletedPackages(configtag,i)) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Fatal error: maximum number of multiple providing packages reached. Aborting.");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!quietmode)
|
|
||||||
fprintf(stdout, " - resolving dependencies...\n");
|
|
||||||
if (resolveFirstLevelDependencies(configtag, i)) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Fatal error: could not generate first level requires table\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == 0) /* fixme? */ {
|
|
||||||
if (!quietmode)
|
|
||||||
fprintf(stdout, " - resolving source dependencies\n");
|
|
||||||
if (resolveFirstLevelSourceDependencies(configtag, i)) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Fatal error: could not generate first level requires table\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (recursive_mode) {
|
|
||||||
if (!quietmode)
|
|
||||||
fprintf(stdout, " - resolving recursive dependencies...\n");
|
|
||||||
|
|
||||||
if (resolveRecursiveDependencies
|
|
||||||
(configtag->headerlist[i])) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Fatal error: could not resolve recursive dependencies\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode & MODE_DATA_TABLES) {
|
|
||||||
if (!quietmode) fprintf(stdout, " - writing dependencies table...\n");
|
|
||||||
print_datatables(configtag,i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (genheader_mode & GENHEADER_STATS) {
|
|
||||||
if (!quietmode)
|
|
||||||
fprintf(stdout, " - generating statistics...\n");
|
|
||||||
|
|
||||||
logmsg(LOG_DEBUG,"generateHeaderStats - start");
|
|
||||||
if (generateHeaderStats(configtag, i)) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Fatal error: could not generate statistic for headers\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
logmsg(LOG_DEBUG,"generateHeaderStats - done");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode & MODE_HTML) {
|
|
||||||
// printf("Generating HTML files for binary RPMs...\n");
|
|
||||||
logmsg(LOG_DEBUG,"generateHTMLFiles - start");
|
|
||||||
generateHTMLFiles(configtag, i);
|
|
||||||
logmsg(LOG_DEBUG,"generateHTMLFiles - done");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (mode & MODE_GENPKGLIST) {
|
|
||||||
/* currheaderlist = headerlist; */
|
|
||||||
generatePkgList(configtag, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // archs loop
|
|
||||||
|
|
||||||
if (!passed_arch) { // can't do missing builds and ports check in single arch mode
|
if (!passed_arch) { // can't do missing builds and ports check in single arch mode
|
||||||
if (!quietmode)
|
if (!quietmode)
|
||||||
fprintf(stdout, "Checking for SRPMS with no builds and missing ports...\n");
|
fprintf(stdout, "Checking for SRPMS with no builds and missing ports...\n");
|
||||||
|
@ -26,6 +26,12 @@
|
|||||||
# include <rpm/rpmlib.h>
|
# include <rpm/rpmlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if RPM_VERSION >= 0x040100
|
||||||
|
#include <rpm/rpmts.h>
|
||||||
|
#else
|
||||||
|
#define rpmReadPackageFile(a,b,c,d) rpmReadPackageHeader(b,d,0,NULL,NULL)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAVE_STRING_H
|
#if HAVE_STRING_H
|
||||||
# if !STDC_HEADERS && HAVE_MEMORY_H
|
# if !STDC_HEADERS && HAVE_MEMORY_H
|
||||||
# include <memory.h>
|
# include <memory.h>
|
||||||
@ -56,10 +62,10 @@
|
|||||||
# define memcpy(d, s, n) bcopy ((s), (d), (n))
|
# define memcpy(d, s, n) bcopy ((s), (d), (n))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int rpmselector(const struct dirent *entry);
|
int rpmselector(const struct dirent *entry);
|
||||||
static int sourcerpmselector(const struct dirent *entry);
|
int sourcerpmselector(const struct dirent *entry);
|
||||||
|
|
||||||
static const int bufsize = 1024;
|
const int bufsize = 1024;
|
||||||
|
|
||||||
struct warningList* addWarning(struct headerSourceList *pkg, char* text)
|
struct warningList* addWarning(struct headerSourceList *pkg, char* text)
|
||||||
{
|
{
|
||||||
@ -332,7 +338,7 @@ generateHeaderSourceStats(struct configTag *ct)
|
|||||||
/*
|
/*
|
||||||
* this function should filter only RPM files
|
* this function should filter only RPM files
|
||||||
* fixme: it currently just filters files from other entities */
|
* fixme: it currently just filters files from other entities */
|
||||||
static int
|
int
|
||||||
rpmselector(const struct dirent *entry)
|
rpmselector(const struct dirent *entry)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
@ -354,7 +360,7 @@ rpmselector(const struct dirent *entry)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
sourcerpmselector(const struct dirent *entry)
|
sourcerpmselector(const struct dirent *entry)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
@ -371,7 +377,7 @@ sourcerpmselector(const struct dirent *entry)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long providedListCount = 0;
|
long providedListCount[ARCHS_MAX];
|
||||||
|
|
||||||
void
|
void
|
||||||
cleanProvidedListIndex(struct configTag *ct, int arch)
|
cleanProvidedListIndex(struct configTag *ct, int arch)
|
||||||
@ -381,17 +387,17 @@ cleanProvidedListIndex(struct configTag *ct, int arch)
|
|||||||
for (i = 0; i < PROVIDEDLIST_IDX_SIZE; i++)
|
for (i = 0; i < PROVIDEDLIST_IDX_SIZE; i++)
|
||||||
ct->providedlist_idx[arch][i]=NULL;
|
ct->providedlist_idx[arch][i]=NULL;
|
||||||
|
|
||||||
providedListCount = 0;
|
providedListCount[arch] = 0;
|
||||||
ct->filetree[arch]=NULL;
|
ct->filetree[arch]=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
createProvidedListIndex(struct providedList* *idx) {
|
createProvidedListIndex(struct providedList* *idx, int arch) {
|
||||||
int i, step = providedListCount/PROVIDEDLIST_IDX_SIZE;
|
int i, step = providedListCount[arch]/PROVIDEDLIST_IDX_SIZE;
|
||||||
int curridx = 1;
|
int curridx = 1;
|
||||||
struct providedList *currprovided = idx[0];
|
struct providedList *currprovided = idx[0];
|
||||||
|
|
||||||
if (providedListCount > PROVIDEDLIST_IDX_SIZE) {
|
if (providedListCount[arch] > PROVIDEDLIST_IDX_SIZE) {
|
||||||
while (currprovided && curridx < PROVIDEDLIST_IDX_SIZE) {
|
while (currprovided && curridx < PROVIDEDLIST_IDX_SIZE) {
|
||||||
for (i = 0; i < step; i++)
|
for (i = 0; i < step; i++)
|
||||||
currprovided = currprovided->next;
|
currprovided = currprovided->next;
|
||||||
@ -406,7 +412,7 @@ static long providedListId = 0;
|
|||||||
|
|
||||||
struct providedList*
|
struct providedList*
|
||||||
findOrCreateProvidedListEntry(struct providedList* *idx,
|
findOrCreateProvidedListEntry(struct providedList* *idx,
|
||||||
char* findname, int create)
|
char* findname, int create, int arch)
|
||||||
{
|
{
|
||||||
struct providedList *newprovided, *currprovided, *prevprovided = NULL;
|
struct providedList *newprovided, *currprovided, *prevprovided = NULL;
|
||||||
int c = 0, i;
|
int c = 0, i;
|
||||||
@ -438,7 +444,7 @@ findOrCreateProvidedListEntry(struct providedList* *idx,
|
|||||||
|
|
||||||
if ((!currprovided) || (c > 0)) {
|
if ((!currprovided) || (c > 0)) {
|
||||||
if (!create) return NULL;
|
if (!create) return NULL;
|
||||||
providedListCount++;
|
providedListCount[arch]++;
|
||||||
newprovided = malloc(sizeof(struct providedList));
|
newprovided = malloc(sizeof(struct providedList));
|
||||||
if (prevprovided) {
|
if (prevprovided) {
|
||||||
newprovided->next = prevprovided->next;
|
newprovided->next = prevprovided->next;
|
||||||
@ -554,6 +560,11 @@ addToSourceHeaderList(struct headerSourceList **headersourcelist, struct configT
|
|||||||
char **requireversion, **requirename;
|
char **requireversion, **requirename;
|
||||||
uint_32 *requireflags;
|
uint_32 *requireflags;
|
||||||
char warning[PATH_MAX];
|
char warning[PATH_MAX];
|
||||||
|
#if RPM_VERSION >= 0x040100
|
||||||
|
rpmts ts = rpmtsCreate();
|
||||||
|
#else
|
||||||
|
rpmts ts = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (altrepository == ct->repository_level) {
|
if (altrepository == ct->repository_level) {
|
||||||
scanpath = ct->repository_source_dir;
|
scanpath = ct->repository_source_dir;
|
||||||
@ -581,7 +592,7 @@ addToSourceHeaderList(struct headerSourceList **headersourcelist, struct configT
|
|||||||
}
|
}
|
||||||
strcpy(&filepath[strlen(scanpath)], namelist[cnt]->d_name);
|
strcpy(&filepath[strlen(scanpath)], namelist[cnt]->d_name);
|
||||||
|
|
||||||
if (getHeader(filepath, &h)) {
|
if (getHeader(&ts, filepath, &h)) {
|
||||||
errstr = strerror(errno);
|
errstr = strerror(errno);
|
||||||
logmsg(LOG_WARNING,
|
logmsg(LOG_WARNING,
|
||||||
"%s: unable to read header (%s); skipping.",namelist[cnt]->d_name, errstr);
|
"%s: unable to read header (%s); skipping.",namelist[cnt]->d_name, errstr);
|
||||||
@ -726,6 +737,7 @@ addToSourceHeaderList(struct headerSourceList **headersourcelist, struct configT
|
|||||||
} // for
|
} // for
|
||||||
|
|
||||||
free(namelist);
|
free(namelist);
|
||||||
|
rpmtsFree(ts);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -791,8 +803,12 @@ addToHeaderList(struct configTag *ct,
|
|||||||
**requirename, **requireversion,
|
**requirename, **requireversion,
|
||||||
**basename, **dirname, **newversion;
|
**basename, **dirname, **newversion;
|
||||||
const char* errstr;
|
const char* errstr;
|
||||||
|
|
||||||
uint_32 *requireflags, *obsoleteflags, *provideflags;
|
uint_32 *requireflags, *obsoleteflags, *provideflags;
|
||||||
|
#if RPM_VERSION >= 0x040100
|
||||||
|
rpmts ts = rpmtsCreate();
|
||||||
|
#else
|
||||||
|
rpmts ts = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
currheaderlist = ct->headerlist[arch];
|
currheaderlist = ct->headerlist[arch];
|
||||||
|
|
||||||
@ -885,7 +901,9 @@ addToHeaderList(struct configTag *ct,
|
|||||||
/* process package */
|
/* process package */
|
||||||
logmsg(LOG_DEBUG, "getting header for %s", filepath);
|
logmsg(LOG_DEBUG, "getting header for %s", filepath);
|
||||||
|
|
||||||
if (getHeader(filepath, &h)) {
|
sem_wait(&rpm_mutex);
|
||||||
|
if (getHeader(&ts, filepath, &h)) {
|
||||||
|
sem_post(&rpm_mutex);
|
||||||
errstr = strerror(errno);
|
errstr = strerror(errno);
|
||||||
logmsg(LOG_WARNING,
|
logmsg(LOG_WARNING,
|
||||||
"%s: unable to read header (%s); skipping.",filename, errstr);
|
"%s: unable to read header (%s); skipping.",filename, errstr);
|
||||||
@ -907,6 +925,7 @@ addToHeaderList(struct configTag *ct,
|
|||||||
}
|
}
|
||||||
memset(newheaderlist, 0, sizeof(struct headerList));
|
memset(newheaderlist, 0, sizeof(struct headerList));
|
||||||
getPackageInfoIntoHeaderList(h, newheaderlist);
|
getPackageInfoIntoHeaderList(h, newheaderlist);
|
||||||
|
sem_post(&rpm_mutex);
|
||||||
|
|
||||||
if (!newheaderlist->sourcename) {
|
if (!newheaderlist->sourcename) {
|
||||||
logmsg(LOG_WARNING,
|
logmsg(LOG_WARNING,
|
||||||
@ -976,7 +995,7 @@ addToHeaderList(struct configTag *ct,
|
|||||||
newheaderlist->provided = malloc(sizeof(struct providedList*)*providecount);
|
newheaderlist->provided = malloc(sizeof(struct providedList*)*providecount);
|
||||||
for (i=0; i < providecount; i++) {
|
for (i=0; i < providecount; i++) {
|
||||||
provided = findOrCreateProvidedListEntry((struct providedList **) &(ct->providedlist_idx[arch]),
|
provided = findOrCreateProvidedListEntry((struct providedList **) &(ct->providedlist_idx[arch]),
|
||||||
providename[i],1);
|
providename[i],1,arch);
|
||||||
newheaderlist->provided[i]=provided;
|
newheaderlist->provided[i]=provided;
|
||||||
if (provided && (provided->numproviders == 0)) {
|
if (provided && (provided->numproviders == 0)) {
|
||||||
provided->flags=provideflags[i];
|
provided->flags=provideflags[i];
|
||||||
@ -986,7 +1005,7 @@ addToHeaderList(struct configTag *ct,
|
|||||||
provided->numversions++;
|
provided->numversions++;
|
||||||
provided->version=malloc(sizeof(char *));
|
provided->version=malloc(sizeof(char *));
|
||||||
provided->version[0]=strdup(provideversion[i]);
|
provided->version[0]=strdup(provideversion[i]);
|
||||||
} else if (provided->numproviders > 0) {
|
} else if (provided && (provided->numproviders > 0)) {
|
||||||
provided->numproviders++;
|
provided->numproviders++;
|
||||||
newprovider=malloc(sizeof(struct headerList*)*provided->numproviders);
|
newprovider=malloc(sizeof(struct headerList*)*provided->numproviders);
|
||||||
for (j = 0; j < provided->numproviders-1; j++) {
|
for (j = 0; j < provided->numproviders-1; j++) {
|
||||||
@ -996,11 +1015,11 @@ addToHeaderList(struct configTag *ct,
|
|||||||
free(provided->provider);
|
free(provided->provider);
|
||||||
provided->provider=newprovider;
|
provided->provider=newprovider;
|
||||||
|
|
||||||
/* check if version is already provided */
|
// check if version is already provided
|
||||||
for (j = 0; j < provided->numversions; j++) {
|
for (j = 0; j < provided->numversions; j++) {
|
||||||
if (!strcmp(provided->version[j],provideversion[i])) break;
|
if (!strcmp(provided->version[j],provideversion[i])) break;
|
||||||
}
|
}
|
||||||
/* if not add to the list of versions */
|
// if not add to the list of versions
|
||||||
if (j == provided->numversions) {
|
if (j == provided->numversions) {
|
||||||
provided->numversions++;
|
provided->numversions++;
|
||||||
newversion=malloc(sizeof(char *)*provided->numversions);
|
newversion=malloc(sizeof(char *)*provided->numversions);
|
||||||
@ -1074,8 +1093,9 @@ addToHeaderList(struct configTag *ct,
|
|||||||
free(altnamelist[altrepository-1][altcnt[altrepository-1]-1]); }
|
free(altnamelist[altrepository-1][altcnt[altrepository-1]-1]); }
|
||||||
else free(namelist[cnt-1]);
|
else free(namelist[cnt-1]);
|
||||||
} // main while
|
} // main while
|
||||||
|
rpmtsFree(ts);
|
||||||
free(namelist);
|
free(namelist);
|
||||||
createProvidedListIndex((struct providedList **)&(ct->providedlist_idx[arch]));
|
createProvidedListIndex((struct providedList **)&(ct->providedlist_idx[arch]), arch);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ generateHeaderSourceStats(struct configTag *ct);
|
|||||||
|
|
||||||
struct providedList*
|
struct providedList*
|
||||||
findOrCreateProvidedListEntry(struct providedList **idx,
|
findOrCreateProvidedListEntry(struct providedList **idx,
|
||||||
char* findname, int create);
|
char* findname, int create, int arch);
|
||||||
|
|
||||||
struct fileTree*
|
struct fileTree*
|
||||||
findOrCreateFileTreeBrother(struct fileTree* *first,char* findname);
|
findOrCreateFileTreeBrother(struct fileTree* *first,char* findname);
|
||||||
@ -179,7 +179,7 @@ void
|
|||||||
cleanProvidedListIndex(struct configTag *ct, int arch);
|
cleanProvidedListIndex(struct configTag *ct, int arch);
|
||||||
|
|
||||||
void
|
void
|
||||||
createProvidedListIndex(struct providedList* *idx);
|
createProvidedListIndex(struct providedList* *idx, int arch);
|
||||||
|
|
||||||
int generateHeaderList(
|
int generateHeaderList(
|
||||||
struct configTag *ct,
|
struct configTag *ct,
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
# include <rpm/rpmlib.h>
|
# include <rpm/rpmlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <semaphore.h>
|
||||||
#include "headerlist.h"
|
#include "headerlist.h"
|
||||||
|
|
||||||
#define HEADERS_BUFFER_SIZE 2000000
|
#define HEADERS_BUFFER_SIZE 2000000
|
||||||
@ -30,7 +31,7 @@ long long headerGetUIntEntry(Header h, const int tag);
|
|||||||
|
|
||||||
void *headerGetUIntArrayEntry(Header h, const int tag, int *count);
|
void *headerGetUIntArrayEntry(Header h, const int tag, int *count);
|
||||||
|
|
||||||
int getHeader(char *headerFile, Header * h);
|
int getHeader(rpmts *ts, char *headerFile, Header * h);
|
||||||
|
|
||||||
int getPackageRequires(
|
int getPackageRequires(
|
||||||
Header h, char ***requirename, uint_32 **requireflags,
|
Header h, char ***requirename, uint_32 **requireflags,
|
||||||
@ -55,4 +56,6 @@ int scanrpmnamecmp(const struct dirent **f1, const struct dirent **f2);
|
|||||||
|
|
||||||
char* printrpmversion(char *s, int bufsize, long epoch, char *version, char *release);
|
char* printrpmversion(char *s, int bufsize, long epoch, char *version, char *release);
|
||||||
|
|
||||||
|
sem_t rpm_mutex;
|
||||||
|
|
||||||
#endif // RPMFUNCTIONS_H
|
#endif // RPMFUNCTIONS_H
|
||||||
|
@ -89,10 +89,10 @@ unsigned int checkVersionWithFlags(const char* cmp1, uint_32 flags, const char*
|
|||||||
/*
|
/*
|
||||||
* get header from a file descriptor of a YUM compressed header file */
|
* get header from a file descriptor of a YUM compressed header file */
|
||||||
int
|
int
|
||||||
getHeader(char *headerFile, Header * h)
|
getHeader(rpmts* ts, char *headerFile, Header * h)
|
||||||
{
|
{
|
||||||
char buffer[HEADERS_BUFFER_SIZE];
|
char buffer[HEADERS_BUFFER_SIZE];
|
||||||
int len;
|
int len,lock=0;
|
||||||
|
|
||||||
/* check if file is a compressed header or a RPM/SRPM */
|
/* check if file is a compressed header or a RPM/SRPM */
|
||||||
if (!strcmp(&headerFile[strlen(headerFile) - 4], ".hdr")) {
|
if (!strcmp(&headerFile[strlen(headerFile) - 4], ".hdr")) {
|
||||||
@ -124,16 +124,19 @@ getHeader(char *headerFile, Header * h)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
#if RPM_VERSION >= 0x040100
|
#if RPM_VERSION >= 0x040100
|
||||||
rc = rpmReadPackageFile(ts, fd, headerFile, h);
|
rc = rpmReadPackageFile(*ts, fd, headerFile, h);
|
||||||
if (rc != RPMRC_OK && rc != RPMRC_NOTTRUSTED && rc != RPMRC_NOKEY) {
|
|
||||||
/* fprintf(stderr, "Error: Failed reading file %s", headerFile); */
|
|
||||||
#else
|
#else
|
||||||
rc = rpmReadPackageHeader(fd, h, NULL, NULL, NULL);
|
rc = rpmReadPackageHeader(fd, h, NULL, NULL, NULL);
|
||||||
|
#endif
|
||||||
|
fdClose(fd);
|
||||||
|
#if RPM_VERSION >= 0x040100
|
||||||
|
if (rc != RPMRC_OK && rc != RPMRC_NOTTRUSTED && rc != RPMRC_NOKEY) {
|
||||||
|
// fprintf(stderr, "Error: Failed reading file %s\n", headerFile);
|
||||||
|
#else
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fdClose(fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -366,7 +369,8 @@ char* printrpmversion(char *s, int bufsize, long epoch, char *version, char *rel
|
|||||||
void rpminit() {
|
void rpminit() {
|
||||||
#if RPM_VERSION >= 0x040100
|
#if RPM_VERSION >= 0x040100
|
||||||
rpmReadConfigFiles(NULL, NULL);
|
rpmReadConfigFiles(NULL, NULL);
|
||||||
ts = rpmtsCreate();
|
// ts = rpmtsCreate();
|
||||||
// rpmtsSetVSFlags(ts, (rpmVSFlags_e)-1);
|
// rpmtsSetVSFlags(ts, (rpmVSFlags_e)-1);
|
||||||
#endif
|
#endif
|
||||||
|
sem_init(&rpm_mutex, 0, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user