Commit b2b087f2 authored by Bernhard Link's avatar Bernhard Link

start of some refactoring

parent 8374d090
......@@ -480,7 +480,7 @@ retvalue aptmethod_queueindexfile(struct aptmethod *method,const char *origfile,
/*****************what to do with received files************************/
/* process a received file, possibly copying it around... */
static inline retvalue todo_done(const struct tobedone *todo,const char *filename,const char *md5sum,filesdb filesdb) {
static inline retvalue todo_done(const struct tobedone *todo,const char *filename,const char *md5sum,struct database *database) {
char *calculatedmd5;
/* if the file is somewhere else, copy it: */
......@@ -528,10 +528,9 @@ static inline retvalue todo_done(const struct tobedone *todo,const char *filenam
if( todo->filekey != NULL ) {
retvalue r;
assert(filesdb != NULL);
assert(todo->md5sum != NULL);
r = files_add(filesdb,todo->filekey,todo->md5sum);
r = files_add(database, todo->filekey, todo->md5sum);
if( RET_WAS_ERROR(r) )
return r;
}
......@@ -620,14 +619,14 @@ static retvalue urierror(struct aptmethod *method,const char *uri,/*@only@*/char
}
/* look where a received file has to go to: */
static retvalue uridone(struct aptmethod *method,const char *uri,const char *filename,/*@null@*/const char *md5sum,filesdb filesdb) {
static retvalue uridone(struct aptmethod *method,const char *uri,const char *filename,/*@null@*/const char *md5sum,struct database *database) {
struct tobedone *todo,*lasttodo;
lasttodo = NULL; todo = method->tobedone;
while( todo != NULL ) {
if( strcmp(todo->uri,uri) == 0) {
retvalue r;
r = todo_done(todo,filename,md5sum,filesdb);
r = todo_done(todo, filename, md5sum, database);
/* remove item: */
if( lasttodo == NULL )
......@@ -708,7 +707,7 @@ static inline retvalue gotcapabilities(struct aptmethod *method,const char *chun
return RET_OK;
}
static inline retvalue goturidone(struct aptmethod *method,const char *chunk,filesdb filesdb) {
static inline retvalue goturidone(struct aptmethod *method,const char *chunk,struct database *database) {
retvalue r;
char *uri,*filename,*md5,*size,*md5sum;
......@@ -750,7 +749,7 @@ static inline retvalue goturidone(struct aptmethod *method,const char *chunk,fil
return r;
}
r = uridone(method,uri,filename,md5sum,filesdb);
r = uridone(method, uri, filename, md5sum, database);
free(uri);
free(filename);
free(md5sum);
......@@ -783,7 +782,7 @@ static inline retvalue goturierror(struct aptmethod *method,const char *chunk) {
return r;
}
static inline retvalue parsereceivedblock(struct aptmethod *method,const char *input,filesdb filesdb) {
static inline retvalue parsereceivedblock(struct aptmethod *method,const char *input,struct database *database) {
const char *p;
retvalue r;
#define OVERLINE {while( *p != '\0' && *p != '\n') p++; if(*p == '\n') p++; }
......@@ -837,7 +836,7 @@ static inline retvalue parsereceivedblock(struct aptmethod *method,const char *i
OVERLINE;
if( verbose >= 1 )
logmessage(method,p,"got");
return goturidone(method,p,filesdb);
return goturidone(method, p, database);
default:
fprintf(stderr,"Got error or unsupported mesage: '%s'\n",input);
return RET_ERROR;
......@@ -868,7 +867,7 @@ static inline retvalue parsereceivedblock(struct aptmethod *method,const char *i
}
}
static retvalue receivedata(struct aptmethod *method,filesdb filesdb) {
static retvalue receivedata(struct aptmethod *method,struct database *database) {
retvalue result;
ssize_t r;
char *p;
......@@ -934,7 +933,7 @@ static retvalue receivedata(struct aptmethod *method,filesdb filesdb) {
return result;
}
*p ='\0'; p++; r--;
res = parsereceivedblock(method,method->inputbuffer,filesdb);
res = parsereceivedblock(method, method->inputbuffer, database);
if( r > 0 )
memmove(method->inputbuffer,p,r);
method->alreadyread = r;
......@@ -1044,7 +1043,7 @@ static retvalue checkchilds(struct aptmethodrun *run) {
}
/* *workleft is always set, even when return indicated error. (workleft < 0 when critical)*/
static retvalue readwrite(struct aptmethodrun *run,/*@out@*/int *workleft,filesdb filesdb) {
static retvalue readwrite(struct aptmethodrun *run,/*@out@*/int *workleft,struct database *database) {
int maxfd,v;
fd_set readfds,writefds;
struct aptmethod *method;
......@@ -1096,7 +1095,7 @@ static retvalue readwrite(struct aptmethodrun *run,/*@out@*/int *workleft,filesd
maxfd = 0;
for( method = run->methods ; method != NULL ; method = method->next ) {
if( method->stdout != -1 && FD_ISSET(method->stdout,&readfds) ) {
r = receivedata(method,filesdb);
r = receivedata(method, database);
RET_UPDATE(result,r);
}
if( method->stdin != -1 && FD_ISSET(method->stdin,&writefds) ) {
......@@ -1107,7 +1106,7 @@ static retvalue readwrite(struct aptmethodrun *run,/*@out@*/int *workleft,filesd
return result;
}
retvalue aptmethod_download(struct aptmethodrun *run,const char *methoddir,filesdb filesdb) {
retvalue aptmethod_download(struct aptmethodrun *run,const char *methoddir,struct database *database) {
struct aptmethod *method;
retvalue result,r;
int workleft;
......@@ -1127,7 +1126,7 @@ retvalue aptmethod_download(struct aptmethodrun *run,const char *methoddir,files
do {
r = checkchilds(run);
RET_UPDATE(result,r);
r = readwrite(run,&workleft,filesdb);
r = readwrite(run, &workleft, database);
RET_UPDATE(result,r);
// TODO: check interrupted here...
} while( workleft > 0 );
......
......@@ -293,7 +293,7 @@ retvalue ubinaries_doreoverride(const struct distribution *distribution,const ch
return RET_OK;
}
retvalue binaries_retrack(UNUSED(struct target *t),const char *packagename,const char *chunk, trackingdb tracks,references refs) {
retvalue binaries_retrack(UNUSED(struct target *t),const char *packagename,const char *chunk, trackingdb tracks,struct database *database) {
retvalue r;
const char *sourcename;
char *fsourcename,*sourceversion,*arch,*filekey;
......@@ -366,7 +366,8 @@ retvalue binaries_retrack(UNUSED(struct target *t),const char *packagename,const
return r;
}
assert( r != RET_NOTHING );
r = trackedpackage_addfilekey(tracks,pkg,filetype,filekey,TRUE,refs);
r = trackedpackage_addfilekey(tracks,pkg, filetype, filekey, TRUE,
database);
if( RET_WAS_ERROR(r) ) {
trackedpackage_free(pkg);
return r;
......@@ -550,7 +551,7 @@ retvalue binaries_complete(const struct deb_headers *pkg,const char *filekey,con
return RET_OK;
}
retvalue binaries_adddeb(const struct deb_headers *deb,const char *dbdir,references refs,const char *forcearchitecture,const char *packagetype,struct distribution *distribution,struct strlist *dereferencedfilekeys,struct trackingdata *trackingdata,const char *component,const struct strlist *filekeys, const char *control) {
retvalue binaries_adddeb(const struct deb_headers *deb,struct database *database,const char *forcearchitecture,const char *packagetype,struct distribution *distribution,struct strlist *dereferencedfilekeys,struct trackingdata *trackingdata,const char *component,const struct strlist *filekeys, const char *control) {
retvalue r,result;
int i;
......@@ -564,15 +565,15 @@ retvalue binaries_adddeb(const struct deb_headers *deb,const char *dbdir,referen
struct target *t = distribution_getpart(distribution,
component, deb->architecture,
packagetype);
r = target_initpackagesdb(t,dbdir);
r = target_initpackagesdb(t, database);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
if( interrupted() )
r = RET_ERROR_INTERUPTED;
else
r = target_addpackage(t, distribution->logger,
refs, deb->name,
deb->version,
database,
deb->name, deb->version,
control,
filekeys, FALSE,
dereferencedfilekeys,
......@@ -585,15 +586,15 @@ retvalue binaries_adddeb(const struct deb_headers *deb,const char *dbdir,referen
struct target *t = distribution_getpart(distribution,
component, forcearchitecture,
packagetype);
r = target_initpackagesdb(t,dbdir);
r = target_initpackagesdb(t, database);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
if( interrupted() )
r = RET_ERROR_INTERUPTED;
else
r = target_addpackage(t, distribution->logger,
refs, deb->name,
deb->version,
database,
deb->name, deb->version,
control,
filekeys, FALSE,
dereferencedfilekeys,
......@@ -607,15 +608,15 @@ retvalue binaries_adddeb(const struct deb_headers *deb,const char *dbdir,referen
if( strcmp(distribution->architectures.values[i],"source") == 0 )
continue;
t = distribution_getpart(distribution,component,distribution->architectures.values[i],packagetype);
r = target_initpackagesdb(t,dbdir);
r = target_initpackagesdb(t, database);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
if( interrupted() )
r = RET_ERROR_INTERUPTED;
else
r = target_addpackage(t, distribution->logger,
refs, deb->name,
deb->version,
database,
deb->name, deb->version,
control,
filekeys, FALSE,
dereferencedfilekeys,
......@@ -630,22 +631,22 @@ retvalue binaries_adddeb(const struct deb_headers *deb,const char *dbdir,referen
return result;
}
static inline retvalue checkadddeb(const char *dbdir,struct distribution *distribution,const char *component,const char *architecture,const char *packagetype,bool_t tracking,const struct deb_headers *deb,bool_t permitnewerold) {
static inline retvalue checkadddeb(struct database *database,struct distribution *distribution,const char *component,const char *architecture,const char *packagetype,bool_t tracking,const struct deb_headers *deb,bool_t permitnewerold) {
retvalue r;
struct target *t;
t = distribution_getpart(distribution,
component, architecture, packagetype);
assert( t != NULL );
r = target_initpackagesdb(t, dbdir);
r = target_initpackagesdb(t, database);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
if( interrupted() )
r = RET_ERROR_INTERUPTED;
else
r = target_checkaddpackage(t,
deb->name,
deb->version, tracking,
deb->name, deb->version,
tracking,
permitnewerold);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
......@@ -653,7 +654,7 @@ static inline retvalue checkadddeb(const char *dbdir,struct distribution *distri
return r;
}
retvalue binaries_checkadddeb(const struct deb_headers *deb,const char *dbdir,const char *forcearchitecture,const char *packagetype,struct distribution *distribution,bool_t tracking,const char *component,bool_t permitnewerold) {
retvalue binaries_checkadddeb(const struct deb_headers *deb,struct database *database,const char *forcearchitecture,const char *packagetype,struct distribution *distribution,bool_t tracking,const char *component,bool_t permitnewerold) {
retvalue r,result;
int i;
......@@ -661,13 +662,13 @@ retvalue binaries_checkadddeb(const struct deb_headers *deb,const char *dbdir,co
result = RET_NOTHING;
if( strcmp(deb->architecture,"all") != 0 ) {
r = checkadddeb(dbdir, distribution,
r = checkadddeb(database, distribution,
component, deb->architecture, packagetype,
tracking, deb,
permitnewerold);
RET_UPDATE(result,r);
} else if( forcearchitecture != NULL && strcmp(forcearchitecture,"all") != 0 ) {
r = checkadddeb(dbdir, distribution,
r = checkadddeb(database, distribution,
component, forcearchitecture, packagetype,
tracking, deb,
permitnewerold);
......@@ -676,7 +677,7 @@ retvalue binaries_checkadddeb(const struct deb_headers *deb,const char *dbdir,co
const char *a = distribution->architectures.values[i];
if( strcmp(a, "source") == 0 )
continue;
r = checkadddeb(dbdir, distribution,
r = checkadddeb(database, distribution,
component, a, packagetype,
tracking, deb,
permitnewerold);
......
This diff is collapsed.
......@@ -106,7 +106,7 @@ static retvalue deb_read(/*@out@*/struct debpackage **pkg, const char *filename,
return RET_OK;
}
retvalue deb_prepare(/*@out@*/struct debpackage **deb,filesdb filesdb,const char * const forcecomponent,const char * const forcearchitecture,const char *forcesection,const char *forcepriority,const char * const packagetype,struct distribution *distribution,const char *debfilename,const char * const givenfilekey,const char * const givenmd5sum,int delete,bool_t needsourceversion,const struct strlist *allowed_binaries,const char *expectedsourcepackage,const char *expectedsourceversion){
retvalue deb_prepare(/*@out@*/struct debpackage **deb,struct database *database,const char * const forcecomponent,const char * const forcearchitecture,const char *forcesection,const char *forcepriority,const char * const packagetype,struct distribution *distribution,const char *debfilename,const char * const givenfilekey,const char * const givenmd5sum,int delete,bool_t needsourceversion,const struct strlist *allowed_binaries,const char *expectedsourcepackage,const char *expectedsourceversion){
retvalue r;
struct debpackage *pkg;
const struct overrideinfo *oinfo;
......@@ -265,7 +265,7 @@ retvalue deb_prepare(/*@out@*/struct debpackage **deb,filesdb filesdb,const char
return RET_ERROR_OOM;
}
if( givenfilekey == NULL ) {
r = files_ready(filesdb, pkg->filekey,pkg->md5sum);
r = files_ready(database, pkg->filekey,pkg->md5sum);
if( RET_WAS_ERROR(r) ) {
deb_free(pkg);
return r;
......@@ -273,7 +273,7 @@ retvalue deb_prepare(/*@out@*/struct debpackage **deb,filesdb filesdb,const char
}
} else {
assert(givenfilekey == NULL);
r = files_include(filesdb,debfilename,pkg->filekey,NULL,&pkg->md5sum,delete);
r = files_include(database,debfilename,pkg->filekey,NULL,&pkg->md5sum,delete);
if( RET_WAS_ERROR(r) ) {
deb_free(pkg);
return r;
......@@ -293,14 +293,14 @@ retvalue deb_prepare(/*@out@*/struct debpackage **deb,filesdb filesdb,const char
return RET_OK;
}
retvalue deb_hardlinkfiles(struct debpackage *deb,filesdb filesdb,const char *debfilename) {
retvalue deb_hardlinkfiles(struct debpackage *deb,struct database *database,const char *debfilename) {
assert( deb != NULL );
assert( deb->filekey != NULL && deb-> md5sum != NULL );
return files_hardlink(filesdb, debfilename, deb->filekey, deb->md5sum);
return files_hardlink(database, debfilename, deb->filekey, deb->md5sum);
}
retvalue deb_addprepared(const struct debpackage *pkg, const char *dbdir,references refs,const char *forcearchitecture,const char *packagetype,struct distribution *distribution,struct strlist *dereferencedfilekeys,struct trackingdata *trackingdata) {
return binaries_adddeb(&pkg->deb, dbdir, refs, forcearchitecture,
retvalue deb_addprepared(const struct debpackage *pkg,struct database *database,const char *forcearchitecture,const char *packagetype,struct distribution *distribution,struct strlist *dereferencedfilekeys,struct trackingdata *trackingdata) {
return binaries_adddeb(&pkg->deb, database, forcearchitecture,
packagetype, distribution, dereferencedfilekeys,
trackingdata,
pkg->component, &pkg->filekeys, pkg->deb.control);
......@@ -310,7 +310,7 @@ retvalue deb_addprepared(const struct debpackage *pkg, const char *dbdir,referen
* putting things with architecture of "all" into <d->architectures> (and also
* causing error, if it is not one of them otherwise)
* if component is NULL, guessing it from the section. */
retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *forcecomponent,const char *forcearchitecture,const char *forcesection,const char *forcepriority,const char *packagetype,struct distribution *distribution,const char *debfilename,const char *givenfilekey,const char *givenmd5sum,int delete,struct strlist *dereferencedfilekeys,/*@null@*/trackingdb tracks){
retvalue deb_add(struct database *database,const char *forcecomponent,const char *forcearchitecture,const char *forcesection,const char *forcepriority,const char *packagetype,struct distribution *distribution,const char *debfilename,const char *givenfilekey,const char *givenmd5sum,int delete,struct strlist *dereferencedfilekeys,/*@null@*/trackingdb tracks){
struct debpackage *pkg;
retvalue r;
struct trackingdata trackingdata;
......@@ -318,7 +318,7 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
if( givenfilekey != NULL && givenmd5sum != NULL ) {
assert( delete == D_INPLACE );
}
r = deb_prepare(&pkg,filesdb,forcecomponent,forcearchitecture,forcesection,forcepriority,packagetype,distribution,debfilename,givenfilekey,givenmd5sum,delete,tracks!=NULL,NULL,NULL,NULL);
r = deb_prepare(&pkg,database,forcecomponent,forcearchitecture,forcesection,forcepriority,packagetype,distribution,debfilename,givenfilekey,givenmd5sum,delete,tracks!=NULL,NULL,NULL,NULL);
if( RET_WAS_ERROR(r) )
return r;
......@@ -333,7 +333,7 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
}
}
r = binaries_adddeb(&pkg->deb, dbdir, refs, forcearchitecture,
r = binaries_adddeb(&pkg->deb, database, forcearchitecture,
packagetype, distribution, dereferencedfilekeys,
(tracks!=NULL)?&trackingdata:NULL,
pkg->component, &pkg->filekeys, pkg->deb.control);
......@@ -342,7 +342,7 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
if( tracks != NULL ) {
retvalue r2;
r2 = trackingdata_finish(tracks, &trackingdata, refs, dereferencedfilekeys);
r2 = trackingdata_finish(tracks, &trackingdata, database, dereferencedfilekeys);
RET_ENDUPDATE(r,r2);
}
......
......@@ -194,7 +194,7 @@ static retvalue dsc_adddsc(struct dscpackage *pkg) {
}
retvalue dsc_prepare(struct dscpackage **dsc,filesdb filesdb,const char *forcecomponent,const char *forcesection,const char *forcepriority,struct distribution *distribution,const char *sourcedir, const char *dscfilename,const char *filekey,const char *basename,const char *directory,const char *md5sum,int delete, const char *expectedname, const char *expectedversion){
retvalue dsc_prepare(struct dscpackage **dsc,struct database *database,const char *forcecomponent,const char *forcesection,const char *forcepriority,struct distribution *distribution,const char *sourcedir, const char *dscfilename,const char *filekey,const char *basename,const char *directory,const char *md5sum,int delete, const char *expectedname, const char *expectedversion){
retvalue r;
struct dscpackage *pkg;
const struct overrideinfo *oinfo;
......@@ -289,11 +289,15 @@ retvalue dsc_prepare(struct dscpackage **dsc,filesdb filesdb,const char *forceco
if( !RET_WAS_ERROR(r) ) {
/* evil things will hapen if delete is not D_INPLACE when
* called from includechanges */
r = files_include(filesdb,dscfilename,pkg->dscfilekey,md5sum,&pkg->dscmd5sum,delete);
r = files_include(database,
dscfilename, pkg->dscfilekey,
md5sum, &pkg->dscmd5sum, delete);
}
if( !RET_WAS_ERROR(r) ) {
r = files_includefiles(filesdb,sourcedir,&pkg->dsc.basenames,&pkg->filekeys,&pkg->dsc.md5sums,delete);
r = files_includefiles(database,
sourcedir, &pkg->dsc.basenames, &pkg->filekeys,
&pkg->dsc.md5sums, delete);
}
/* Calculate the chunk to include: */
......@@ -314,20 +318,20 @@ retvalue dsc_prepare(struct dscpackage **dsc,filesdb filesdb,const char *forceco
return r;
}
retvalue dsc_addprepared(const struct dscpackage *pkg,const char *dbdir,references refs,struct distribution *distribution,struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata){
retvalue dsc_addprepared(const struct dscpackage *pkg,struct database *database,struct distribution *distribution,struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata){
retvalue r;
struct target *t = distribution_getpart(distribution,pkg->component,"source","dsc");
assert( logger_isprepared(distribution->logger) );
/* finally put it into the source distribution */
r = target_initpackagesdb(t,dbdir);
r = target_initpackagesdb(t, database);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
if( interrupted() )
r = RET_ERROR_INTERUPTED;
else
r = target_addpackage(t, distribution->logger, refs,
r = target_addpackage(t, distribution->logger, database,
pkg->dsc.name, pkg->dsc.version,
pkg->dsc.control, &pkg->filekeys,
FALSE, dereferencedfilekeys,
......@@ -344,7 +348,7 @@ retvalue dsc_addprepared(const struct dscpackage *pkg,const char *dbdir,referenc
* If basename, filekey and directory are != NULL, then they are used instead
* of being newly calculated.
* (And all files are expected to already be in the pool). */
retvalue dsc_add(const char *dbdir,references refs,filesdb filesdb,const char *forcecomponent,const char *forcesection,const char *forcepriority,struct distribution *distribution,const char *dscfilename,int delete,struct strlist *dereferencedfilekeys, trackingdb tracks){
retvalue dsc_add(struct database *database,const char *forcecomponent,const char *forcesection,const char *forcepriority,struct distribution *distribution,const char *dscfilename,int delete,struct strlist *dereferencedfilekeys, trackingdb tracks){
retvalue r;
struct dscpackage *pkg;
struct trackingdata trackingdata;
......@@ -354,7 +358,7 @@ retvalue dsc_add(const char *dbdir,references refs,filesdb filesdb,const char *f
if( RET_WAS_ERROR(r) )
return r;
r = dsc_prepare(&pkg,filesdb,forcecomponent,forcesection,forcepriority,distribution,dscdirectory,dscfilename,NULL,NULL,NULL,NULL,delete,NULL,NULL);
r = dsc_prepare(&pkg,database,forcecomponent,forcesection,forcepriority,distribution,dscdirectory,dscfilename,NULL,NULL,NULL,NULL,delete,NULL,NULL);
free(dscdirectory);
if( RET_WAS_ERROR(r) )
return r;
......@@ -372,14 +376,15 @@ retvalue dsc_add(const char *dbdir,references refs,filesdb filesdb,const char *f
}
}
r = dsc_addprepared(pkg,dbdir,refs,distribution,
r = dsc_addprepared(pkg, database, distribution,
dereferencedfilekeys,
(tracks!=NULL)?&trackingdata:NULL);
dsc_free(pkg);
if( tracks != NULL ) {
retvalue r2;
r2 = trackingdata_finish(tracks, &trackingdata, refs, dereferencedfilekeys);
r2 = trackingdata_finish(tracks, &trackingdata, database,
dereferencedfilekeys);
RET_ENDUPDATE(r,r2);
}
return r;
......
......@@ -31,6 +31,8 @@
#include "names.h"
#include "release.h"
#include "distribution.h"
#include "filelist.h"
#include "files.h"
extern int verbose;
......@@ -190,7 +192,7 @@ struct addcontentsdata {
int rate;
size_t work, leisure;
struct filelist_list *contents;
filesdb files;
struct database *db;
};
static retvalue addpackagetocontents(void *data, const char *packagename, const char *chunk) {
......@@ -213,12 +215,12 @@ static retvalue addpackagetocontents(void *data, const char *packagename, const
assert( r != RET_NOTHING );
if( RET_WAS_ERROR(r) )
return r;
r = files_getfilelist(d->files, filekey, package, d->contents);
r = files_getfilelist(d->db, filekey, package, d->contents);
if( r == RET_NOTHING ) {
if( d->rate <= 1 || d->work <= d->leisure/(d->rate-1) ) {
if( verbose > 3 )
printf("Reading filelist for %s\n", filekey);
r = files_genfilelist(d->files, filekey, package, d->contents);
r = files_genfilelist(d->db, filekey, package, d->contents);
if( RET_IS_OK(r) )
d->work++;
} else {
......@@ -234,7 +236,7 @@ static retvalue addpackagetocontents(void *data, const char *packagename, const
return r;
}
static retvalue genarchcontents(filesdb files, struct distribution *distribution, const char *dbdir, const char *architecture, struct release *release, bool_t onlyneeded) {
static retvalue genarchcontents(struct database *database, struct distribution *distribution, const char *architecture, struct release *release, bool_t onlyneeded) {
retvalue r;
struct target *target;
char *contentsfilename;
......@@ -244,7 +246,7 @@ static retvalue genarchcontents(filesdb files, struct distribution *distribution
data.rate = distribution->contents.rate;
data.work = data.leisure = 0;
data.files = files;
data.db = database;
if( distribution->contents.components.count > 0 )
components = &distribution->contents.components;
......@@ -291,7 +293,7 @@ static retvalue genarchcontents(filesdb files, struct distribution *distribution
continue;
if( !strlist_in(components, target->component) )
continue;
r = target_initpackagesdb(target, dbdir);
r = target_initpackagesdb(target, database);
if( RET_WAS_ERROR(r) )
break;
r = packages_foreach(target->packages,addpackagetocontents,&data);
......@@ -309,7 +311,7 @@ static retvalue genarchcontents(filesdb files, struct distribution *distribution
return r;
}
static retvalue genarchudebcontents(filesdb files, struct distribution *distribution, const char *dbdir, const char *architecture, struct release *release, bool_t onlyneeded) {
static retvalue genarchudebcontents(struct database *database, struct distribution *distribution, const char *architecture, struct release *release, bool_t onlyneeded) {
retvalue r;
struct target *target;
char *contentsfilename;
......@@ -319,7 +321,7 @@ static retvalue genarchudebcontents(filesdb files, struct distribution *distribu
data.rate = distribution->contents.rate;
data.work = data.leisure = 0;
data.files = files;
data.db = database;
if( distribution->contents.ucomponents.count > 0 )
components = &distribution->contents.ucomponents;
......@@ -364,7 +366,7 @@ static retvalue genarchudebcontents(filesdb files, struct distribution *distribu
continue;
if( !strlist_in(components, target->component) )
continue;
r = target_initpackagesdb(target, dbdir);
r = target_initpackagesdb(target, database);
if( RET_WAS_ERROR(r) )
break;
r = packages_foreach(target->packages,addpackagetocontents,&data);
......@@ -382,7 +384,7 @@ static retvalue genarchudebcontents(filesdb files, struct distribution *distribu
return r;
}
retvalue contents_generate(filesdb files, struct distribution *distribution, const char *dbdir, struct release *release, bool_t onlyneeded) {
retvalue contents_generate(struct database *database, struct distribution *distribution, struct release *release, bool_t onlyneeded) {
retvalue result,r;
int i;
const struct strlist *architectures;
......@@ -399,12 +401,12 @@ retvalue contents_generate(filesdb files, struct distribution *distribution, con
continue;
if( !distribution->contents.flags.nodebs) {
r = genarchcontents(files, distribution, dbdir,
r = genarchcontents(database, distribution,
architecture,release,onlyneeded);
RET_UPDATE(result,r);
}
if( distribution->contents.flags.udebs) {
r = genarchudebcontents(files, distribution, dbdir,
r = genarchudebcontents(database, distribution,
architecture,release,onlyneeded);
RET_UPDATE(result,r);
}
......
......@@ -418,6 +418,64 @@ retvalue distribution_foreach_part(struct distribution *distribution,const char
return result;
}
/* call <action> for each part of <distribution>, within initpackagesdb/closepackagesdb */
retvalue distribution_foreach_rwopenedpart(struct distribution *distribution,struct database *database,const char *component,const char *architecture,const char *packagetype,distribution_each_action action,void *data) {
retvalue result,r;
struct target *t;
result = RET_NOTHING;
for( t = distribution->targets ; t != NULL ; t = t->next ) {
if( component != NULL && strcmp(component,t->component) != 0 )
continue;
if( architecture != NULL && strcmp(architecture,t->architecture) != 0 )
continue;
if( packagetype != NULL && strcmp(packagetype,t->packagetype) != 0 )
continue;
r = target_initpackagesdb(t, database);
RET_UPDATE(result, r);
if( RET_WAS_ERROR(r) )
return result;
r = action(data, t, distribution);
RET_UPDATE(result, r);
// TODO: how to seperate this in those affecting distribution
// and those that do not?
RET_UPDATE(distribution->status, r);
r = target_closepackagesdb(t);
RET_UPDATE(distribution->status, r);
RET_UPDATE(result, r);
if( RET_WAS_ERROR(result) )
return result;
}
return result;
}
/* call <action> for each part of <distribution>, within initpackagesdb/closepackagesdb */
retvalue distribution_foreach_roopenedpart(struct distribution *distribution,struct database *database,const char *component,const char *architecture,const char *packagetype,distribution_each_action action,void *data) {
retvalue result,r;
struct target *t;
result = RET_NOTHING;
for( t = distribution->targets ; t != NULL ; t = t->next ) {
if( component != NULL && strcmp(component,t->component) != 0 )
continue;
if( architecture != NULL && strcmp(architecture,t->architecture) != 0 )
continue;
if( packagetype != NULL && strcmp(packagetype,t->packagetype) != 0 )
continue;
r = target_initpackagesdb(t, database);
RET_UPDATE(result, r);
if( RET_WAS_ERROR(r) )
return result;
r = action(data, t, distribution);
RET_UPDATE(result, r);
r = target_closepackagesdb(t);
RET_UPDATE(result, r);
if( RET_WAS_ERROR(result) )
return result;
}
return result;
}
struct target *distribution_gettarget(const struct distribution *distribution,const char *component,const char *architecture,const char *packagetype) {
struct target *t = distribution->targets;
......@@ -560,8 +618,8 @@ retvalue distribution_get(const char *confdir,const char *logdir,const char *nam
}
retvalue distribution_snapshot(struct distribution *distribution,
const char *confdir, const char *dbdir, const char *distdir,
references refs, const char *name) {
const char *confdir, const char *distdir,
struct database *database, const char *name) {
struct target *target;
retvalue result,r;
struct release *release;
......@@ -578,7 +636,8 @@ retvalue distribution_snapshot(struct distribution *distribution,
RET_ENDUPDATE(result,r);
if( RET_WAS_ERROR(r) )
break;
r = target_export(target,confdir,dbdir,FALSE,TRUE,release);
r = target_export(target, confdir, database,
FALSE, TRUE, release);
RET_UPDATE(result,r);
if( RET_WAS_ERROR(r) )
break;
......@@ -598,22 +657,22 @@ retvalue distribution_snapshot(struct distribution *distribution,
return r;
/* add references so that the pool files belonging to it are not deleted */
for( target=distribution->targets; target != NULL ; target = target->next ) {
r = target_addsnapshotreference(target,dbdir,refs,name);
r = target_addsnapshotreference(target, database, name);
RET_UPDATE(result,r);
}
return result;
}
static retvalue export(struct distribution *distribution,
const char *confdir, const char *dbdir, const char *distdir,
filesdb files, bool_t onlyneeded) {
const char *confdir, const char *distdir,
struct database *database, bool_t onlyneeded) {
struct target *target;
retvalue result,r;
struct release *release;
assert( distribution != NULL );
r = release_init(dbdir,distdir,distribution->codename,&release);
r = release_init(&release, database, distdir, distribution->codename);
if( RET_WAS_ERROR(r) )
return r;
......@@ -623,7 +682,8 @@ static retvalue export(struct distribution *distribution,
RET_ENDUPDATE(result,r);
if( RET_WAS_ERROR(r) )
break;
r = target_export(target,confdir,dbdir,onlyneeded,FALSE,release);
r = target_export(target, confdir, database,
onlyneeded, FALSE, release);
RET_UPDATE(result,r);
if( RET_WAS_ERROR(r) )
break;
......@@ -635,7 +695,8 @@ static retvalue export(struct distribution *distribution,
}
}
if( !RET_WAS_ERROR(result) && distribution->contents.rate > 0 ) {
r = contents_generate(files, distribution, dbdir, release, onlyneeded);
r = contents_generate(database, distribution,
release, onlyneeded);
}
if( RET_WAS_ERROR(result) )
release_free(release);
......@@ -650,8 +711,8 @@ static retvalue export(struct distribution *distribution,
return result;
}
retvalue distribution_fullexport(struct distribution *distribution,const char *confdir,const char *dbdir,const char *distdir, filesdb files) {
return export(distribution,confdir,dbdir,distdir,files,FALSE);
retvalue distribution_fullexport(struct distribution *distribution,const char *confdir,const char *distdir, struct database *database) {
return export(distribution,confdir,distdir,database,FALSE);
}
retvalue distribution_freelist(struct distribution *distributions) {
......@@ -669,8 +730,8 @@ retvalue distribution_freelist(struct distribution *distributions) {
retvalue distribution_exportandfreelist(enum exportwhen when,
struct distribution *distributions,
const char *confdir,const char *dbdir, const char *distdir,
filesdb files) {
const char *confdir,const char *distdir,
struct database *database) {
retvalue result,r;
bool_t todo = FALSE;
struct distribution *d;
......@@ -725,7 +786,8 @@ retvalue distribution_exportandfreelist(enum exportwhen when,
"Please report this and how you got this message as bugreport. Thanks.\n"
"Doing a export despite --export=changed....\n",
d->codename);
r = export(d,confdir,dbdir,distdir,files,TRUE);
r = export(d, confdir, distdir,
database, TRUE);
RET_UPDATE(result,r);
break;
}
......@@ -735,7 +797,7 @@ retvalue distribution_exportandfreelist(enum exportwhen when,
( d->status == RET_NOTHING &&
when != EXPORT_CHANGED) ||
when == EXPORT_FORCE);
r = export(d,confdir,dbdir,distdir,files, TRUE);
r = export(d, confdir, distdir, database, TRUE);
RET_UPDATE(result,<