Commit 185a64d6 authored by Bernhard Link's avatar Bernhard Link

add logging support

parent e4b6e1a0
2007-03-23 Bernhard R. Link <brlink@debian.org>
* first part of logging code
2007-03-16 Bernhard R. Link <brlink@debian.org>
* fix bug not recognizing already existing .bz2 files
when exporting only changes.
......
......@@ -16,12 +16,12 @@ AM_CPPFLAGS = -D_GNU_SOURCE=1 -Wall $(ARCHIVECPP) $(DBCPPFLAGS)
reprepro_LDADD = $(ARCHIVELIBS) $(DBLIBS)
changestool_LDADD = $(ARCHIVELIBS)
reprepro_SOURCES = 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 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 = 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 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 ignore.c names.c copyfile.c $(ARCHIVE_USED)
noinst_HEADERS = changes.h incoming.h guesscomponent.h md5.h md5sum.h dirs.h files.h chunks.h reference.h packages.h binaries.h sources.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 = 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 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
......
......@@ -30,6 +30,7 @@
#include "binaries.h"
#include "names.h"
#include "dpkgversions.h"
#include "log.h"
#include "override.h"
#include "tracking.h"
#include "debfile.h"
......@@ -552,6 +553,8 @@ retvalue binaries_adddeb(const struct deb_headers *deb,const char *dbdir,referen
retvalue r,result;
int i;
assert( logger_isprepared(distribution->logger) );
/* finally put it into one or more architectures of the distribution */
result = RET_NOTHING;
......@@ -566,7 +569,8 @@ retvalue binaries_adddeb(const struct deb_headers *deb,const char *dbdir,referen
if( interrupted() )
r = RET_ERROR_INTERUPTED;
else
r = target_addpackage(t, refs, deb->name,
r = target_addpackage(t, distribution->logger,
refs, deb->name,
deb->version,
control,
filekeys, FALSE,
......@@ -586,7 +590,8 @@ retvalue binaries_adddeb(const struct deb_headers *deb,const char *dbdir,referen
if( interrupted() )
r = RET_ERROR_INTERUPTED;
else
r = target_addpackage(t, refs, deb->name,
r = target_addpackage(t, distribution->logger,
refs, deb->name,
deb->version,
control,
filekeys, FALSE,
......@@ -607,7 +612,8 @@ retvalue binaries_adddeb(const struct deb_headers *deb,const char *dbdir,referen
if( interrupted() )
r = RET_ERROR_INTERUPTED;
else
r = target_addpackage(t, refs, deb->name,
r = target_addpackage(t, distribution->logger,
refs, deb->name,
deb->version,
control,
filekeys, FALSE,
......
......@@ -781,6 +781,10 @@ static retvalue changes_includepkgs(const char *dbdir,references refs,struct dis
retvalue r;
bool_t somethingwasmissed = FALSE;
r = distribution_prepareforwriting(distribution);
if( RET_WAS_ERROR(r) )
return r;
r = RET_NOTHING;
e = changes->files;
......
......@@ -42,6 +42,7 @@
#include "tracking.h"
#include "ignore.h"
#include "override.h"
#include "log.h"
extern int verbose;
......@@ -317,6 +318,8 @@ retvalue dsc_addprepared(const struct dscpackage *pkg,const char *dbdir,referenc
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);
if( !RET_WAS_ERROR(r) ) {
......@@ -324,7 +327,11 @@ retvalue dsc_addprepared(const struct dscpackage *pkg,const char *dbdir,referenc
if( interrupted() )
r = RET_ERROR_INTERUPTED;
else
r = target_addpackage(t,refs,pkg->dsc.name,pkg->dsc.version,pkg->dsc.control,&pkg->filekeys,FALSE,dereferencedfilekeys,trackingdata,ft_SOURCE);
r = target_addpackage(t, distribution->logger, refs,
pkg->dsc.name, pkg->dsc.version,
pkg->dsc.control, &pkg->filekeys,
FALSE, dereferencedfilekeys,
trackingdata, ft_SOURCE);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
......
......@@ -38,6 +38,7 @@
#include "copyfile.h"
#include "tracking.h"
#include "override.h"
#include "log.h"
#include "uploaderslist.h"
#include "distribution.h"
......@@ -72,6 +73,7 @@ retvalue distribution_free(struct distribution *distribution) {
override_free(distribution->overrides.deb);
override_free(distribution->overrides.udeb);
override_free(distribution->overrides.dsc);
logger_free(distribution->logger);
if( distribution->uploaderslist != NULL ) {
uploaders_unlock(distribution->uploaderslist);
}
......@@ -200,7 +202,7 @@ static const char * const allowedfields[] = {
"UDebComponents", "DebIndices", "DscIndices", "UDebIndices",
"Pull", "Contents", "ContentsArchitectures",
"ContentsComponents", "ContentsUComponents",
"Uploaders", "AlsoAcceptFor",
"Uploaders", "AlsoAcceptFor", "Log",
NULL};
assert( chunk !=NULL && distribution != NULL );
......@@ -347,6 +349,17 @@ NULL};
return ret;
}
r->logger = NULL;
ret = chunk_getvalue(chunk,"Log",&option);
if( RET_IS_OK(ret) ) {
ret = logger_init(option, &r->logger);
free(option);
}
if(RET_WAS_ERROR(ret)) {
(void)distribution_free(r);
return ret;
}
ret = chunk_getuniqwordlist(chunk, "AlsoAcceptFor", &r->alsoaccept);
if( RET_WAS_ERROR(ret) ) {
(void)distribution_free(r);
......@@ -846,3 +859,15 @@ void distribution_unloaduploaders(struct distribution *distribution) {
distribution->uploaderslist = NULL;
}
}
retvalue distribution_prepareforwriting(struct distribution *distribution) {
retvalue r;
if( distribution->logger != NULL ) {
r = logger_prepare(distribution->logger);
if( RET_WAS_ERROR(r) )
return r;
}
distribution->lookedat = TRUE;
return RET_OK;
}
......@@ -65,6 +65,8 @@ struct distribution {
/*@null@*/char *uploaders;
/* only loaded after _loaduploaders */
/*@null@*/struct uploaders *uploaderslist;
/* how and where to log */
/*@null@*/struct logger *logger;
/* a list of names beside Codename and Suite to accept .changes
* files via include */
struct strlist alsoaccept;
......@@ -76,10 +78,12 @@ struct distribution {
bool_t lookedat;
};
retvalue distribution_get(/*@out@*/struct distribution **distribution,const char *conf,const char *name, bool_t lookedat);
retvalue distribution_free(/*@only@*/struct distribution *distribution);
/* set lookedat, start logger, ... */
retvalue distribution_prepareforwriting(struct distribution *distribution);
typedef retvalue distribution_each_action(void *data, struct target *t, struct distribution *d);
/* call <action> for each part of <distribution>, if component or architecture is
......
......@@ -43,6 +43,7 @@
#include "dpkgversions.h"
#include "uploaderslist.h"
#include "guesscomponent.h"
#include "log.h"
#include "override.h"
#include "tracking.h"
#include "incoming.h"
......@@ -1122,6 +1123,8 @@ static retvalue add_dsc(const char *dbdir, references refs,
retvalue r;
struct target *t = distribution_getpart(into, p->component, "source", "dsc");
assert( logger_isprepared(into->logger) );
/* finally put it into the source distribution */
r = target_initpackagesdb(t,dbdir);
if( !RET_WAS_ERROR(r) ) {
......@@ -1129,7 +1132,7 @@ static retvalue add_dsc(const char *dbdir, references refs,
if( interrupted() )
r = RET_ERROR_INTERUPTED;
else
r = target_addpackage(t,refs,
r = target_addpackage(t, into->logger, refs,
p->master->dsc.name,
p->master->dsc.version,
p->control,
......@@ -1154,6 +1157,11 @@ static retvalue candidate_add_into(const char *confdir,filesdb filesdb,const cha
return RET_ERROR_INTERUPTED;
d->into->lookedat = TRUE;
if( d->into->logger != NULL ) {
r = logger_prepare(d->into->logger);
if( RET_WAS_ERROR(r) )
return r;
}
tracks = NULL;
if( into->tracking != dt_NONE ) {
......
/* This file is part of "reprepro"
* Copyright (C) 2007 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 <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include <time.h>
#include <malloc.h>
#include "error.h"
#include "strlist.h"
#include "target.h"
#include "log.h"
extern int verbose;
struct logfile {
struct logfile *next;
char *filename;
size_t refcount;
int fd;
} *logfile_root = NULL;
static retvalue logfile_reference(const char *filename,struct logfile **logfile) {
struct logfile *l;
for( l = logfile_root ; l != NULL ; l = l->next ) {
if( strcmp(l->filename, filename) == 0 ) {
l->refcount++;
*logfile = l;
return RET_OK;
}
}
l = malloc(sizeof(struct logfile));
if( l == NULL )
return RET_ERROR_OOM;
l->filename = strdup(filename);
if( l->filename == NULL ) {
free(l);
return RET_ERROR_OOM;
}
l->refcount = 1;
l->fd = -1;
l->next = logfile_root;
logfile_root = l;
*logfile = l;
return RET_OK;
}
static void logfile_dereference(struct logfile *logfile) {
assert( logfile != NULL );
assert( logfile->refcount > 0 );
if( --logfile->refcount == 0 ) {
if( logfile_root == logfile )
logfile_root = logfile->next;
else {
struct logfile *previous = logfile_root;
while( previous != NULL && previous->next != logfile )
previous = previous->next;
assert( previous != NULL );
assert( previous->next == logfile );
previous->next = logfile->next;
}
if( logfile->fd >= 0 ) {
int ret,e;
ret = close(logfile->fd); logfile->fd = -1;
if( ret < 0 ) {
e = errno;
fprintf(stderr,
"Error received when closing log file '%s': %d=%s\n",
logfile->filename, e, strerror(e));
}
}
free(logfile->filename);
free(logfile);
}
}
static retvalue logfile_open(struct logfile *logfile) {
assert( logfile != NULL );
assert( logfile->fd < 0 );
logfile->fd = open(logfile->filename,
O_CREAT|O_APPEND|O_LARGEFILE|O_NOCTTY|O_WRONLY,
0666);
if( logfile->fd < 0 ) {
int e = errno;
fprintf(stderr, "Cannot open/create logfile '%s': %d=%s\n",
logfile->filename, e, strerror(e));
return RET_ERRNO(e);
}
return RET_OK;
}
static retvalue logfile_write(struct logfile *logfile,struct target *target,const char *name,const char *version,const char *oldversion) {
int ret;
time_t currenttime;
struct tm t;
assert( logfile->fd >= 0 );
currenttime = time(NULL);
if( localtime_r(&currenttime, &t) == NULL ) {
if( version != NULL && oldversion != NULL )
ret = dprintf(logfile->fd,
"EEEE-EE-EE EE:EE:EE replace %s %s %s %s %s %s %s\n",
target->codename, target->packagetype,
target->component, target->architecture,
name, version, oldversion);
else if( version != NULL )
ret = dprintf(logfile->fd,
"EEEE-EE-EE EE:EE:EE add %s %s %s %s %s %s\n",
target->codename, target->packagetype,
target->component, target->architecture,
name, version);
else
ret = dprintf(logfile->fd,
"EEEE-EE-EE EE:EE:EE remove %s %s %s %s %s %s\n",
target->codename, target->packagetype,
target->component, target->architecture,
name, oldversion);
} else if( version != NULL && oldversion != NULL )
ret = dprintf(logfile->fd,
"%04d-%02d-%02d %02u:%02u:%02u replace %s %s %s %s %s %s %s\n",
1900+t.tm_year, t.tm_mon+1,
t.tm_mday, t.tm_hour,
t.tm_min, t.tm_sec,
target->codename, target->packagetype,
target->component, target->architecture,
name, version, oldversion);
else if( version != NULL )
ret = dprintf(logfile->fd,
"%04d-%02d-%02d %02u:%02u:%02u add %s %s %s %s %s %s\n",
1900+t.tm_year, t.tm_mon+1,
t.tm_mday, t.tm_hour,
t.tm_min, t.tm_sec,
target->codename, target->packagetype,
target->component, target->architecture,
name, version);
else
ret = dprintf(logfile->fd,
"%04d-%02d-%02d %02u:%02u:%02u remove %s %s %s %s %s %s\n",
1900+t.tm_year, t.tm_mon+1,
t.tm_mday, t.tm_hour,
t.tm_min, t.tm_sec,
target->codename, target->packagetype,
target->component, target->architecture,
name, oldversion);
if( ret < 0 ) {
int e = errno;
fprintf(stderr, "Error writing to log file '%s': %d=%s",
logfile->filename, e, strerror(e));
return RET_ERRNO(e);
}
return RET_OK;
}
struct logger {
struct logfile *logfile;
};
void logger_free(struct logger *logger) {
if( logger == NULL )
return;
if( logger->logfile != NULL )
logfile_dereference(logger->logfile);
free(logger);
}
retvalue logger_init(const char *option,struct logger **logger_p) {
struct logger *n;
retvalue r;
if( option == NULL || *option == '\0' ) {
*logger_p = NULL;
return RET_NOTHING;
}
n = malloc(sizeof(struct logger));
if( n == NULL )
return RET_ERROR_OOM;
r = logfile_reference(option,&n->logfile);
if( RET_WAS_ERROR(r) ) {
free(n);
return r;
}
*logger_p = n;
return RET_OK;
}
retvalue logger_prepare(struct logger *logger) {
retvalue r;
if( logger->logfile == NULL )
return RET_NOTHING;
if( logger->logfile != NULL && logger->logfile->fd < 0 ) {
r = logfile_open(logger->logfile);
} else
r = RET_OK;
return r;
}
bool_t logger_isprepared(/*@null@*/const struct logger *logger) {
if( logger == NULL )
return TRUE;
if( logger->logfile != NULL && logger->logfile->fd < 0 )
return FALSE;
return TRUE;
}
void logger_log(struct logger *log,struct target *target,const char *name,const char *version,const char *oldversion,const char *control,const char *oldcontrol,const struct strlist *filekeys, const struct strlist *oldfilekeys) {
assert( name != NULL );
assert( control != NULL || oldcontrol != NULL );
/* so that logfile_write can detect a replacement by the oldversion */
if( oldcontrol != NULL && oldversion == NULL )
oldversion = "#unparseable#";
assert( version != NULL || oldversion != NULL );
if( log->logfile != NULL )
logfile_write(log->logfile, target, name, version, oldversion);
}
#ifndef REPREPRO_LOG_H
#define REPREPRO_LOG_H
#ifndef REPREPRO_STRLIST_H
#include "strlist.h"
#endif
struct target;
struct logger;
enum log_action { LOG_PACKAGE_ADD, LOG_PACKAGE_REPLACE, LOG_PACKAGE_REMOVE};
retvalue logger_init(const char *option,struct logger **);
void logger_free(/*@only@*/struct logger *);
retvalue logger_prepare(struct logger *logger);
bool_t logger_isprepared(/*@null@*/const struct logger *logger);
void logger_log(struct logger *,struct target *,const char *name,/*@null@*/const char *version,/*@null@*/const char *oldversion,/*@null@*/const char *control,/*@null@*/const char *oldcontrol,/*@null@*/const struct strlist *filekeys,/*@null@*/const struct strlist *oldfilekeys);
/* do work that is left */
retvalue logger_continue(struct logger*);
/* wait for all jobs to finish */
retvalue logger_wait(struct logger*);
#endif
......@@ -58,6 +58,7 @@
#include "dpkgversions.h"
#include "incoming.h"
#include "override.h"
#include "log.h"
#ifndef STD_BASE_DIR
#define STD_BASE_DIR "."
......@@ -394,7 +395,7 @@ ACTION_R(addreference) {
}
struct remove_args {/*@temp@*/references refs; int count; /*@temp@*/ const char * const *names; bool_t *gotremoved; int todo;/*@temp@*/struct strlist *removedfiles;/*@temp@*/struct trackingdata *trackingdata;};
struct remove_args {/*@temp@*/references refs; int count; /*@temp@*/ const char * const *names; bool_t *gotremoved; int todo;/*@temp@*/struct strlist *removedfiles;/*@temp@*/struct trackingdata *trackingdata;struct logger *logger;};
static retvalue remove_from_target(/*@temp@*/void *data, struct target *target,
struct distribution *distribution) {
......@@ -410,7 +411,9 @@ static retvalue remove_from_target(/*@temp@*/void *data, struct target *target,
result = RET_NOTHING;
for( i = 0 ; i < d->count ; i++ ){
r = target_removepackage(target,d->refs,d->names[i],d->removedfiles,d->trackingdata);
r = target_removepackage(target, d->logger, d->refs,
d->names[i], NULL,
d->removedfiles, d->trackingdata);
if( RET_IS_OK(r) ) {
if( ! d->gotremoved[i] )
d->todo--;
......@@ -441,6 +444,10 @@ ACTION_D(remove) {
return r;
}
r = distribution_prepareforwriting(distribution);
if( RET_WAS_ERROR(r) )
return r;
if( distribution->tracking != dt_NONE ) {
r = tracking_initialize(&tracks,dbdir,distribution);
if( RET_WAS_ERROR(r) ) {
......@@ -464,6 +471,7 @@ ACTION_D(remove) {
d.gotremoved = calloc(d.count,sizeof(*d.gotremoved));
d.refs = references;
d.removedfiles = dereferenced;
d.logger = distribution->logger;
if( d.gotremoved == NULL )
result = RET_ERROR_OOM;
else
......@@ -1103,7 +1111,10 @@ static retvalue copy(/*@temp@*/void *data, struct target *origtarget,
return result;
}
result = target_addpackage(dsttarget, d->refs, d->name, version, chunk,
assert( logger_isprepared(d->destination->logger) );
result = target_addpackage(dsttarget, d->destination->logger,
d->refs, d->name, version, chunk,
&filekeys, TRUE, d->removedfiles,
NULL, '?');
free(version);
......@@ -1136,6 +1147,11 @@ ACTION_D(copy) {
distribution_free(destination);
return result;
}
result = distribution_prepareforwriting(destination);
if( RET_WAS_ERROR(result) ) {
distribution_free(destination);
return result;
}
if( destination->tracking != dt_NONE ) {
fprintf(stderr, "WARNING: copy does not yet support trackingdata and will ignore trackingdata in '%s'!\n", destination->codename);
......@@ -1576,6 +1592,12 @@ ACTION_D(includedeb) {
return RET_ERROR;
}
r = distribution_prepareforwriting(distribution);
if( RET_WAS_ERROR(r) ) {
(void)distribution_free(distribution);
return RET_ERROR;
}
if( distribution->tracking != dt_NONE ) {
result = tracking_initialize(&tracks,dbdir,distribution);
if( RET_WAS_ERROR(result) ) {
......@@ -1640,6 +1662,12 @@ ACTION_D(includedsc) {
RET_ENDUPDATE(result,r);
return result;
}
result = distribution_prepareforwriting(distribution);
if( RET_WAS_ERROR(result) ) {
r = distribution_free(distribution);
RET_ENDUPDATE(result,r);
return result;
}
if( distribution->tracking != dt_NONE ) {
result = tracking_initialize(&tracks,dbdir,distribution);
......
......@@ -29,11 +29,8 @@
#include "names.h"
#include "md5sum.h"
#include "dirs.h"
#include "reference.h"
#include "files.h"
#include "target.h"
#include "packages.h"
#include "tracking.h"
struct s_packagesdb {
char *identifier;
......@@ -130,7 +127,7 @@ retvalue packages_initialize(packagesdb *db,const char *dbpath,const char *ident
}
/* replace a save chunk with another */
static retvalue packages_replace(packagesdb db,const char *package,const char *chunk) {
retvalue packages_replace(packagesdb db,const char *package,const char *chunk) {
int dbret;
DBT key,data;
......@@ -156,7 +153,7 @@ static retvalue packages_replace(packagesdb db,const char *package,const char *c
}
/* save a given chunk in the database */
static retvalue packages_add(packagesdb db,const char *package,const char *chunk) {
retvalue packages_add(packagesdb db,const char *package,const char *chunk) {
int dbret;
DBT key,data;
......@@ -330,57 +327,6 @@ retvalue packages_modifyall(packagesdb db,per_package_modifier *action,const str
return result;
}
retvalue packages_insert(references refs, packagesdb packagesdb,
const char *packagename, const char *controlchunk,
const struct strlist *files,
struct strlist *oldfiles,
struct strlist *dereferencedfilekeys,
struct trackingdata *trackingdata,
enum filetype filetype,
/*@only@*/char *oldsource,/*@only@*/char *oldsversion) {
retvalue result,r;
/* mark it as needed by this distribution */
r = references_insert(refs,packagesdb->identifier,files,oldfiles);
if( RET_WAS_ERROR(r) ) {
if( oldfiles != NULL )
strlist_done(oldfiles);
return r;
}
/* Add package to the distribution's database */
if( oldfiles != NULL ) {
result = packages_replace(packagesdb,packagename,controlchunk);
} else {
result = packages_add(packagesdb,packagename,controlchunk);
}
if( RET_WAS_ERROR(result) ) {
if( oldfiles != NULL )
strlist_done(oldfiles);
return result;
}
r = trackingdata_insert(trackingdata,filetype,files,oldsource,oldsversion,oldfiles,refs);
RET_UPDATE(result,r);
/* remove old references to files */
if( oldfiles != NULL ) {
r = references_delete(refs,packagesdb->identifier,
oldfiles,files,dereferencedfilekeys);
RET_UPDATE(result,r);
}
return result;
}
/* Get a list of all identifiers having a package list */
retvalue packages_getdatabases(const char *dbpath, struct strlist *identifiers) {
char *filename;
......
......@@ -15,12 +15,6 @@
#ifndef REPREPRO_FILES_H
#include "files.h"
#endif
#ifndef REPREPRO_REFERENCE_H
#include "reference.h"
#endif
#ifndef REPREPRO_TRACKINGT_H
#include "trackingt.h"
#endif
typedef struct s_packagesdb *packagesdb;
......@@ -34,29 +28,15 @@ retvalue packages_init(packagesdb *pkgs,const char *dbpath,const char *codename,
retvalue packages_done(/*@only@*/packagesdb db);
/* save a given chunk in the database */
//retvalue packages_add(packagesdb db,const char *package,const char *chunk);
retvalue packages_add(packagesdb,const char *package,const char *chunk);
/* replace a save chunk with another */
//retvalue packages_replace(packagesdb db,const char *package,const char *chunk);
retvalue packages_replace(packagesdb,const char *package,const char *chunk);
/* remove a given chunk from the database */
retvalue packages_remove(packagesdb db,const char *package);
/* get the saved chunk from the database,
* returns RET_NOTHING, if there is none*/
retvalue packages_get(packagesdb db,const char *package,/*@out@*/char **chunk);
/* insert a chunk in the packages database, adding and deleting
* references and insert files while that.
* unreference oldfiles, if != NULL, and strlist_done it!
* if != NULL, add filekeys losing reference to derferencedfilekeys*/
retvalue packages_insert(references refs, packagesdb packagesdb,
const char *packagename, const char *controlchunk,
const struct strlist *files,
/*@null@*/struct strlist *oldfiles,
/*@null@*/struct strlist *dereferencedfilekeys,
/*@null@*/struct trackingdata *,
enum filetype filetype,
/*@null@*//*@only@*/char *oldsource,
/*@null@*//*@only@*/char *oldsversion);
/* action to be called by packages_forall */
typedef retvalue per_package_action(void *data,const char *package,/*@temp@*/const char *chunk);
......
......@@ -32,6 +32,7 @@
#include "distribution.h"
#include "terms.h"
#include "filterlist.h"
#include "log.h"
extern int verbose;
......@@ -704,9 +705,14 @@ static retvalue pull_install(const char *dbdir,filesdb filesdb,references refs,s
retvalue result,r;
struct pull_target *u;
assert( logger_isprepared(distribution->distribution->logger) );
result = RET_NOTHING;
for( u=distribution->targets ; u != NULL ; u=u->next ) {
r = upgradelist_install(u->upgradelist,dbdir,filesdb,refs,u->ignoredelete,dereferencedfilekeys);
r = upgradelist_install(u->upgradelist,
distribution->distribution->logger,
dbdir, filesdb, refs,
u->ignoredelete, dereferencedfilekeys);
RET_UPDATE(distribution->distribution->status, r);
RET_UPDATE(result,r);
upgradelist_free(u->upgradelist);
......@@ -734,6 +740,12 @@ retvalue pull_update(const char *dbdir,filesdb filesdb,references refs,struct pu
retvalue result,r;