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

View File

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

View File

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