Commit 82efa89a authored by Bernhard Link's avatar Bernhard Link

next step of tracking code

parent d09c4f93
......@@ -7,6 +7,6 @@ bin_PROGRAMS = reprepro
AM_CPPFLAGS = -D_GNU_SOURCE=1 -DPKGDATADIR=\"$(pkgdatadir)\" -Wall
reprepro_SOURCES = 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 extractcontrol.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
noinst_HEADERS = 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 extractcontrol.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
noinst_HEADERS = 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 extractcontrol.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
MAINTAINERCLEANFILES = Makefile.in configure install-sh stamp-h.in aclocal.m4 config.h.in mkinstalldirs
......@@ -31,6 +31,7 @@
#include "names.h"
#include "dpkgversions.h"
#include "override.h"
#include "tracking.h"
extern int verbose;
......@@ -283,7 +284,7 @@ retvalue ubinaries_doreoverride(const struct alloverrides *ao,const char *packag
return RET_OK;
}
retvalue binaries_retrack(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,references refs) {
retvalue r;
const char *sourcename;
char *fsourcename,*sourceversion,*arch,*filekey;
......@@ -380,3 +381,36 @@ retvalue binaries_retrack(struct target *t,const char *packagename,const char *c
return r;
}
retvalue binaries_getsourceandversion(UNUSED(struct target *t),const char *chunk,const char *packagename,char **source,char **version) {
retvalue r;
char *sourcename,*sourceversion;
//TODO: elliminate duplicate code!
assert(packagename!=NULL);
/* is there a sourcename */
r = chunk_getnameandversion(chunk,"Source",&sourcename,&sourceversion);
if( RET_WAS_ERROR(r) )
return r;
if( r == RET_NOTHING ) {
sourceversion = NULL;
sourcename = strdup(packagename);
if( sourcename == NULL )
return RET_ERROR_OOM;
}
if( sourceversion == NULL ) {
r = chunk_getvalue(chunk,"Version",&sourceversion);
if( RET_WAS_ERROR(r) ) {
free(sourcename);
return r;
}
if( r == RET_NOTHING ) {
free(sourcename);
fprintf(stderr,"Did not find Version in chunk:'%s'\n",chunk);
return RET_ERROR;
}
}
*source = sourcename;
*version = sourceversion;
return RET_OK;
}
......@@ -23,6 +23,7 @@ char *ubinaries_getupstreamindex(struct target *target,const char *suite_from,
retvalue binaries_doreoverride(const struct alloverrides *alloverrides,const char *packagename,const char *controlchunk,/*@out@*/char **newcontrolchunk);
retvalue ubinaries_doreoverride(const struct alloverrides *alloverrides,const char *packagename,const char *controlchunk,/*@out@*/char **newcontrolchunk);
retvalue binaries_retrack(struct target *t,const char *packagename,const char *chunk, trackingdb tracks,references refs);
retvalue binaries_getsourceandversion(struct target *,const char *chunk,const char *packagename,char **source,char **version);
......
......@@ -86,6 +86,8 @@ struct fileentry {
char *component;
/* only set after changes_includefiles */
char *filekey;
/* set between checkpkg and includepkg */
union { struct dscpackage *dsc; struct debpackage *deb;} pkg;
};
struct changes {
......@@ -99,12 +101,12 @@ struct changes {
/* Things to be set by changes_fixfields: */
/* the component source files are put into */
const char *srccomponent;
/* != NULL if changesfile was put into pool/ */
/*@null@*/ char *changesfilekey;
/* the directory where source files are put into */
char *srcdirectory;
/* (only to warn if multiple are used) */
const char *firstcomponent;
/* if tracks != NULL, the package to track, otherwise NULL*/
struct trackedpackage *trackedpkg;
};
static void freeentries(/*@only@*/struct fileentry *entry) {
......@@ -135,7 +137,8 @@ static void changes_free(/*@only@*/struct changes *changes) {
strlist_done(&changes->distributions);
free(changes->control);
free(changes->srcdirectory);
trackedpackage_free(changes->trackedpkg);
free(changes->changesfilekey);
// trackedpackage_free(changes->trackedpkg);
}
free(changes);
}
......@@ -709,7 +712,7 @@ static retvalue changes_includefiles(filesdb filesdb,const char *filename,struct
return r;
}
static retvalue changes_includepkgs(const char *dbdir,references refs,filesdb filesdb,struct distribution *distribution,struct changes *changes,const struct alloverrides *ao,int force,/*@null@*/struct strlist *dereferencedfilekeys, bool_t onlysigned) {
static retvalue changes_checkpkgs(filesdb filesdb,struct distribution *distribution,struct changes *changes,const struct alloverrides *ao, bool_t onlysigned) {
struct fileentry *e;
retvalue r;
bool_t somethingwasmissed = FALSE;
......@@ -727,37 +730,34 @@ static retvalue changes_includepkgs(const char *dbdir,references refs,filesdb fi
if( fullfilename == NULL )
return RET_ERROR_OOM;
if( e->type == fe_DEB ) {
r = deb_add(dbdir,refs,filesdb,
r = deb_prepare(&e->pkg.deb,filesdb,
e->component,e->architecture,
e->section,e->priority,
"deb",
distribution,fullfilename,
e->filekey,e->md5sum,
ao->deb,
force,D_INPLACE,dereferencedfilekeys);
ao->deb,D_INPLACE);
if( r == RET_NOTHING )
somethingwasmissed = TRUE;
} else if( e->type == fe_UDEB ) {
r = deb_add(dbdir,refs,filesdb,
r = deb_prepare(&e->pkg.deb,filesdb,
e->component,e->architecture,
e->section,e->priority,
"udeb",
distribution,fullfilename,
e->filekey,e->md5sum,
ao->udeb,
force,D_INPLACE,dereferencedfilekeys);
ao->udeb,D_INPLACE);
if( r == RET_NOTHING )
somethingwasmissed = TRUE;
} else if( e->type == fe_DSC ) {
assert(changes->srccomponent!=NULL);
assert(changes->srcdirectory!=NULL);
r = dsc_add(dbdir,refs,filesdb,
r = dsc_prepare(&e->pkg.dsc,filesdb,
changes->srccomponent,e->section,e->priority,
distribution,fullfilename,
e->filekey,e->basename,
changes->srcdirectory,e->md5sum,
ao->dsc,
force,D_INPLACE,dereferencedfilekeys,onlysigned);
ao->dsc,D_INPLACE,onlysigned);
if( r == RET_NOTHING )
somethingwasmissed = TRUE;
}
......@@ -773,6 +773,48 @@ static retvalue changes_includepkgs(const char *dbdir,references refs,filesdb fi
}
return r;
}
static retvalue changes_includepkgs(const char *dbdir,references refs,struct distribution *distribution,struct changes *changes,int force,/*@null@*/struct strlist *dereferencedfilekeys, /*@null@*/struct trackingdata *trackingdata) {
struct fileentry *e;
retvalue r;
bool_t somethingwasmissed = FALSE;
r = RET_NOTHING;
e = changes->files;
while( e != NULL ) {
if( e->type != fe_DEB && e->type != fe_DSC && e->type != fe_UDEB) {
e = e->next;
continue;
}
if( e->type == fe_DEB ) {
r = deb_addprepared(e->pkg.deb,dbdir,refs,
e->architecture,"deb",
distribution,force,dereferencedfilekeys,trackingdata);
if( r == RET_NOTHING )
somethingwasmissed = TRUE;
} else if( e->type == fe_UDEB ) {
r = deb_addprepared(e->pkg.deb,dbdir,refs,
e->architecture,"udeb",
distribution,force,dereferencedfilekeys,trackingdata);
if( r == RET_NOTHING )
somethingwasmissed = TRUE;
} else if( e->type == fe_DSC ) {
r = dsc_addprepared(e->pkg.dsc,dbdir,refs,
distribution,force,dereferencedfilekeys,trackingdata);
if( r == RET_NOTHING )
somethingwasmissed = TRUE;
}
if( RET_WAS_ERROR(r) )
break;
e = e->next;
}
if( RET_IS_OK(r) && somethingwasmissed ) {
return RET_NOTHING;
}
return r;
}
/* insert the given .changes into the mirror in the <distribution>
* if forcecomponent, forcesection or forcepriority is NULL
......@@ -780,7 +822,7 @@ static retvalue changes_includepkgs(const char *dbdir,references refs,filesdb fi
retvalue changes_add(const char *dbdir,trackingdb const tracks,references refs,filesdb filesdb,const char *packagetypeonly,const char *forcecomponent,const char *forcearchitecture,const char *forcesection,const char *forcepriority,struct distribution *distribution,const struct alloverrides *ao,const char *changesfilename,int force,int delete,struct strlist *dereferencedfilekeys,bool_t onlysigned) {
retvalue result,r;
struct changes *changes;
bool_t newtrack;
struct trackingdata trackingdata;
r = changes_read(changesfilename,&changes,packagetypeonly,forcearchitecture,force,onlysigned);
if( RET_WAS_ERROR(r) )
......@@ -792,86 +834,93 @@ retvalue changes_add(const char *dbdir,trackingdb const tracks,references refs,f
fprintf(stderr,"Warning: .changes put in a distribution not listed within it!\n");
}
if( tracks != NULL ) {
newtrack = FALSE;
r = tracking_get(tracks,changes->source,changes->version,&changes->trackedpkg);
if( r == RET_NOTHING ) {
newtrack = TRUE;
r = tracking_new(tracks,changes->source,changes->version,&changes->trackedpkg);
}
if( RET_WAS_ERROR(r) ) {
changes_free(changes);
return r;
}
}
#ifndef GCCHASLEARNEDIT
else newtrack = FALSE;
#endif
/* look for component, section and priority to be correct or guess them*/
r = changes_fixfields(distribution,changesfilename,changes,forcecomponent,forcesection,forcepriority,ao);
if( RET_WAS_ERROR(r) ) {
changes_free(changes);
return r;
}
/* do some tests if values are sensible */
r = changes_check(changesfilename,changes,forcearchitecture);
if( RET_WAS_ERROR(r) ) {
changes_free(changes);
return r;
}
if( !RET_WAS_ERROR(r) )
r = changes_check(changesfilename,changes,forcearchitecture);
/* add files in the pool */
//TODO: D_DELETE would fail here, what to do?
r = changes_includefiles(filesdb,changesfilename,changes,delete);
if( RET_WAS_ERROR(r) ) {
changes_free(changes);
return r;
}
if( !RET_WAS_ERROR(r) )
r = changes_includefiles(filesdb,changesfilename,changes,delete);
if( !RET_WAS_ERROR(r) )
r = changes_checkpkgs(filesdb,distribution,changes,ao,delete);
/* add the source and binary packages in the given distribution */
result = changes_includepkgs(dbdir,refs,filesdb,
distribution,changes,ao,force,
dereferencedfilekeys, onlysigned);
if( RET_WAS_ERROR(r) ) {
changes_free(changes);
return r;
}
if( tracks != NULL ) {
r = trackingdata_summon(tracks,changes->source,changes->version,&trackingdata);
if( RET_WAS_ERROR(r) ) {
changes_free(changes);
return r;
}
if( distribution->trackingoptions.includechanges ) {
char *filekey;const char *basename;
const char *basename;
assert( changes->srcdirectory != NULL );
basename = dirs_basename(changesfilename);
filekey = calc_dirconcat(changes->srcdirectory,basename);
if( filekey == NULL ) {
changes->changesfilekey =
calc_dirconcat(changes->srcdirectory,basename);
if( changes->changesfilekey == NULL ) {
changes_free(changes);
trackingdata_done(&trackingdata);
return RET_ERROR_OOM;
}
r = files_include(filesdb,changesfilename,filekey,
NULL,NULL,
(result==RET_NOTHING)?D_COPY:delete);
if( !RET_WAS_ERROR(r) ) {
r = trackedpackage_addfilekey(tracks,changes->trackedpkg,ft_CHANGES,filekey,refs);
/* always D_COPY, and only delete it afterwards... */
r = files_include(filesdb,changesfilename,
changes->changesfilekey,
NULL,NULL,D_COPY);
if( RET_WAS_ERROR(r) ) {
changes_free(changes);
trackingdata_done(&trackingdata);
return r;
}
free(filekey);
changesfilename = NULL;
}
}
/* add the source and binary packages in the given distribution */
result = changes_includepkgs(dbdir,refs,
distribution,changes,force,dereferencedfilekeys,
(tracks!=NULL)?&trackingdata:NULL);
if( RET_WAS_ERROR(r) ) {
if( tracks != NULL ) {
trackingdata_done(&trackingdata);
}
changes_free(changes);
return r;
}
if( tracks != NULL ) {
if( changes->changesfilekey != NULL ) {
assert( changes->srcdirectory != NULL );
r = trackedpackage_addfilekey(tracks,trackingdata.pkg,ft_CHANGES,changes->changesfilekey,refs);
RET_ENDUPDATE(result,r);
}
if( newtrack ) {
r = tracking_put(tracks,changes->trackedpkg);
if( trackingdata.isnew ) {
r = tracking_put(tracks,trackingdata.pkg);
} else {
r = tracking_replace(tracks,changes->trackedpkg);
r = tracking_replace(tracks,trackingdata.pkg);
}
if( RET_WAS_ERROR(r) ) {
trackingdata_done(&trackingdata);
RET_ENDUPDATE(result,r);
if( RET_WAS_ERROR(result) ) {
changes_free(changes);
return r;
return result;
}
}
if( delete >= D_MOVE && changesfilename != NULL ) {
if( result == RET_NOTHING && delete < D_DELETE ) {
if( result == RET_NOTHING && delete < D_DELETE &&
changes->changesfilekey == NULL) {
if( verbose >= 0 ) {
fprintf(stderr,"Not deleting '%s' as no package was added or some package was missed.\n(Use --delete --delete to delete anyway in such cases)\n",changesfilename);
}
......
......@@ -103,7 +103,7 @@ struct debpackage {
char *md5sum;
};
static void deb_free(/*@only@*/struct debpackage *pkg) {
void deb_free(/*@only@*/struct debpackage *pkg) {
if( pkg != NULL ) {
free(pkg->package);free(pkg->version);
free(pkg->source);free(pkg->architecture);
......@@ -275,33 +275,11 @@ static retvalue deb_calclocations(struct debpackage *pkg,/*@null@*/const char *g
return r;
}
static retvalue deb_copyfiles(filesdb filesdb,struct debpackage *pkg,const char *debfilename, int delete) {
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,const struct overrideinfo *binoverride,int delete){
retvalue r;
r = files_include(filesdb,debfilename,pkg->filekey,NULL,&pkg->md5sum,delete);
return r;
}
static retvalue deb_checkfiles(struct debpackage *pkg,const char *md5sum) {
/* Not much to do here, as anything should already be done... */
pkg->md5sum = strdup(md5sum);
if( pkg->md5sum == NULL )
return RET_ERROR_OOM;
return RET_OK;
}
/* insert the given .deb into the mirror in <component> in the <distribution>
* 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,const struct overrideinfo *binoverride,int force,int delete,struct strlist *dereferencedfilekeys){
retvalue r,result;
struct debpackage *pkg;
const struct overrideinfo *oinfo;
const struct strlist *components;
int i;
assert( (givenmd5sum!=NULL && givenfilekey!=NULL ) ||
(givenmd5sum==NULL && givenfilekey==NULL ) );
......@@ -370,15 +348,13 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
/* some sanity checks: */
if( forcearchitecture != NULL && strcmp(forcearchitecture,"all") == 0 )
forcearchitecture = NULL;
if( forcearchitecture != NULL &&
if( forcearchitecture != NULL && strcmp(forcearchitecture,"all") != 0 &&
strcmp(pkg->architecture,forcearchitecture) != 0 &&
strcmp(pkg->architecture,"all") != 0 ) {
fprintf(stderr,"Cannot checking in '%s' into architecture '%s', as it is '%s'!",
debfilename,forcearchitecture,pkg->architecture);
deb_free(pkg);
/* TODO: this should be moved upwards...
if( delete >= D_DELETE ) {
if( verbose >= 0 )
fprintf(stderr,"Deleting '%s' as requested!\n",debfilename);
......@@ -386,6 +362,7 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
fprintf(stderr,"Error deleting '%s': %m\n",debfilename);
}
}
*/
return RET_ERROR;
} else if( strcmp(pkg->architecture,"all") != 0 &&
!strlist_in( &distribution->architectures, pkg->architecture )) {
......@@ -393,10 +370,8 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
debfilename,pkg->architecture);
(void)strlist_fprint(stderr,&distribution->architectures);
(void)fputs("'\n",stderr);
if( force <= 0 ) {
deb_free(pkg);
return RET_ERROR;
}
deb_free(pkg);
return RET_ERROR;
}
if( !strlist_in(components,pkg->component) ) {
fprintf(stderr,"While checking in '%s': Would put in component '%s', but that is not available!\n",debfilename,pkg->component);
......@@ -409,25 +384,44 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
deb_free(pkg);
return r;
}
/* then looking if we already have this, or copy it in */
if( givenfilekey != NULL ) {
assert(givenmd5sum != NULL);
if( givenfilekey != NULL && givenmd5sum != NULL ) {
assert( delete == D_INPLACE );
r = deb_checkfiles(pkg,givenmd5sum);
} else
r = deb_copyfiles(filesdb,pkg,debfilename,delete);
if( RET_WAS_ERROR(r) ) {
deb_free(pkg);
return r;
}
pkg->md5sum = strdup(givenmd5sum);
if( pkg->md5sum == NULL ) {
deb_free(pkg);
return RET_ERROR_OOM;
}
} else {
assert(givenmd5sum == NULL);
r = files_include(filesdb,debfilename,pkg->filekey,NULL,&pkg->md5sum,delete);
if( r == RET_NOTHING ) {
fprintf(stderr,"File '%s' vanished unexpectedly.\n",debfilename);
r = RET_ERROR;
}
if( RET_WAS_ERROR(r) ) {
deb_free(pkg);
return r;
}
}
assert( pkg->md5sum != NULL );
/* Prepare everything that can be prepared beforehand */
r = deb_complete(pkg,oinfo);
if( RET_WAS_ERROR(r) ) {
deb_free(pkg);
return r;
}
*deb = pkg;
return RET_OK;
}
retvalue deb_addprepared(const struct debpackage *pkg, const char *dbdir,references refs,const char *forcearchitecture,const char *packagetype,struct distribution *distribution,int force,struct strlist *dereferencedfilekeys,struct trackingdata *trackingdata){
retvalue r,result;
int i;
/* finaly put it into one or more architectures of the distribution */
result = RET_NOTHING;
......@@ -437,17 +431,17 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
r = target_initpackagesdb(t,dbdir);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
r = target_addpackage(t,refs,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE,dereferencedfilekeys);
r = target_addpackage(t,refs,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE,dereferencedfilekeys,trackingdata,ft_ARCH_BINARY);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
RET_UPDATE(result,r);
} else if( forcearchitecture != NULL ) {
} else if( forcearchitecture != NULL && strcmp(forcearchitecture,"all") != 0 ) {
struct target *t = distribution_getpart(distribution,pkg->component,forcearchitecture,packagetype);
r = target_initpackagesdb(t,dbdir);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
r = target_addpackage(t,refs,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE,dereferencedfilekeys);
r = target_addpackage(t,refs,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE,dereferencedfilekeys,trackingdata,ft_ALL_BINARY);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
......@@ -460,14 +454,35 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
r = target_initpackagesdb(t,dbdir);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
r = target_addpackage(t,refs,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE,dereferencedfilekeys);
r = target_addpackage(t,refs,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE,dereferencedfilekeys,trackingdata,ft_ALL_BINARY);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
RET_UPDATE(result,r);
}
deb_free(pkg);
// deb_free(pkg);
return result;
}
/* insert the given .deb into the mirror in <component> in the <distribution>
* 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,const struct overrideinfo *binoverride,int force,int delete,struct strlist *dereferencedfilekeys){
struct debpackage *pkg;
retvalue r;
if( givenfilekey != NULL && givenmd5sum != NULL ) {
assert( delete == D_INPLACE );
}
r = deb_prepare(&pkg,filesdb,forcecomponent,forcearchitecture,forcesection,forcepriority,packagetype,distribution,debfilename,givenfilekey,givenmd5sum,binoverride,delete);
if( RET_WAS_ERROR(r) )
return r;
r = deb_addprepared(pkg,dbdir,refs,forcearchitecture,packagetype,distribution,force, dereferencedfilekeys,NULL);
deb_free(pkg);
return r;
}
......@@ -23,4 +23,10 @@
* information there),
* if dereferencedfilekeys is != NULL, add there filekeys that lost a reference */
retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,/*@null@*/const char *forcecomponent,/*@null@*/const char *forcearchitecture,/*@null@*/const char *forcesection,/*@null@*/const char *forcepriority,const char *packagetype,struct distribution *distribution,const char *debfilename,/*@null@*/const char *givenfilekey,/*@null@*/const char *givenmd5sum,/*@null@*/const struct overrideinfo *binoverride,int force,int delete,/*@null@*/struct strlist *dereferencedfilekeys);
/* in two steps */
struct debpackage;
retvalue deb_addprepared(const struct debpackage *pkg, const char *dbdir,references refs,const char *forcearchitecture,const char *packagetype,struct distribution *distribution,int force,struct strlist *dereferencedfilekeys,struct trackingdata *trackingdata);
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,const struct overrideinfo *binoverride,int delete);
void deb_free(/*@only@*/struct debpackage *pkg);
#endif
......@@ -128,7 +128,7 @@ struct dscpackage {
struct strlist filekeys;
};
static void dsc_free(/*@only@*/struct dscpackage *pkg) {
void dsc_free(/*@only@*/struct dscpackage *pkg) {
if( pkg != NULL ) {
free(pkg->package);free(pkg->version);
free(pkg->control);
......@@ -368,13 +368,8 @@ static retvalue dsc_checkfiles(filesdb filesdb,
return r;
}
/* insert the given .dsc into the mirror in <component> in the <distribution>
* if component is NULL, guessing it from the section.
* If basename, filekey and directory are != NULL, then they are used instead
* of beeing 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,const char *filekey,const char *basename,const char *directory,const char *md5sum,const struct overrideinfo *srcoverride,int force,int delete,struct strlist *dereferencedfilekeys, bool_t onlysigned){
retvalue dsc_prepare(struct dscpackage **dsc,filesdb filesdb,const char *forcecomponent,const char *forcesection,const char *forcepriority,struct distribution *distribution,const char *dscfilename,const char *filekey,const char *basename,const char *directory,const char *md5sum,const struct overrideinfo *srcoverride,int delete, bool_t onlysigned){
retvalue r;
struct dscpackage *pkg;
const struct overrideinfo *oinfo;
......@@ -390,7 +385,7 @@ retvalue dsc_add(const char *dbdir,references refs,filesdb filesdb,const char *f
return RET_ERROR;
}
/* Then take a closer look to the file: */
/* Then take a closer look in the file: */
r = dsc_read(&pkg,dscfilename,onlysigned);
if( RET_WAS_ERROR(r) ) {
......@@ -467,18 +462,44 @@ retvalue dsc_add(const char *dbdir,references refs,filesdb filesdb,const char *f
if( !RET_WAS_ERROR(r) )
r = dsc_complete(pkg,oinfo);
if( RET_IS_OK(r) )
*dsc = pkg;
else
dsc_free(pkg);
return r;
}
retvalue dsc_addprepared(const struct dscpackage *pkg,const char *dbdir,references refs,struct distribution *distribution,int force,struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata){
retvalue r;
struct target *t = distribution_getpart(distribution,pkg->component,"source","dsc");
/* finaly put it into the source distribution */
r = target_initpackagesdb(t,dbdir);
if( !RET_WAS_ERROR(r) ) {
struct target *t = distribution_getpart(distribution,pkg->component,"source","dsc");
r = target_initpackagesdb(t,dbdir);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
r = target_addpackage(t,refs,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE,dereferencedfilekeys);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
retvalue r2;
r = target_addpackage(t,refs,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE,dereferencedfilekeys,trackingdata,ft_SOURCE);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
dsc_free(pkg);
return r;
}
/* insert the given .dsc into the mirror in <component> in the <distribution>
* if component is NULL, guessing it from the section.
* If basename, filekey and directory are != NULL, then they are used instead
* of beeing 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,const char *filekey,const char *basename,const char *directory,const char *md5sum,const struct overrideinfo *srcoverride,int force,int delete,struct strlist *dereferencedfilekeys, bool_t onlysigned){
retvalue r;
struct dscpackage *pkg;
r = dsc_prepare(&pkg,filesdb,forcecomponent,forcesection,forcepriority,distribution,dscfilename,filekey,basename,directory,md5sum,srcoverride,delete,onlysigned);
if( RET_WAS_ERROR(r) )
return r;
r = dsc_addprepared(pkg,dbdir,refs,distribution,force,dereferencedfilekeys,NULL);
dsc_free(pkg);
return r;
}
......@@ -23,4 +23,11 @@
* if dereferenced_filekeys is != NULL, add there the filekeys that lost a reference*/
retvalue dsc_add(const char *dbdir,references refs,filesdb filesdb,/*@null@*/const char *forcecomponent,/*@null@*/const char *forcesection,/*@null@*/const char *forcepriority,struct distribution *distribution,const char *dscfilename,/*@null@*/const char *filekey,/*@null@*/const char *basename,/*@null@*/const char *directory,/*@null@*/const char *md5sum,/*@null@*/const struct overrideinfo *srcoverride,int force,int delete,/*@null@*/struct strlist *dereferencedfilekeys, bool_t onlysigned);
/* in two steps: */
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 *dscfilename,const char *filekey,const char *basename,const char *directory,const char *md5sum,const struct overrideinfo *srcoverride,int delete, bool_t onlysigned);
retvalue dsc_addprepared(const struct dscpackage *pkg,const char *dbdir,references refs,struct distribution *distribution,int force,struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata);
void dsc_free(/*@only@*/struct dscpackage *pkg);
#endif
......@@ -35,6 +35,7 @@
#include "names.h"
#include "release.h"
#include "copyfile.h"
#include "tracking.h"
#include "distribution.h"
retvalue distribution_free(struct distribution *distribution) {
......
......@@ -39,10 +39,12 @@ struct distribution {
/* what kind of index files to generate */
struct exportmode dsc,deb,udeb;
/* is tracking enabled for this distribution? */
enum trackingtype { dt_NONE=0, dt_KEEP, dt_NEEDED } tracking;
enum trackingtype { dt_NONE=0, dt_KEEP, dt_ALL, dt_MINIMAL } tracking;
struct { bool_t includechanges:1;
bool_t includebyhand:1;
bool_t needsources:1;
bool_t inlcudebyhand:1;} trackingoptions;
bool_t embargoalls:1;
} trackingoptions;
/* A list of all targets contained in the distribution*/
struct target *targets;
};
......
......@@ -310,7 +310,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;};
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;};
static retvalue remove_from_target(/*@temp@*/void *data, struct target *target) {
retvalue result,r;
......@@ -324,7 +324,7 @@ 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);
r = target_removepackage(target,d->refs,d->names[i],d->removedfiles,d->trackingdata);
if( RET_IS_OK(r) ) {
if( ! d->gotremoved[i] )
d->todo--;
......@@ -341,6 +341,8 @@ ACTION_D_U(remove) {
retvalue result,r;
struct distribution *distribution;