Commit c5ac6706 authored by Bernhard Link's avatar Bernhard Link

move package database handling from packages.c to database.c

parent fcbdd616
2007-09-15 Bernhard R. Link <brlink@debian.org>
* move package database handling from packages.c to database.c
2007-09-14 Bernhard R. Link <brlink@debian.org>
* rereference now also refreshes references by tracking data.
......
......@@ -16,12 +16,12 @@ AM_CPPFLAGS = -std=gnu99 -Wall $(ARCHIVECPP) $(DBCPPFLAGS)
reprepro_LDADD = $(ARCHIVELIBS) $(DBLIBS)
changestool_LDADD = $(ARCHIVELIBS)
reprepro_SOURCES = configparser.c database.c freespace.c log.c changes.c incoming.c uploaderslist.c guesscomponent.c files.c md5.c md5sum.c dirs.c chunks.c reference.c packages.c binaries.c sources.c checks.c names.c dpkgversions.c release.c mprintf.c updates.c strlist.c signature.c distribution.c checkindeb.c checkindsc.c checkin.c copyfile.c upgradelist.c target.c aptmethod.c downloadcache.c main.c override.c terms.c ignore.c filterlist.c exports.c tracking.c optionsfile.c readrelease.c donefile.c pull.c contents.c filelist.c $(ARCHIVE_USED)
reprepro_SOURCES = configparser.c database.c freespace.c log.c changes.c incoming.c uploaderslist.c guesscomponent.c files.c md5.c md5sum.c dirs.c chunks.c reference.c binaries.c sources.c checks.c names.c dpkgversions.c release.c mprintf.c updates.c strlist.c signature.c distribution.c checkindeb.c checkindsc.c checkin.c copyfile.c upgradelist.c target.c aptmethod.c downloadcache.c main.c override.c terms.c ignore.c filterlist.c exports.c tracking.c optionsfile.c readrelease.c donefile.c pull.c contents.c filelist.c $(ARCHIVE_USED)
EXTRA_reprepro_SOURCE = $(ARCHIVE_UNUSED)
changestool_SOURCES = tool.c chunkedit.c strlist.c md5sum.c md5.c mprintf.c chunks.c signature.c dirs.c names.c copyfile.c $(ARCHIVE_USED)
noinst_HEADERS = configparser.h database_p.h database.h freespace.h log.h changes.h incoming.h guesscomponent.h md5.h md5sum.h dirs.h files.h chunks.h reference.h packages.h binaries.h sources.h checks.h names.h release.h error.h mprintf.h updates.h strlist.h signature.h distribution.h debfile.h checkindeb.h checkindsc.h copyfile.h upgradelist.h target.h aptmethod.h downloadcache.h override.h terms.h ignore.h filterlist.h dpkgversions.h checkin.h exports.h globals.h tracking.h trackingt.h optionsfile.h readrelease.h donefile.h pull.h ar.h filelist.h contents.h chunkedit.h uploaderslist.h
noinst_HEADERS = configparser.h database_p.h database.h freespace.h log.h changes.h incoming.h guesscomponent.h md5.h md5sum.h dirs.h files.h chunks.h reference.h binaries.h sources.h checks.h names.h release.h error.h mprintf.h updates.h strlist.h signature.h distribution.h debfile.h checkindeb.h checkindsc.h copyfile.h upgradelist.h target.h aptmethod.h downloadcache.h override.h terms.h ignore.h filterlist.h dpkgversions.h checkin.h exports.h globals.h tracking.h trackingt.h optionsfile.h readrelease.h donefile.h pull.h ar.h filelist.h contents.h chunkedit.h uploaderslist.h
MAINTAINERCLEANFILES = Makefile.in configure install-sh stamp-h.in aclocal.m4 config.h.in mkinstalldirs config.guess config.sub missing
......
......@@ -634,7 +634,7 @@ static retvalue preparepackages(struct database *db, bool fast, bool readonly, b
if( !allowunused && !fast && packagesfileexists ) {
struct strlist identifiers;
r = packages_getdatabases(db, &identifiers);
r = database_listpackages(db, &identifiers);
if( RET_WAS_ERROR(r) )
return r;
if( RET_IS_OK(r) ) {
......@@ -669,7 +669,7 @@ static retvalue preparepackages(struct database *db, bool fast, bool readonly, b
* - if readonly, do not create but return with RET_NOTHING
* - lock database, waiting a given amount of time if already locked
*/
retvalue database_create(struct database **result, const char *dbdir, struct distribution *alldistributions, bool fast, bool nopackages, bool allowunused, bool readonly, size_t waitforlock) {
retvalue database_create(struct database **result, const char *dbdir, struct distribution *alldistributions, bool fast, bool nopackages, bool allowunused, bool readonly, size_t waitforlock, bool verbosedb) {
struct database *n;
retvalue r;
......@@ -695,6 +695,7 @@ retvalue database_create(struct database **result, const char *dbdir, struct dis
return r;
}
n->readonly = readonly;
n->verbose = verbosedb;
if( nopackages ) {
n->nopackages = true;
......@@ -712,3 +713,394 @@ retvalue database_create(struct database **result, const char *dbdir, struct dis
return RET_OK;
}
/********************************************************************************
* Stuff string parts *
********************************************************************************/
static const char databaseerror[] = "Internal error of the underlying BerkleyDB database:\n";
/********************************************************************************
* Stuff to handle data in tables *
********************************************************************************
There is nothing that connot be solved by another layer of indirection, except
too many levels of indirection. (Source forgotten) */
struct table {
char *name, *subname;
DB *berkleydb;
bool *flagreset;
bool readonly, verbose;
};
static void table_printerror(struct table *table, int dbret, const char *action) {
if( table->subname != NULL )
table->berkleydb->err(table->berkleydb, dbret,
"%sWithin %s subtable %s at %s:",
databaseerror, table->name, table->subname,
action);
else
table->berkleydb->err(table->berkleydb, dbret,
"%sWithin %s at %s:",
databaseerror, table->name, action);
}
retvalue table_close(struct table *table) {
int dbret;
if( table == NULL )
return RET_NOTHING;
if( table->flagreset != NULL )
*table->flagreset = false;
if( table->berkleydb == NULL ) {
assert( table->readonly );
dbret = 0;
} else
dbret = table->berkleydb->close(table->berkleydb, 0);
free(table->name);
free(table->subname);
free(table);
if( dbret != 0 )
return RET_DBERR(dbret);
else
return RET_OK;
}
retvalue table_getrecord(struct table *table, const char *key, char **data_p) {
int dbret;
DBT Key, Data;
assert( table != NULL );
if( table->berkleydb == NULL ) {
assert( table->readonly );
return RET_NOTHING;
}
SETDBT(Key, key);
CLEARDBT(Data);
Data.flags = DB_DBT_MALLOC;
dbret = table->berkleydb->get(table->berkleydb, NULL,
&Key, &Data, 0);
// TODO: find out what error code means out of memory...
if( dbret == DB_NOTFOUND )
return RET_NOTHING;
if( dbret != 0 ) {
table_printerror(table, dbret, "get");
return RET_DBERR(dbret);
}
if( Data.data == NULL )
return RET_ERROR_OOM;
if( ((const char*)Data.data)[Data.size-1] != '\0' ) {
if( table->subname != NULL )
fprintf(stderr,
"Database %s(%s) returned corrupted (not null-terminated) data!",
table->name, table->subname);
else
fprintf(stderr,
"Database %s returned corrupted (not null-terminated) data!",
table->name);
free(Data.data);
return RET_ERROR;
}
*data_p = Data.data;
return RET_OK;
}
retvalue table_adduniqrecord(struct table *table, const char *key, const char *data) {
int dbret;
DBT Key, Data;
assert( table != NULL );
assert( !table->readonly && table->berkleydb != NULL );
SETDBT(Key, key);
SETDBT(Data, data);
dbret = table->berkleydb->put(table->berkleydb, NULL,
&Key, &Data, DB_NOOVERWRITE);
if( dbret != 0 ) {
table_printerror(table, dbret, "put(uniq)");
return RET_DBERR(dbret);
}
if( table->verbose ) {
if( table->subname != NULL )
printf("db: '%s' added to %s(%s).\n",
key, table->name, table->subname);
else
printf("db: '%s' added to %s.\n",
key, table->name);
}
return RET_OK;
}
retvalue table_deleterecord(struct table *table, const char *key) {
int dbret;
DBT Key;
assert( table != NULL );
assert( !table->readonly && table->berkleydb != NULL );
SETDBT(Key, key);
dbret = table->berkleydb->del(table->berkleydb, NULL, &Key, 0);
if( dbret != 0 ) {
table_printerror(table, dbret, "del");
if( dbret == DB_NOTFOUND )
return RET_ERROR_MISSING;
else
return RET_DBERR(dbret);
}
if( table->verbose ) {
if( table->subname != NULL )
printf("db: '%s' removed from %s(%s).\n",
key, table->name, table->subname);
else
printf("db: '%s' removed from %s.\n",
key, table->name);
}
return RET_OK;
}
retvalue table_replacerecord(struct table *table, const char *key, const char *data) {
retvalue r;
r = table_deleterecord(table, key);
if( r != RET_ERROR_MISSING && RET_WAS_ERROR(r) )
return r;
return table_adduniqrecord(table, key, data);
}
struct cursor {
DBC *cursor;
retvalue r;
};
retvalue table_newglobaluniqcursor(struct table *table, struct cursor **cursor_p) {
struct cursor *cursor;
int dbret;
if( table->berkleydb == NULL ) {
assert( table->readonly );
*cursor_p = NULL;
return RET_OK;
}
cursor = calloc(1, sizeof(struct cursor));
if( cursor == NULL )
return RET_ERROR_OOM;
cursor->cursor = NULL;
cursor->r = RET_OK;
dbret = table->berkleydb->cursor(table->berkleydb, NULL,
&cursor->cursor, 0);
if( dbret != 0 ) {
table_printerror(table, dbret, "cursor");
return RET_DBERR(dbret);
}
*cursor_p = cursor;
return RET_OK;
}
retvalue table_newduplicatecursor(struct table *, const char *key, struct cursor **);
retvalue cursor_close(struct table *table, struct cursor *cursor) {
int dbret;
retvalue r;
if( cursor == NULL )
return RET_OK;
r = cursor->r;
dbret = cursor->cursor->c_close(cursor->cursor);
cursor->cursor = NULL;
free(cursor);
if( dbret != 0 ) {
table_printerror(table, dbret, "c_close");
RET_UPDATE(r, RET_DBERR(dbret));
}
return r;
}
bool cursor_nexttemp(struct table *table, struct cursor *cursor, const char **key, const char **data) {
DBT Key, Data;
int dbret;
if( cursor == NULL )
return false;
CLEARDBT(Key);
CLEARDBT(Data);
dbret = cursor->cursor->c_get(cursor->cursor, &Key, &Data, DB_NEXT);
if( dbret == DB_NOTFOUND )
return false;
if( dbret != 0 ) {
table_printerror(table, dbret, "c_get(DB_NEXT)");
cursor->r = RET_DBERR(dbret);
return false;
}
if( ((const char*)Key.data)[Key.size-1] != '\0' ||
((const char*)Data.data)[Data.size-1] != '\0' ) {
if( table->subname != NULL )
fprintf(stderr,
"Database %s(%s) returned corrupted (not null-terminated) data!",
table->name, table->subname);
else
fprintf(stderr,
"Database %s returned corrupted (not null-terminated) data!",
table->name);
cursor->r = RET_ERROR;
return false;
}
*key = Key.data;
*data = Data.data;
return true;
}
retvalue cursor_replace(struct table *table, struct cursor *cursor, const char *data) {
DBT Data;
int dbret;
assert( cursor != NULL );
assert( !table->readonly );
SETDBT(Data, data);
dbret = cursor->cursor->c_put(cursor->cursor, NULL, &Data, DB_CURRENT);
if( dbret != 0 ) {
table_printerror(table, dbret, "c_put(DB_CURRENT)");
return RET_DBERR(dbret);
}
return RET_OK;
}
bool table_isempty(struct table *table) {
DBC *cursor;
DBT Key, Data;
int dbret;
dbret = table->berkleydb->cursor(table->berkleydb, NULL,
&cursor, 0);
if( dbret != 0 ) {
table_printerror(table, dbret, "cursor");
return true;
}
CLEARDBT(Key);
CLEARDBT(Data);
dbret = cursor->c_get(cursor, &Key, &Data, DB_NEXT);
if( dbret == DB_NOTFOUND ) {
(void)cursor->c_close(cursor);
return true;
}
if( dbret != 0 ) {
table_printerror(table, dbret, "c_get(DB_NEXT)");
(void)cursor->c_close(cursor);
return true;
}
dbret = cursor->c_close(cursor);
if( dbret != 0 )
table_printerror(table, dbret, "c_close");
return false;
}
// obsolete, remove in next step:
typedef retvalue per_package_action(void *data,const char *package,const char *chunk);
retvalue packages_foreach(struct table *table, per_package_action action, void *privdata) {
retvalue result, r;
struct cursor *cursor;
const char *package, *control;
r = table_newglobaluniqcursor(table, &cursor);
assert( r != RET_NOTHING );
if( RET_WAS_ERROR(r) )
return r;
result = RET_NOTHING;
while( cursor_nexttemp(table, cursor, &package, &control) ) {
r = action(privdata, package, control);
RET_UPDATE(result, r);
if( RET_WAS_ERROR(r) )
break;
}
r = cursor_close(table, cursor);
RET_ENDUPDATE(result,r);
return result;
}
/********************************************************************************
* Open the different types of tables with their needed flags: *
********************************************************************************/
static retvalue database_table(struct database *database, const char *filename, const char *subtable, DBTYPE type, u_int32_t preflags, int (*dupcompare)(DB *,const DBT *,const DBT *), bool readonly, /*@out@*/struct table **table_p) {
struct table *table;
retvalue r;
table = calloc(1, sizeof(struct table));
if( table == NULL )
return RET_ERROR_OOM;
/* TODO: is filename always an static constant? then we could drop the dup */
table->name = strdup(filename);
if( table->name == NULL ) {
free(table);
return RET_ERROR_OOM;
}
if( subtable != NULL ) {
table->subname = strdup(subtable);
if( table->subname == NULL ) {
free(table->name);
free(table);
return RET_ERROR_OOM;
}
} else
table->subname = NULL;
table->readonly = readonly;
table->verbose = verbose;
r = database_opentable(database, filename, subtable, type, preflags, dupcompare, readonly, &table->berkleydb);
if( RET_WAS_ERROR(r) ) {
free(table->subname);
free(table->name);
free(table);
return r;
}
if( r == RET_NOTHING ) {
assert( readonly );
/* sometimes we don't want a return here, when? */
table->berkleydb = NULL;
r = RET_OK;
}
*table_p = table;
return r;
}
retvalue database_openpackages(struct database *database, const char *identifier, bool readonly, struct table **table_p) {
struct table *table IFSTUPIDCC(=NULL);
retvalue r;
if( database->nopackages ) {
fputs("Internal Error: Accessing packages databse while that was not prepared!\n", stderr);
return RET_ERROR;
}
if( database->packagesdatabaseopen ) {
fputs("Internal Error: Trying to open multiple packages databases at the same time.\nThis should normaly not happen (to avoid triggering bugs in the underlying BerkleyDB)\n", stderr);
return RET_ERROR;
}
r = database_table(database, "packages.db", identifier,
DB_BTREE, 0, NULL, readonly, &table);
assert( r != RET_NOTHING );
if( RET_WAS_ERROR(r) )
return r;
table->flagreset = &database->packagesdatabaseopen;
database->packagesdatabaseopen = true;
*table_p = table;
return RET_OK;
}
/* Get a list of all identifiers having a package list */
retvalue database_listpackages(struct database *database, struct strlist *identifiers) {
return database_listsubtables(database, "packages.db", identifiers);
}
/* drop a database */
retvalue database_droppackages(struct database *database, const char *identifier) {
return database_dropsubtable(database, "packages.db", identifier);
}
......@@ -7,16 +7,42 @@
#ifndef REPREPRO_ERROR_H
#include "error.h"
#endif
#ifndef REPREPRO_STRLIST_H
#include "strlist.h"
#endif
struct database;
struct distribution;
struct table;
struct cursor;
retvalue database_create(struct database **, const char *dbdir, struct distribution *, bool fast, bool nopackages, bool allowunused, bool readonly, size_t waitforlock);
retvalue database_create(struct database **, const char *dbdir, struct distribution *, bool fast, bool nopackages, bool allowunused, bool readonly, size_t waitforlock, bool verbosedb);
retvalue database_close(struct database *);
const char *database_directory(struct database *);
retvalue database_openfiles(struct database *, const char *mirrordir);
retvalue database_openreferences(struct database *);
retvalue database_listpackages(struct database *, /*@out@*/struct strlist *);
retvalue database_droppackages(struct database *, const char *);
retvalue database_openpackages(struct database *, const char *identifier, bool readonly, /*@out@*/struct table **);
retvalue table_close(/*@only@*/struct table *);
bool table_isempty(struct table *);
/* retrieve a record from the database, return RET_NOTHING if there is none: */
retvalue table_getrecord(struct table *, const char *, /*@out@*/char **);
retvalue table_adduniqrecord(struct table *, const char *key, const char *data);
retvalue table_replacerecord(struct table *, const char *key, const char *data);
retvalue table_deleterecord(struct table *, const char *key);
retvalue table_checkkey(struct table *, const char *key);
retvalue table_newglobaluniqcursor(struct table *, /*@out@*/struct cursor **);
retvalue table_newduplicatecursor(struct table *, const char *key, /*@out@*/struct cursor **);
bool cursor_nexttemp(struct table *, struct cursor *, /*@out@*/const char **, /*@out@*/const char **);
retvalue cursor_replace(struct table *, struct cursor *, const char *);
retvalue cursor_close(struct table *, /*@only@*/struct cursor *);
#endif
......@@ -14,9 +14,9 @@ struct database {
char *directory;
struct filesdb *files;
struct references *references;
bool locked;
bool locked, verbose;
int dircreationdepth;
bool nopackages, readonly;
bool nopackages, readonly, packagesdatabaseopen;
int version, compatibilityversion;
};
......
......@@ -31,8 +31,9 @@
#include "error.h"
#include "mprintf.h"
#include "strlist.h"
#include "names.h"
#include "chunks.h"
#include "packages.h"
#include "database.h"
#include "exports.h"
#include "md5sum.h"
#include "copyfile.h"
......@@ -400,7 +401,7 @@ static retvalue callexporthook(const char *confdir,/*@null@*/const char *hook, c
}
}
retvalue export_target(const char *confdir, const char *relativedir, packagesdb packages, const struct exportmode *exportmode, struct release *release, bool onlyifmissing, bool snapshot) {
retvalue export_target(const char *confdir, const char *relativedir, struct table *packages, const struct exportmode *exportmode, struct release *release, bool onlyifmissing, bool snapshot) {
retvalue r;
struct filetorelease *file;
const char *status;
......
......@@ -4,9 +4,6 @@
#ifndef REPREPRO_RELEASE_H
#include "release.h"
#endif
#ifndef REPREPRO_PACKAGES_H
#include "packages.h"
#endif
struct exportmode {
/* "Packages", "Sources" or something like that */
......@@ -25,6 +22,6 @@ struct configiterator;
retvalue exportmode_set(struct exportmode *mode, const char *confdir, struct configiterator *iter);
void exportmode_done(struct exportmode *mode);
retvalue export_target(const char *confdir, const char *relativedir, packagesdb packages, const struct exportmode *exportmode, struct release *release, bool onlymissing, bool snapshot);
retvalue export_target(const char *confdir, const char *relativedir, struct table *packages, const struct exportmode *exportmode, struct release *release, bool onlymissing, bool snapshot);
#endif
......@@ -40,7 +40,6 @@
#include "files.h"
#include "database.h"
#include "target.h"
#include "packages.h"
#include "reference.h"
#include "binaries.h"
#include "sources.h"
......@@ -104,6 +103,7 @@ static size_t waitforlock = 0;
static enum exportwhen export = EXPORT_NORMAL;
int verbose = 0;
static bool fast = false;
static bool verbosedatabase = false;
static enum spacecheckmode spacecheckmode = scm_FULL;
/* default: 100 MB for database to grow */
static off_t reserveddbspace = 1024*1024*100
......@@ -114,7 +114,7 @@ static off_t reservedotherspace = 1024*1024;
* to change something owned by lower owners. */
enum config_option_owner config_state,
#define O(x) owner_ ## x = CONFIG_OWNER_DEFAULT
O(fast), O(mirrordir), O(distdir), O(dbdir), O(listdir), O(confdir), O(logdir), O(overridedir), O(methoddir), O(section), O(priority), O(component), O(architecture), O(packagetype), O(nothingiserror), O(nolistsdownload), O(keepunreferenced), O(keepunneededlists), O(keepdirectories), O(askforpassphrase), O(skipold), O(export), O(waitforlock), O(spacecheckmode), O(reserveddbspace), O(reservedotherspace), O(guessgpgtty);
O(fast), O(mirrordir), O(distdir), O(dbdir), O(listdir), O(confdir), O(logdir), O(overridedir), O(methoddir), O(section), O(priority), O(component), O(architecture), O(packagetype), O(nothingiserror), O(nolistsdownload), O(keepunreferenced), O(keepunneededlists), O(keepdirectories), O(askforpassphrase), O(skipold), O(export), O(waitforlock), O(spacecheckmode), O(reserveddbspace), O(reservedotherspace), O(guessgpgtty), O(verbosedatabase);
#undef O
#define CONFIGSET(variable,value) if(owner_ ## variable <= config_state) { \
......@@ -563,7 +563,7 @@ static retvalue list_in_target(void *data, struct target *target,
const char *packagename = data;
char *control,*version;
result = packages_get(target->packages, packagename, &control);
result = table_getrecord(target->packages, packagename, &control);
if( RET_IS_OK(result) ) {
r = (*target->getversion)(target, control, &version);
if( RET_IS_OK(r) ) {
......@@ -712,17 +712,17 @@ static retvalue printout(UNUSED(void *data),const char *package,const char *chun
ACTION_u_B(dumpcontents) {
retvalue result,r;
packagesdb packages;
struct table *packages;
assert( argc == 2 );
result = packages_initialize(&packages, database, argv[1]);
result = database_openpackages(database, argv[1], true, &packages);
if( RET_WAS_ERROR(result) )
return result;
result = packages_foreach(packages,printout,NULL);
r = packages_done(packages);
r = table_close(packages);
RET_ENDUPDATE(result,r);
return result;
......@@ -1017,7 +1017,7 @@ static retvalue copy(/*@temp@*/void *data, struct target *origtarget,
d->destination->codename);
result = RET_NOTHING;
} else
result = packages_get(origtarget->packages, d->name, &chunk);
result = table_getrecord(origtarget->packages, d->name, &chunk);
if( result == RET_NOTHING && verbose > 2 )
printf("No instance of '%s' found in '%s'!\n",
d->name, origtarget->identifier);
......@@ -1812,14 +1812,6 @@ ACTION_C(createsymlinks) {
/***********************clearvanished***********************************/
static retvalue docount(void *data,UNUSED(const char *a),UNUSED(const char *b)) {
long int *p = data;
(*p)++;
return RET_OK;
}
ACTION_U_D(clearvanished) {
retvalue result,r;
struct distribution *d;
......@@ -1827,7 +1819,7 @@ ACTION_U_D(clearvanished) {
bool *inuse;
int i;
result = packages_getdatabases(database, &identifiers);
result = database_listpackages(database, &identifiers);
if( !RET_IS_OK(result) ) {
return result;
}
......@@ -1860,17 +1852,16 @@ ACTION_U_D(clearvanished) {
if( interrupted() )
return RET_ERROR_INTERRUPTED;
if( delete <= 0 ) {
long int count = 0;
packagesdb db;
r = packages_initialize(&db, database, identifier);
if( !RET_WAS_ERROR(r) )
r = packages_foreach(db, docount, &count);
if( !RET_WAS_ERROR(r) )
r = packages_done(db);
if( count > 0 ) {
fprintf(stderr,
"There are still %ld packages in '%s', not removing (give --delete to do so)!\n", count, identifier);
continue;
struct table *packages;
r = database_openpackages(database, identifier, true,
&packages);
if( RET_IS_OK(r) ) {
if( !table_isempty(packages) ) {
fprintf(stderr,
"There are still packages in '%s', not removing (give --delete to do so)!\n", identifier);
continue;
}
r = table_close(packages);
}
}
if( interrupted() )
......@@ -1882,7 +1873,7 @@ ACTION_U_D(clearvanished) {
/* derference anything left */
references_remove(database, identifier, dereferenced);
/* remove the database */
packages_drop(database, identifier);
database_droppackages(database, identifier);
}
free(inuse);
strlist_done(&identifiers);
......@@ -2199,7 +2190,7 @@ static retvalue callaction(const struct action *action, int argc, const char *ar
result = database_create(&database, dbdir, alldistributions,
fast, ISSET(needs, NEED_NO_PACKAGES),
ISSET(needs, MAY_UNUSED), ISSET(needs, IS_RO),
waitforlock);
waitforlock, verbosedatabase || (verbose >= 30) );
if( !RET_IS_OK(result) ) {
return result;
}
......@@ -2286,6 +2277,8 @@ LO_NOKEEPDIRECTORIES,
LO_NOFAST,
LO_NOSKIPOLD,
LO_NOGUESSGPGTTY,
LO_VERBOSEDB,
LO_NOVERBOSEDB,
LO_EXPORT,
LO_DISTDIR,
LO_DBDIR,
......@@ -2464,6 +2457,12 @@ static void handle_option(int c,const char *optarg) {
case LO_NOFAST:
CONFIGSET(fast, false);
break;
case LO_VERBOSEDB:
CONFIGSET(verbosedatabase, true);
break;
case LO_NOVERBOSEDB:
CONFIGSET(verbosedatabase, false);
break;
case LO_EXPORT:
setexport(optarg);
break;
......@@ -2656,6 +2655,10 @@ int main(int argc,char *argv[]) {
{"nonoguessgpgtty", no_argument, &longoption, LO_GUESSGPGTTY},
{"fast", no_argument, &longoption, LO_FAST},
{"nofast", no_argument, &longoption, LO_NOFAST},
{"verbosedb", no_argument, &longoption, LO_VERBOSEDB},
{"noverbosedb", no_argument, &longoption, LO_NOVERBOSEDB},
{"verbosedatabase", no_argument, &longoption, LO_VERBOSEDB},
{"noverbosedatabase", no_argument, &longoption, LO_NOVERBOSEDB},
{"skipold", no_argument, &longoption, LO_SKIPOLD},
{"noskipold", no_argument, &longoption, LO_NOSKIPOLD},
{"nonoskipold", no_argument, &longoption, LO_SKIPOLD},
......
/* This file is part of "reprepro"
* Copyright (C) 2003,2004,2005 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301 USA
*/
#include <config.h>
#include <assert.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <zlib.h>
#include "error.h"
#include "strlist.h"
#include "names.h"
#include "md5sum.h"
#include "dirs.h"
#include "files.h"
#include "database_p.h"
#include "packages.h"
struct s_packagesdb {
char *identifier;
DB *database;