Make contentslist generation optional using --gencontentslist
backend-sqlite: only output data for local repository to work also when executed with other arguments
This commit is contained in:
parent
4f56214e72
commit
4d9e6ffad9
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* distromatic - tool for RPM based repositories
|
||||
*
|
||||
* Copyright (C) 2013 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
* Copyright (C) 2013-2015 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of version 2 of the GNU General Public License as published by the
|
||||
@ -68,7 +68,18 @@ int SQLite_print_contents_subtree(sqlite3 *db,
|
||||
struct configTag* ct,
|
||||
int arch) {
|
||||
|
||||
int thisrep, i;
|
||||
|
||||
while (ft) {
|
||||
i = 0;
|
||||
thisrep = 0;
|
||||
for (i = 0; i < ft->numproviders; i++) {
|
||||
if (ft->provider[i]->altrepository == ct->repository_level) {
|
||||
thisrep = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (thisrep) {
|
||||
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO files VALUES(%ld,?,%ld,%ld,%ld,%d);",
|
||||
ft->id,
|
||||
(ft->firstchild?ft->firstchild->id:-1),
|
||||
@ -92,6 +103,7 @@ int SQLite_print_contents_subtree(sqlite3 *db,
|
||||
if (ft->firstchild) {
|
||||
if (SQLite_print_contents_subtree(db, ft->firstchild, ct, arch)) return 1;
|
||||
}
|
||||
}
|
||||
ft=ft->next;
|
||||
}
|
||||
return 0;
|
||||
@ -163,6 +175,7 @@ int generateSQLite_files(struct configTag* ct, sqlite3 *db, int arch) {
|
||||
|
||||
currpackage = ct->headerlist[arch];
|
||||
while (currpackage) {
|
||||
if (currpackage->altrepository == ct->repository_level) {
|
||||
/* packages <-> files relations */
|
||||
for (i = 0; i < currpackage->filenamecount; i++) {
|
||||
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages_files_rel VALUES(NULL,%ld,%ld,%ld,%ld,%d,?,?,?);",
|
||||
@ -189,10 +202,10 @@ int generateSQLite_files(struct configTag* ct, sqlite3 *db, int arch) {
|
||||
SQLite_begin_transaction(db);
|
||||
}
|
||||
}
|
||||
}
|
||||
currpackage = currpackage->next;
|
||||
}
|
||||
SQLite_commit_transaction(db);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -202,6 +215,7 @@ int generateSQLite_files(struct configTag* ct, sqlite3 *db, int arch) {
|
||||
int generateSQLite_provided(struct configTag* ct, sqlite3 *db, int arch) {
|
||||
|
||||
struct providedList* provided;
|
||||
int i, thisrep;
|
||||
|
||||
snprintf(sqlite3_query, PATH_MAX, "provided");
|
||||
SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_provided);
|
||||
@ -209,6 +223,15 @@ int generateSQLite_provided(struct configTag* ct, sqlite3 *db, int arch) {
|
||||
|
||||
provided = ct->providedlist_idx[arch][0];
|
||||
while (provided) {
|
||||
i = 0;
|
||||
thisrep = 0;
|
||||
for (i = 0; i < provided->numproviders; i++) {
|
||||
if (provided->provider[i]->altrepository == ct->repository_level) {
|
||||
thisrep = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (thisrep) {
|
||||
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provided VALUES(%ld,?,%ld,%d);",
|
||||
provided->id,
|
||||
provided->flags,
|
||||
@ -220,11 +243,10 @@ int generateSQLite_provided(struct configTag* ct, sqlite3 *db, int arch) {
|
||||
return 1;
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
provided = provided->next;
|
||||
}
|
||||
|
||||
SQLite_commit_transaction(db);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -316,7 +338,7 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
|
||||
|
||||
currpackage = ct->headerlist[arch];
|
||||
while (currpackage) {
|
||||
|
||||
if (currpackage->altrepository == ct->repository_level) {
|
||||
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages VALUES(NULL,?,%d,%ld,?,?,?,?,?,%ld,%ld);",
|
||||
currpackage->altrepository,
|
||||
currpackage->epoch,
|
||||
@ -398,6 +420,7 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
|
||||
fprintf(stderr, "WARNING: package %s require %s not in provided list\n", currpackage->name, currpackage->require[i]->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
currpackage = currpackage->next;
|
||||
}
|
||||
SQLite_commit_transaction(db);
|
||||
@ -435,7 +458,7 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
|
||||
|
||||
currsource = ct->headersourcelist;
|
||||
while (currsource != NULL) {
|
||||
|
||||
if (currsource->altrepository == ct->repository_level) {
|
||||
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources VALUES(%ld,?,%d,%ld,?,?,?,%ld,?,?,?,?,?,?,?,%ld,%ld,%ld);",
|
||||
currsource->id,
|
||||
currsource->altrepository,
|
||||
@ -544,6 +567,7 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
|
||||
if (currsource->changelog) {
|
||||
nextchangelogid = generateSQLite_add_changelog(db, currsource->changelog, currsource->id) + 1;
|
||||
}
|
||||
}
|
||||
currsource = currsource->next;
|
||||
}
|
||||
SQLite_commit_transaction(db);
|
||||
|
@ -92,6 +92,7 @@
|
||||
#define MODE_GENPKGLIST 64
|
||||
#define MODE_SQLITE3 128
|
||||
#define MODE_SQLITE3_FILES 256
|
||||
#define MODE_GENCONTENTSLIST 512
|
||||
|
||||
static void program_usage(int exit_code);
|
||||
static void program_version(void);
|
||||
@ -147,6 +148,7 @@ static const char *helpmsg[] = {
|
||||
" --gensrcpkglist generate a source packages list with version",
|
||||
" --gensqlite3 dump data to SQLite3 databases",
|
||||
" --gensqlite3files dump files to SQLite3 databases",
|
||||
" --gencontentslist generate files listing all files in packages",
|
||||
" --find-deps <package> find dependencies for given package name",
|
||||
" --changelog <package> print changelog for given package name",
|
||||
" --changelogsince <mmddyy> print changelog for all packages since given date",
|
||||
@ -895,10 +897,16 @@ void *threadArchScan(void* arg) {
|
||||
}
|
||||
|
||||
if (mode & MODE_DATA_TABLES) {
|
||||
if (!quietmode) fprintf(stdout,"%s: writing dependencies table...\n",configtag->arch[arch]);
|
||||
if (!quietmode) fprintf(stdout,"%s: writing dependencies tables...\n",configtag->arch[arch]);
|
||||
print_datatables(configtag,arch);
|
||||
}
|
||||
|
||||
|
||||
if (mode & MODE_GENCONTENTSLIST) {
|
||||
if (!quietmode) fprintf(stdout,"%s: writing contentslist files...\n",configtag->arch[arch]);
|
||||
print_contentslist(configtag,arch);
|
||||
}
|
||||
|
||||
if (genheader_mode & GENHEADER_STATS) {
|
||||
if (!quietmode) fprintf(stdout,"%s: generating statistics...\n",configtag->arch[arch]);
|
||||
|
||||
@ -956,6 +964,7 @@ main(int argc, char *argv[])
|
||||
{ "gensrcpkglist", no_argument, 0, 0 },
|
||||
{ "gensqlite3", no_argument, 0, 0 },
|
||||
{ "gensqlite3files", no_argument, 0, 0 },
|
||||
{ "gencontentslist", no_argument, 0, 0 },
|
||||
{ "arch", required_argument, 0, 'a' },
|
||||
{ "conf", required_argument, 0, 'c' },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
@ -1020,6 +1029,9 @@ main(int argc, char *argv[])
|
||||
mode |= MODE_GENBUILDINFO;
|
||||
genheader_mode |= GENHEADER_BASE;
|
||||
name = NULL;
|
||||
} else if (!strcmp(longopts[longindex].name, "gencontentslist")) {
|
||||
mode |= MODE_GENCONTENTSLIST;
|
||||
name = NULL;
|
||||
}
|
||||
break;
|
||||
case 'a':
|
||||
|
@ -28,6 +28,7 @@ int generateHTML_SRPMSFiles(struct configTag *configtag);
|
||||
int generateHTMLMainIndex(struct configTag *configtag);
|
||||
char *groupdirname(char *group,char *dest,unsigned int max);
|
||||
int write_RPM_HTML(struct configTag *ct,FILE *fout, struct headerList *currheaderlist);
|
||||
int print_contentslist(struct configTag *ct, int arch);
|
||||
int print_datatables(struct configTag *ct, int arch);
|
||||
char *ftname(struct fileTree* ft, char* buf, unsigned int bufsize);
|
||||
void print_contents_subtree(FILE *f,
|
||||
|
@ -1764,13 +1764,32 @@ void print_contents_subtree(FILE *f,
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
print_datatables(struct configTag *ct, int arch) {
|
||||
int print_contentslist(struct configTag *ct, int arch) {
|
||||
FILE *fc;
|
||||
char contents_filename[PATH_MAX],buf[PATH_MAX];
|
||||
|
||||
FILE *fbd,*fd,*fv,*fb,*fbsh,*fs,*fc,*fw;
|
||||
snprintf(contents_filename, PATH_MAX, "%scontentslist-%s", ct->repository_dir, ct->arch[arch]);
|
||||
|
||||
fc=fopen(contents_filename,"w");
|
||||
if (!fc) {
|
||||
fprintf(stderr, "Error: can't open file for writing: %s. Aborting.\n", contents_filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//write contents (filenames)
|
||||
logmsg(LOG_DEBUG,"writing contents file");
|
||||
print_contents_subtree(fc, ct->filetree[arch], ct, buf, PATH_MAX);
|
||||
|
||||
fclose(fc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int print_datatables(struct configTag *ct, int arch) {
|
||||
|
||||
FILE *fbd,*fd,*fv,*fb,*fbsh,*fs,*fw;
|
||||
char builddeps_filename[PATH_MAX], deps_filename[PATH_MAX], virtual_filename[PATH_MAX],
|
||||
builds_filename[PATH_MAX], builds_sh_filename[PATH_MAX], sources_filename[PATH_MAX],
|
||||
contents_filename[PATH_MAX], warnings_filename[PATH_MAX], buf[PATH_MAX];
|
||||
warnings_filename[PATH_MAX];
|
||||
char obsoletebuf[PATH_MAX];
|
||||
struct headerList *currheaderlist, *currchild;
|
||||
struct headerSourceList *currheadersourcelist, *oldheadersourcelist;
|
||||
@ -1783,7 +1802,6 @@ print_datatables(struct configTag *ct, int arch) {
|
||||
snprintf(builds_filename, PATH_MAX, "%sbuilds-%s", ct->html_dir, ct->arch[arch]);
|
||||
snprintf(builds_sh_filename, PATH_MAX, "%sbuilds-%s.sh", ct->html_dir, ct->arch[arch]);
|
||||
snprintf(sources_filename, PATH_MAX, "%ssources-%s", ct->html_dir, ct->arch[arch]);
|
||||
snprintf(contents_filename, PATH_MAX, "%scontentslist-%s", ct->repository_dir, ct->arch[arch]);
|
||||
snprintf(warnings_filename, PATH_MAX, "%swarnings-%s", ct->repository_dir, ct->arch[arch]);
|
||||
|
||||
fbd=fopen(builddeps_filename,"w");
|
||||
@ -1822,12 +1840,6 @@ print_datatables(struct configTag *ct, int arch) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
fc=fopen(contents_filename,"w");
|
||||
if (!fc) {
|
||||
fprintf(stderr, "Error: can't open file for writing: %s. Aborting.\n", contents_filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fw=fopen(warnings_filename,"w");
|
||||
if (!fw) {
|
||||
fprintf(stderr, "Error: can't open file for writing: %s. Aborting.\n", warnings_filename);
|
||||
@ -1933,10 +1945,6 @@ print_datatables(struct configTag *ct, int arch) {
|
||||
provided = provided->next;
|
||||
}
|
||||
|
||||
//write contents (filenames)
|
||||
logmsg(LOG_DEBUG,"writing contents file");
|
||||
print_contents_subtree(fc, ct->filetree[arch], ct, buf, PATH_MAX);
|
||||
|
||||
logmsg(LOG_DEBUG,"writing deps files (2)");
|
||||
currheaderlist = ct->headerlist[arch];
|
||||
while (currheaderlist) {
|
||||
@ -2112,7 +2120,6 @@ print_datatables(struct configTag *ct, int arch) {
|
||||
fclose(fbsh);
|
||||
fclose(fb);
|
||||
fclose(fs);
|
||||
fclose(fc);
|
||||
fclose(fw);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user