sqlite-backend: support for single repository not incremental db creation

- also don't resolve dependencies and obsoletes
This commit is contained in:
Silvan Calarco 2013-10-06 17:43:38 +02:00
parent 57786153d2
commit b9b62dc14c
3 changed files with 73 additions and 66 deletions

View File

@ -127,7 +127,9 @@ unsigned int quietmode = 0;
unsigned int genheader_mode = GENHEADER_BASE + GENHEADER_REQUIREMENTS; unsigned int genheader_mode = GENHEADER_BASE + GENHEADER_REQUIREMENTS;
unsigned int mode = 0; unsigned int mode = 0;
unsigned int recursive_mode = 0; unsigned int recursive_mode = 0;
unsigned int incremental_mode = 1;
unsigned int obsolete_packages = 1; unsigned int obsolete_packages = 1;
unsigned int resolve_dependencies = 1;
/* *INDENT-OFF* */ /* *INDENT-OFF* */
static const char *freelicense[] = { static const char *freelicense[] = {
@ -1107,7 +1109,7 @@ read_configuration(const char *confFile, const char *tag)
void *threadArchScan(void* arg) { void *threadArchScan(void* arg) {
int arch = *(int *)arg; int arch = *(int *)arg;
if (generateHeaderList(configtag,arch)) { if (generateHeaderList(configtag,arch,incremental_mode)) {
fprintf(stderr, fprintf(stderr,
"Fatal error: could not generate header list\n"); "Fatal error: could not generate header list\n");
exit(1); exit(1);
@ -1124,29 +1126,31 @@ void *threadArchScan(void* arg) {
} }
} }
if (!quietmode) fprintf(stdout, "%s: resolving dependencies...\n",configtag->arch[arch]); if (resolve_dependencies) {
if (resolveFirstLevelDependencies(configtag, arch)) { if (!quietmode) fprintf(stdout, "%s: resolving dependencies...\n",configtag->arch[arch]);
fprintf(stderr, if (resolveFirstLevelDependencies(configtag, arch)) {
"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, fprintf(stderr,
"Fatal error: could not generate first level requires table\n"); "Fatal error: could not generate first level requires table\n");
exit(1); exit(1);
} }
}
if (recursive_mode) { if (arch == 0) /* fixme? */ {
if (!quietmode) fprintf(stdout, "%s: resolving recursive dependencies...\n",configtag->arch[arch]); 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 (resolveRecursiveDependencies if (recursive_mode) {
(configtag->headerlist[arch])) { if (!quietmode) fprintf(stdout, "%s: resolving recursive dependencies...\n",configtag->arch[arch]);
fprintf(stderr,"Fatal error: could not resolve recursive dependencies\n");
exit(1); if (resolveRecursiveDependencies
(configtag->headerlist[arch])) {
fprintf(stderr,"Fatal error: could not resolve recursive dependencies\n");
exit(1);
}
} }
} }
} }
@ -1263,8 +1267,11 @@ main(int argc, char *argv[])
name = NULL; name = NULL;
} else if (!strcmp(longopts[longindex].name, "gensqlite3")) { } else if (!strcmp(longopts[longindex].name, "gensqlite3")) {
mode |= MODE_SQLITE3; mode |= MODE_SQLITE3;
genheader_mode |= GENHEADER_CHANGELOG | GENHEADER_STATS; genheader_mode |= GENHEADER_CHANGELOG;
recursive_mode = 1; recursive_mode = 0;
incremental_mode = 0;
obsolete_packages = 0;
resolve_dependencies = 0;
name = NULL; name = NULL;
} else if (!strcmp(longopts[longindex].name, "gensrcpkglist")) { } else if (!strcmp(longopts[longindex].name, "gensrcpkglist")) {
mode |= MODE_GENSRCPKGLIST; mode |= MODE_GENSRCPKGLIST;
@ -1367,7 +1374,7 @@ main(int argc, char *argv[])
else else
logmsg(LOG_MARK,"Source packages check for %s:", configtag->tag); logmsg(LOG_MARK,"Source packages check for %s:", configtag->tag);
if (generateSourceHeaderList(configtag, genheader_mode)) { if (generateSourceHeaderList(configtag, genheader_mode, incremental_mode)) {
fprintf(stderr, fprintf(stderr,
"Fatal error: could not generate source header list\n"); "Fatal error: could not generate source header list\n");
exit(1); exit(1);

View File

@ -567,6 +567,10 @@ addToSourceHeaderList(struct headerSourceList **headersourcelist, struct configT
if (altrepository == ct->repository_level) { if (altrepository == ct->repository_level) {
scanpath = ct->repository_source_dir; scanpath = ct->repository_source_dir;
} else if (altrepository == -1) {
// non-incremental mode
scanpath = ct->repository_source_dir;
altrepository = 0;
} else { } else {
scanpath = ct->repository[altrepository]->repository_source_dir; scanpath = ct->repository[altrepository]->repository_source_dir;
} }
@ -591,6 +595,7 @@ addToSourceHeaderList(struct headerSourceList **headersourcelist, struct configT
} }
strcpy(&filepath[strlen(scanpath)], namelist[cnt]->d_name); strcpy(&filepath[strlen(scanpath)], namelist[cnt]->d_name);
logmsg(LOG_DEBUG, "getting header for %s", filepath);
if (getHeader(&ts, filepath, &h)) { if (getHeader(&ts, filepath, &h)) {
errstr = strerror(errno); errstr = strerror(errno);
logmsg(LOG_WARNING, logmsg(LOG_WARNING,
@ -741,33 +746,29 @@ addToSourceHeaderList(struct headerSourceList **headersourcelist, struct configT
} }
int int
generateSourceHeaderList(struct configTag *ct, int mode) generateSourceHeaderList(struct configTag *ct, int mode, int incremental)
{ {
struct headerSourceList **headersourcelist = &(ct->headersourcelist); struct headerSourceList **headersourcelist = &(ct->headersourcelist);
/* struct headerSourceList **currheadersourcelist;*/
int i; int i;
for (i = 0; i <= ct->repository_level; i++) { if (incremental) {
if (ct->repository[i]) { for (i = 0; i <= ct->repository_level; i++) {
/* currheadersourcelist = headersourcelist; if (ct->repository[i]) {
while ((*currheadersourcelist) && (*currheadersourcelist)->next) { if (addToSourceHeaderList(headersourcelist, ct, mode, i)) {
currheadersourcelist = &((*currheadersourcelist)->next); logmsg(LOG_ERROR,"Error scanning alternate SRPMs repository");
}*/ return 1;
if (addToSourceHeaderList }
(headersourcelist, ct, mode, i)) { } else {
logmsg(LOG_ERROR,"Error scanning alternate SRPMs repository"); break;
return 1; }
} }
} else { } else {
break; if (addToSourceHeaderList(headersourcelist, ct, mode, -1)) {
} logmsg(LOG_ERROR,"Error scanning alternate SRPMs repository");
return 1;
}
} }
/* if (addToSourceHeaderList(headersourcelist, ct, mode, i)) {
logmsg(LOG_ERROR,"Error scanning SRPMs repository");
return 1;
}*/
return 0; return 0;
} }
@ -928,7 +929,7 @@ addToHeaderList(struct configTag *ct,
if (!newheaderlist->sourcename) { if (!newheaderlist->sourcename) {
logmsg(LOG_WARNING, logmsg(LOG_WARNING,
"sourcename undefined in RPM file %s, it looks like a source RPM; skipping package.", "sourcename undefined in RPM file %s, it might be a source RPM with wrong filename; skipping package.",
filepath); filepath);
newheaderlist->sourceheader = NULL; newheaderlist->sourceheader = NULL;
(void) headerFree(h); (void) headerFree(h);
@ -1092,7 +1093,7 @@ addToHeaderList(struct configTag *ct,
} }
int int
generateHeaderList(struct configTag* ct, int arch) generateHeaderList(struct configTag* ct, int arch, int incremental)
{ {
char scanpath[bufsize + 1], *altscanpath[ALT_REPS_MAX]; char scanpath[bufsize + 1], *altscanpath[ALT_REPS_MAX];
char *scantag, *altscantag[ALT_REPS_MAX]; char *scantag, *altscantag[ALT_REPS_MAX];
@ -1103,27 +1104,28 @@ generateHeaderList(struct configTag* ct, int arch)
cleanProvidedListIndex(ct,arch); cleanProvidedListIndex(ct,arch);
if (ct->repository[0]) { if (incremental) {
snprintf(scanpath,bufsize,"%sRPMS.%s/",ct->repository[0]->repository_dir,ct->arch[arch]); if (ct->repository[0]) {
scantag = ct->repository[0]->tag; snprintf(scanpath,bufsize,"%sRPMS.%s/",ct->repository[0]->repository_dir,ct->arch[arch]);
for (i = 1; i <= ct->repository_level; i++) { scantag = ct->repository[0]->tag;
if (ct->repository[i]) { for (i = 1; i <= ct->repository_level; i++) {
altscanpath[i-1] = malloc(bufsize); if (ct->repository[i]) {
snprintf(altscanpath[i-1], bufsize, "%sRPMS.%s/",ct->repository[i]->repository_dir,ct->arch[arch]); altscanpath[i-1] = malloc(bufsize);
altscantag[i-1] = ct->repository[i]->tag; snprintf(altscanpath[i-1], bufsize, "%sRPMS.%s/",ct->repository[i]->repository_dir,ct->arch[arch]);
} else { altscantag[i-1] = ct->repository[i]->tag;
logmsg(LOG_ERROR,"repository[i] not defined; aborting."); } else {
return 1; logmsg(LOG_ERROR,"repository[i] not defined; aborting.");
} return 1;
}
}
} else {
logmsg(LOG_ERROR,"repository[0] is not defined; aborting.");
return 1;
} }
} else { } else {
logmsg(LOG_ERROR,"repository[0] is not defined; aborting.");
return 1;
}
/* else {
snprintf(scanpath,bufsize,"%sRPMS.%s/",ct->repository_dir,ct->arch[arch]); snprintf(scanpath,bufsize,"%sRPMS.%s/",ct->repository_dir,ct->arch[arch]);
scantag = ct->tag; scantag = ct->tag;
}*/ }
if (addToHeaderList(ct, scanpath, scantag, (const char**)altscanpath, (const char**)altscantag, arch)) { if (addToHeaderList(ct, scanpath, scantag, (const char**)altscanpath, (const char**)altscantag, arch)) {
logmsg(LOG_ERROR,"Error scanning RPMs repository"); logmsg(LOG_ERROR,"Error scanning RPMs repository");
return 1; return 1;

View File

@ -180,11 +180,9 @@ cleanProvidedListIndex(struct configTag *ct, int arch);
void void
createProvidedListIndex(struct providedList* *idx, int arch); createProvidedListIndex(struct providedList* *idx, int arch);
int generateHeaderList( int generateHeaderList(struct configTag *ct, int arch, int incremental);
struct configTag *ct,
int arch);
int generateSourceHeaderList(struct configTag *ct, int mode); int generateSourceHeaderList(struct configTag *ct, int mode, int incremental);
/*int generateSourceHeaderList( /*int generateSourceHeaderList(
struct headerSourceList **headersourcelist, struct headerSourceList **headersourcelist,