Commit c40c5d11 authored by Bernhard Link's avatar Bernhard Link

move bookeeping of unreferenced files to new code

parent 4f88b699
2008-10-12
* some rework on unreferenced files bookkeeping. Should make no
difference yet but only make the "Deleting files not longer
referenced" only show up if something is deleted...
2008-10-05
* Internaly atomize components architectures and packagetypes.
Causes multiple checks for unknown identifiers to be earlier or
......
......@@ -18,12 +18,12 @@ AM_CPPFLAGS = -std=gnu99 -Wall $(ARCHIVECPP) $(DBCPPFLAGS)
reprepro_LDADD = $(ARCHIVELIBS) $(DBLIBS)
changestool_LDADD = $(ARCHIVELIBS)
reprepro_SOURCES = atoms.c uncompression.c remoterepository.c indexfile.c copypackages.c sourceextraction.c checksums.c readtextfile.c filecntl.c sha1.c sha256.c configparser.c database.c freespace.c log.c changes.c incoming.c uploaderslist.c guesscomponent.c files.c md5.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 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) $(ARCHIVE_CONTENTS)
reprepro_SOURCES = pool.c atoms.c uncompression.c remoterepository.c indexfile.c copypackages.c sourceextraction.c checksums.c readtextfile.c filecntl.c sha1.c sha256.c configparser.c database.c freespace.c log.c changes.c incoming.c uploaderslist.c guesscomponent.c files.c md5.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 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) $(ARCHIVE_CONTENTS)
EXTRA_reprepro_SOURCE = $(ARCHIVE_UNUSED)
changestool_SOURCES = uncompression.c sourceextraction.c readtextfile.c filecntl.c tool.c chunkedit.c strlist.c checksums.c sha1.c sha256.c md5.c mprintf.c chunks.c signature.c dirs.c names.c $(ARCHIVE_USED)
noinst_HEADERS = atoms.h uncompression.h remoterepository.h copypackages.h sourceextraction.h checksums.h readtextfile.h filecntl.h sha1.h sha256.h configparser.h database_p.h database.h freespace.h log.h changes.h incoming.h guesscomponent.h md5.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 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 indexfile.h
noinst_HEADERS = pool.h atoms.h uncompression.h remoterepository.h copypackages.h sourceextraction.h checksums.h readtextfile.h filecntl.h sha1.h sha256.h configparser.h database_p.h database.h freespace.h log.h changes.h incoming.h guesscomponent.h md5.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 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 indexfile.h
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in $(srcdir)/configure $(srcdir)/stamp-h.in $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
......
......@@ -583,7 +583,7 @@ retvalue binaries_complete(const struct deb_headers *pkg, const char *filekey, c
return RET_OK;
}
retvalue binaries_adddeb(const struct deb_headers *deb, struct database *database, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata, component_t component, const struct strlist *filekeys, bool *usedmarker, const char *control) {
retvalue binaries_adddeb(const struct deb_headers *deb, struct database *database, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct trackingdata *trackingdata, component_t component, const struct strlist *filekeys, bool *usedmarker, const char *control) {
retvalue r,result;
int i;
......@@ -609,7 +609,6 @@ retvalue binaries_adddeb(const struct deb_headers *deb, struct database *databas
control,
filekeys, usedmarker,
false,
dereferencedfilekeys,
trackingdata,
deb->architecture_atom);
r2 = target_closepackagesdb(t);
......@@ -632,7 +631,6 @@ retvalue binaries_adddeb(const struct deb_headers *deb, struct database *databas
control,
filekeys, usedmarker,
false,
dereferencedfilekeys,
trackingdata,
deb->architecture_atom);
r2 = target_closepackagesdb(t);
......@@ -659,7 +657,6 @@ retvalue binaries_adddeb(const struct deb_headers *deb, struct database *databas
control,
filekeys, usedmarker,
false,
dereferencedfilekeys,
trackingdata,
deb->architecture_atom);
r2 = target_closepackagesdb(t);
......
......@@ -51,6 +51,6 @@ retvalue binaries_calcfilekeys(component_t, const struct deb_headers *, packaget
struct overrideinfo;
retvalue binaries_complete(const struct deb_headers *, const char *filekey, const struct checksums *, const struct overrideinfo *, const char *section, const char *priority, char **newcontrol);
retvalue binaries_adddeb(const struct deb_headers *, struct database *, architecture_t forcedarchitecture, packagetype_t, struct distribution *, /*@null@*/struct strlist *dereferencedfilekeys, /*@null@*/struct trackingdata *, component_t, const struct strlist *filekeys, bool *usedmarker, const char *control);
retvalue binaries_adddeb(const struct deb_headers *, struct database *, architecture_t forcedarchitecture, packagetype_t, struct distribution *, /*@null@*/struct trackingdata *, component_t, const struct strlist *filekeys, bool *usedmarker, const char *control);
retvalue binaries_checkadddeb(const struct deb_headers *, struct database *, architecture_t forcearchitecture, packagetype_t, struct distribution *, bool tracking, component_t, bool permitnewerold);
#endif
......@@ -1090,7 +1090,7 @@ static retvalue changes_checkpkgs(struct database *database, struct distribution
return r;
}
static retvalue changes_includepkgs(struct database *database, struct distribution *distribution, struct changes *changes, /*@null@*/struct strlist *dereferencedfilekeys, /*@null@*/struct trackingdata *trackingdata, bool *missed_p) {
static retvalue changes_includepkgs(struct database *database, struct distribution *distribution, struct changes *changes, /*@null@*/struct trackingdata *trackingdata, bool *missed_p) {
struct fileentry *e;
retvalue result,r;
bool markedasused;
......@@ -1114,8 +1114,7 @@ static retvalue changes_includepkgs(struct database *database, struct distributi
if( e->type == fe_DEB ) {
r = deb_addprepared(e->pkg.deb, database,
e->architecture_into, pt_deb,
distribution, dereferencedfilekeys,
trackingdata, &markedasused);
distribution, trackingdata, &markedasused);
if( r == RET_NOTHING )
*missed_p = true;
if( markedasused )
......@@ -1123,8 +1122,7 @@ static retvalue changes_includepkgs(struct database *database, struct distributi
} else if( e->type == fe_UDEB ) {
r = deb_addprepared(e->pkg.deb, database,
e->architecture_into, pt_udeb,
distribution, dereferencedfilekeys,
trackingdata, &markedasused);
distribution, trackingdata, &markedasused);
if( r == RET_NOTHING )
*missed_p = true;
if( markedasused )
......@@ -1133,8 +1131,7 @@ static retvalue changes_includepkgs(struct database *database, struct distributi
r = dsc_addprepared(database, &e->pkg.dsc,
changes->srccomponent,
&e->needed_filekeys, &markedasused,
distribution, dereferencedfilekeys,
trackingdata);
distribution, trackingdata);
if( r == RET_NOTHING )
*missed_p = true;
if( markedasused ) {
......@@ -1171,7 +1168,7 @@ static bool permissionssuffice(UNUSED(struct changes *changes),
/* insert the given .changes into the mirror in the <distribution>
* if forcecomponent, forcesection or forcepriority is NULL
* get it from the files or try to guess it. */
retvalue changes_add(struct database *database, trackingdb const tracks, packagetype_t packagetypeonly, component_t forcecomponent, architecture_t forcearchitecture, const char *forcesection, const char *forcepriority, struct distribution *distribution, const char *changesfilename, int delete, struct strlist *dereferencedfilekeys) {
retvalue changes_add(struct database *database, trackingdb const tracks, packagetype_t packagetypeonly, component_t forcecomponent, architecture_t forcearchitecture, const char *forcesection, const char *forcepriority, struct distribution *distribution, const char *changesfilename, int delete) {
retvalue result,r;
struct changes *changes;
struct trackingdata trackingdata;
......@@ -1310,8 +1307,7 @@ retvalue changes_add(struct database *database, trackingdb const tracks, package
}
/* add the source and binary packages in the given distribution */
result = changes_includepkgs(database,
distribution,changes,dereferencedfilekeys,
result = changes_includepkgs(database, distribution, changes,
(tracks!=NULL)?&trackingdata:NULL, &somethingwasmissed);
if( RET_WAS_ERROR(result) ) {
......@@ -1342,7 +1338,7 @@ retvalue changes_add(struct database *database, trackingdb const tracks, package
/* no longer delete when done */
changes->includedchangesfile = false;
}
r = trackingdata_finish(tracks, &trackingdata, database, dereferencedfilekeys);
r = trackingdata_finish(tracks, &trackingdata, database);
RET_ENDUPDATE(result,r);
if( RET_WAS_ERROR(result) ) {
changes_free(changes);
......
......@@ -20,7 +20,7 @@
* get it from the files or try to guess it.
* if dereferencedfilekeys is != NULL, add filekeys that lost reference,
* if tracks != NULL, update/add tracking information there... */
retvalue changes_add(struct database *, /*@null@*/trackingdb tracks, packagetype_t packagetypeonly, component_t, architecture_t forcearchitecture, /*@null@*/const char *forcesection, /*@null@*/const char *forcepriority, struct distribution *, const char *changesfilename, int delete, /*@null@*/struct strlist *dereferencedfilekeys);
retvalue changes_add(struct database *, /*@null@*/trackingdb tracks, packagetype_t packagetypeonly, component_t, architecture_t forcearchitecture, /*@null@*/const char *forcesection, /*@null@*/const char *forcepriority, struct distribution *, const char *changesfilename, int delete);
#endif
......@@ -269,10 +269,9 @@ retvalue deb_prepare(/*@out@*/struct debpackage **deb, component_t forcecomponen
return RET_OK;
}
retvalue deb_addprepared(const struct debpackage *pkg, struct database *database, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata, bool *usedmarker) {
retvalue deb_addprepared(const struct debpackage *pkg, struct database *database, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct trackingdata *trackingdata, bool *usedmarker) {
return binaries_adddeb(&pkg->deb, database, forcearchitecture,
packagetype, distribution, dereferencedfilekeys,
trackingdata,
packagetype, distribution, trackingdata,
pkg->component_atom, &pkg->filekeys, usedmarker,
pkg->deb.control);
}
......@@ -281,7 +280,7 @@ retvalue deb_addprepared(const struct debpackage *pkg, struct database *database
* 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(struct database *database, component_t forcecomponent, architecture_t forcearchitecture, const char *forcesection, const char *forcepriority, packagetype_t packagetype, struct distribution *distribution, const char *debfilename, int delete, struct strlist *dereferencedfilekeys, /*@null@*/trackingdb tracks){
retvalue deb_add(struct database *database, component_t forcecomponent, architecture_t forcearchitecture, const char *forcesection, const char *forcepriority, packagetype_t packagetype, struct distribution *distribution, const char *debfilename, int delete, /*@null@*/trackingdb tracks) {
struct debpackage *pkg;
retvalue r;
struct trackingdata trackingdata;
......@@ -335,7 +334,7 @@ retvalue deb_add(struct database *database, component_t forcecomponent, architec
}
r = binaries_adddeb(&pkg->deb, database, forcearchitecture,
packagetype, distribution, dereferencedfilekeys,
packagetype, distribution,
(tracks!=NULL)?&trackingdata:NULL,
pkg->component_atom, &pkg->filekeys, &fileused,
pkg->deb.control);
......@@ -347,7 +346,7 @@ retvalue deb_add(struct database *database, component_t forcecomponent, architec
if( tracks != NULL ) {
retvalue r2;
r2 = trackingdata_finish(tracks, &trackingdata, database, dereferencedfilekeys);
r2 = trackingdata_finish(tracks, &trackingdata, database);
RET_ENDUPDATE(r,r2);
}
......
......@@ -17,13 +17,12 @@
* causing error, if it is not one of them otherwise)
* if overwrite is not NULL, it will be search for fields to reset for this
* package. (forcesection and forcepriority have higher priority than the
* information there),
* if dereferencedfilekeys is != NULL, add there filekeys that lost a reference */
retvalue deb_add(struct database *, component_t forcecomponent, architecture_t forcearchitecture, /*@null@*/const char *forcesection, /*@null@*/const char *forcepriority, packagetype_t, struct distribution *, const char *debfilename, int delete, /*@null@*/struct strlist *dereferencedfilekeys, /*@null@*/trackingdb);
* information there), */
retvalue deb_add(struct database *, component_t forcecomponent, architecture_t forcearchitecture, /*@null@*/const char *forcesection, /*@null@*/const char *forcepriority, packagetype_t, struct distribution *, const char *debfilename, int delete, /*@null@*/trackingdb);
/* in two steps */
struct debpackage;
retvalue deb_addprepared(const struct debpackage *pkg, struct database *, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata, bool *usedmarker);
retvalue deb_addprepared(const struct debpackage *pkg, struct database *, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct trackingdata *trackingdata, bool *usedmarker);
retvalue deb_prepare(/*@out@*/struct debpackage **deb, component_t forcecomponent, architecture_t forcearchitecture, const char *forcesection, const char *forcepriority, packagetype_t, struct distribution *distribution, const char *debfilename, const char * const filekey, const struct checksums *checksums, const struct strlist *allowed_binaries, const char *expectedsourcename, const char *expectedsourceversion);
void deb_free(/*@only@*/struct debpackage *pkg);
#endif
......@@ -141,7 +141,7 @@ static retvalue dsc_read(/*@out@*/struct dscpackage **pkg, const char *filename)
return RET_OK;
}
retvalue dsc_addprepared(struct database *database, const struct dsc_headers *dsc, component_t component, const struct strlist *filekeys, bool *usedmarker, struct distribution *distribution, struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata){
retvalue dsc_addprepared(struct database *database, const struct dsc_headers *dsc, component_t component, const struct strlist *filekeys, bool *usedmarker, struct distribution *distribution, struct trackingdata *trackingdata){
retvalue r;
struct target *t = distribution_getpart(distribution,
component, architecture_source, pt_dsc);
......@@ -158,9 +158,7 @@ retvalue dsc_addprepared(struct database *database, const struct dsc_headers *ds
r = target_addpackage(t, distribution->logger, database,
dsc->name, dsc->version,
dsc->control, filekeys,
usedmarker,
false, dereferencedfilekeys,
trackingdata,
usedmarker, false, trackingdata,
architecture_source);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
......@@ -174,7 +172,7 @@ retvalue dsc_addprepared(struct database *database, const struct dsc_headers *ds
* 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(struct database *database, component_t 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, component_t forcecomponent, const char *forcesection, const char *forcepriority, struct distribution *distribution, const char *dscfilename, int delete, trackingdb tracks){
retvalue r;
struct dscpackage *pkg;
struct trackingdata trackingdata;
......@@ -404,7 +402,7 @@ retvalue dsc_add(struct database *database, component_t forcecomponent, const ch
r = dsc_addprepared(database, &pkg->dsc, pkg->component_atom,
&pkg->filekeys, &usedmarker,
distribution, dereferencedfilekeys,
distribution,
(tracks!=NULL)?&trackingdata:NULL);
if( usedmarker ) {
for( i = 0 ; i < pkg->dsc.files.names.count ; i++ )
......@@ -433,8 +431,7 @@ retvalue dsc_add(struct database *database, component_t forcecomponent, const ch
if( tracks != NULL ) {
retvalue r2;
r2 = trackingdata_finish(tracks, &trackingdata, database,
dereferencedfilekeys);
r2 = trackingdata_finish(tracks, &trackingdata, database);
RET_ENDUPDATE(r,r2);
}
return r;
......
......@@ -16,9 +16,8 @@
#endif
/* insert the given .dsc into the mirror in <component> in the <distribution>
* if component is NULL, guess it from the section.
* if dereferenced_filekeys is != NULL, add there the filekeys that lost a reference*/
retvalue dsc_add(struct database *, component_t forcecomponent, /*@null@*/const char *forcesection, /*@null@*/const char *forcepriority, struct distribution *, const char *dscfilename, int delete, /*@null@*/struct strlist *dereferencedfilekeys, /*@null@*/trackingdb tracks);
* if component is NULL, guess it from the section. */
retvalue dsc_add(struct database *, component_t, /*@null@*/const char *forcesection, /*@null@*/const char *forcepriority, struct distribution *, const char *dscfilename, int delete, /*@null@*/trackingdb tracks);
/* in two steps:
* If basename, filekey and directory are != NULL, then they are used instead
......@@ -27,6 +26,6 @@ retvalue dsc_add(struct database *, component_t forcecomponent, /*@null@*/const
* delete should be D_INPLACE then
*/
retvalue dsc_addprepared(struct database *, const struct dsc_headers *, component_t , const struct strlist *filekeys, bool *usedmarker, struct distribution *distribution, /*@null@*/struct strlist *dereferencedfilekeys, /*@null@*/struct trackingdata *trackingdata);
retvalue dsc_addprepared(struct database *, const struct dsc_headers *, component_t , const struct strlist *filekeys, bool *usedmarker, struct distribution *distribution, /*@null@*/struct trackingdata *trackingdata);
#endif
......@@ -245,7 +245,7 @@ static retvalue list_prepareadd(struct database *database, struct package_list *
return RET_OK;
}
static retvalue package_add(struct database *database, struct distribution *into, /*@null@*/trackingdb tracks, struct target *target, const struct package *package, struct strlist *dereferencedfilekeys) {
static retvalue package_add(struct database *database, struct distribution *into, /*@null@*/trackingdb tracks, struct target *target, const struct package *package) {
struct trackingdata trackingdata;
retvalue r;
......@@ -273,7 +273,6 @@ static retvalue package_add(struct database *database, struct distribution *into
package->name, package->version,
package->control,
&package->filekeys, NULL, true,
dereferencedfilekeys,
(tracks != NULL)?
&trackingdata:NULL,
package->architecture);
......@@ -282,13 +281,13 @@ static retvalue package_add(struct database *database, struct distribution *into
retvalue r2;
r2 = trackingdata_finish(tracks, &trackingdata,
database, dereferencedfilekeys);
database);
RET_ENDUPDATE(r, r2);
}
return r;
}
static retvalue packagelist_add(struct database *database, struct distribution *into, const struct package_list *list, struct strlist *dereferencedfilekeys) {
static retvalue packagelist_add(struct database *database, struct distribution *into, const struct package_list *list) {
retvalue result, r;
struct target_package_list *tpl;
struct package *package;
......@@ -315,7 +314,7 @@ static retvalue packagelist_add(struct database *database, struct distribution *
break;
for( package = tpl->packages; package != NULL ; package = package->next ) {
r = package_add(database, into, tracks, target,
package, dereferencedfilekeys);
package);
RET_UPDATE(result, r);
}
r = target_closepackagesdb(target);
......@@ -425,7 +424,7 @@ static void packagelist_done(struct package_list *list) {
}
}
retvalue copy_by_name(struct database *database, struct distribution *into, struct distribution *from, int argc, const char **argv, component_t component, architecture_t architecture, packagetype_t packagetype, struct strlist *dereferenced) {
retvalue copy_by_name(struct database *database, struct distribution *into, struct distribution *from, int argc, const char **argv, component_t component, architecture_t architecture, packagetype_t packagetype) {
struct package_list list;
struct namelist names = { argc, argv, calloc(argc, sizeof(bool)) };
retvalue r;
......@@ -438,7 +437,7 @@ retvalue copy_by_name(struct database *database, struct distribution *into, stru
free(names.warnedabout);
if( !RET_IS_OK(r) )
return r;
r = packagelist_add(database, into, &list, dereferenced);
r = packagelist_add(database, into, &list);
packagelist_done(&list);
return r;
}
......@@ -513,7 +512,7 @@ static retvalue by_source(struct package_list *list, struct database *database,
return result;
}
retvalue copy_by_source(struct database *database, struct distribution *into, struct distribution *from, int argc, const char **argv, component_t component, architecture_t architecture, packagetype_t packagetype, struct strlist *dereferenced) {
retvalue copy_by_source(struct database *database, struct distribution *into, struct distribution *from, int argc, const char **argv, component_t component, architecture_t architecture, packagetype_t packagetype) {
struct package_list list;
struct namelist names = { argc, argv, NULL };
retvalue r;
......@@ -524,7 +523,7 @@ retvalue copy_by_source(struct database *database, struct distribution *into, st
r = copy_by_func(&list, database, into, from, component, architecture, packagetype, by_source, &names);
if( !RET_IS_OK(r) )
return r;
r = packagelist_add(database, into, &list, dereferenced);
r = packagelist_add(database, into, &list);
packagelist_done(&list);
return r;
}
......@@ -565,7 +564,7 @@ static retvalue by_formula(struct package_list *list, struct database *database,
return result;
}
retvalue copy_by_formula(struct database *database, struct distribution *into, struct distribution *from, const char *filter, component_t component, architecture_t architecture, packagetype_t packagetype, struct strlist *dereferenced) {
retvalue copy_by_formula(struct database *database, struct distribution *into, struct distribution *from, const char *filter, component_t component, architecture_t architecture, packagetype_t packagetype) {
struct package_list list;
term *condition;
retvalue r;
......@@ -581,7 +580,7 @@ retvalue copy_by_formula(struct database *database, struct distribution *into, s
term_free(condition);
if( !RET_IS_OK(r) )
return r;
r = packagelist_add(database, into, &list, dereferenced);
r = packagelist_add(database, into, &list);
packagelist_done(&list);
return r;
}
......@@ -648,7 +647,7 @@ static retvalue choose_by_condition(UNUSED(struct target *target), UNUSED(const
return term_decidechunk(condition, chunk);
}
retvalue copy_from_file(struct database *database, struct distribution *into, component_t component_atom, architecture_t architecture_atom, packagetype_t packagetype_atom, const char *filename, int argc, const char **argv, struct strlist *dereferenced) {
retvalue copy_from_file(struct database *database, struct distribution *into, component_t component_atom, architecture_t architecture_atom, packagetype_t packagetype_atom, const char *filename, int argc, const char **argv) {
struct indexfile *i;
retvalue result, r;
struct target *target;
......@@ -710,14 +709,14 @@ retvalue copy_from_file(struct database *database, struct distribution *into, co
r = indexfile_close(i);
RET_ENDUPDATE(result, r);
if( RET_IS_OK(result) )
result = packagelist_add(database, into, &list, dereferenced);
result = packagelist_add(database, into, &list);
packagelist_done(&list);
return result;
}
typedef retvalue chooseaction(struct target *, const char *, const char *, const char *, void *);
static retvalue restore_from_snapshot(struct database *database, struct distribution *into, component_t component_atom, architecture_t architecture_atom, packagetype_t packagetype_atom, const char *snapshotname, chooseaction action, void *d, struct strlist *dereferenced) {
static retvalue restore_from_snapshot(struct database *database, struct distribution *into, component_t component_atom, architecture_t architecture_atom, packagetype_t packagetype_atom, const char *snapshotname, chooseaction action, void *d) {
retvalue result, r;
struct package_list list;
struct target *target;
......@@ -809,26 +808,26 @@ static retvalue restore_from_snapshot(struct database *database, struct distribu
free(basedir);
if( !RET_IS_OK(result) )
return result;
r = packagelist_add(database, into, &list, dereferenced);
r = packagelist_add(database, into, &list);
packagelist_done(&list);
return r;
}
retvalue restore_by_name(struct database *database, struct distribution *into, component_t component, architecture_t architecture, packagetype_t packagetype, const char *snapshotname, int argc, const char **argv, struct strlist *dereferenced) {
retvalue restore_by_name(struct database *database, struct distribution *into, component_t component, architecture_t architecture, packagetype_t packagetype, const char *snapshotname, int argc, const char **argv) {
struct namelist d = {argc, argv, NULL};
return restore_from_snapshot(database, into,
component, architecture, packagetype,
snapshotname, choose_by_name, &d, dereferenced);
snapshotname, choose_by_name, &d);
}
retvalue restore_by_source(struct database *database, struct distribution *into, component_t component, architecture_t architecture, packagetype_t packagetype, const char *snapshotname, int argc, const char **argv, struct strlist *dereferenced) {
retvalue restore_by_source(struct database *database, struct distribution *into, component_t component, architecture_t architecture, packagetype_t packagetype, const char *snapshotname, int argc, const char **argv) {
struct namelist d = {argc, argv, NULL};
return restore_from_snapshot(database, into,
component, architecture, packagetype,
snapshotname, choose_by_source, &d, dereferenced);
snapshotname, choose_by_source, &d);
}
retvalue restore_by_formula(struct database *database, struct distribution *into, component_t component, architecture_t architecture, packagetype_t packagetype, const char *snapshotname, const char *filter, struct strlist *dereferenced) {
retvalue restore_by_formula(struct database *database, struct distribution *into, component_t component, architecture_t architecture, packagetype_t packagetype, const char *snapshotname, const char *filter) {
term *condition;
retvalue r;
......@@ -839,8 +838,7 @@ retvalue restore_by_formula(struct database *database, struct distribution *into
}
r = restore_from_snapshot(database, into,
component, architecture, packagetype,
snapshotname, choose_by_condition, condition,
dereferenced);
snapshotname, choose_by_condition, condition);
term_free(condition);
return r;
}
......@@ -5,14 +5,14 @@
#include "strlist.h"
#endif
retvalue copy_by_name(struct database *, struct distribution *into, struct distribution *from, int, const char **, component_t, architecture_t, packagetype_t, struct strlist *dereferenced);
retvalue copy_by_source(struct database *, struct distribution *into, struct distribution *from, int, const char **, component_t, architecture_t, packagetype_t, struct strlist *dereferenced);
retvalue copy_by_formula(struct database *, struct distribution *into, struct distribution *from, const char *formula, component_t, architecture_t, packagetype_t, struct strlist *dereferenced);
retvalue copy_by_name(struct database *, struct distribution *into, struct distribution *from, int, const char **, component_t, architecture_t, packagetype_t);
retvalue copy_by_source(struct database *, struct distribution *into, struct distribution *from, int, const char **, component_t, architecture_t, packagetype_t);
retvalue copy_by_formula(struct database *, struct distribution *into, struct distribution *from, const char *formula, component_t, architecture_t, packagetype_t);
retvalue copy_from_file(struct database *, struct distribution *into, component_t, architecture_t, packagetype_t, const char *filename, int, const char **, struct strlist *dereferenced);
retvalue copy_from_file(struct database *, struct distribution *into, component_t, architecture_t, packagetype_t, const char *filename, int, const char **);
retvalue restore_by_name(struct database *, struct distribution *, component_t, architecture_t, packagetype_t, const char *snapshotname, int, const char **, struct strlist *dereferenced);
retvalue restore_by_source(struct database *, struct distribution *, component_t, architecture_t, packagetype_t, const char *snapshotname, int, const char **, struct strlist *dereferenced);
retvalue restore_by_formula(struct database *, struct distribution *, component_t, architecture_t, packagetype_t, const char *snapshotname, const char *filter, struct strlist *dereferenced);
retvalue restore_by_name(struct database *, struct distribution *, component_t, architecture_t, packagetype_t, const char *snapshotname, int, const char **);
retvalue restore_by_source(struct database *, struct distribution *, component_t, architecture_t, packagetype_t, const char *snapshotname, int, const char **);
retvalue restore_by_formula(struct database *, struct distribution *, component_t, architecture_t, packagetype_t, const char *snapshotname, const char *filter);
#endif
......@@ -983,7 +983,7 @@ retvalue distribution_prepareforwriting(struct distribution *distribution) {
}
/* delete every package decider returns RET_OK for */
retvalue distribution_remove_packages(struct distribution *distribution, struct database *database, component_t component, architecture_t architecture, packagetype_t packagetype, each_package_action decider, struct strlist *dereferenced, struct trackingdata *trackingdata, void *data) {
retvalue distribution_remove_packages(struct distribution *distribution, struct database *database, component_t component, architecture_t architecture, packagetype_t packagetype, each_package_action decider, struct trackingdata *trackingdata, void *data) {
retvalue result,r;
struct target *t;
struct target_cursor iterator;
......@@ -1006,7 +1006,7 @@ retvalue distribution_remove_packages(struct distribution *distribution, struct
if( RET_IS_OK(r) ) {
r = target_removepackage_by_cursor(&iterator,
distribution->logger, database,
dereferenced, trackingdata);
trackingdata);
RET_UPDATE(result, r);
RET_UPDATE(distribution->status, r);
}
......
......@@ -111,7 +111,7 @@ retvalue distribution_foreach_package(struct distribution *, struct database *,
retvalue distribution_foreach_package_c(struct distribution *, struct database *, const struct atomlist *components, architecture_t, packagetype_t, each_package_action, void *);
/* delete every package decider returns RET_OK for */
retvalue distribution_remove_packages(struct distribution *, struct database *, component_t, architecture_t, packagetype_t, each_package_action decider, struct strlist *dereferenced, struct trackingdata *, void *);
retvalue distribution_remove_packages(struct distribution *, struct database *, component_t, architecture_t, packagetype_t, each_package_action decider, struct trackingdata *, void *);
/*@dependent@*/struct target *distribution_getpart(const struct distribution *distribution, component_t, architecture_t, packagetype_t);
......
......@@ -1351,9 +1351,7 @@ static retvalue candidate_addfiles(struct database *database,struct candidate *c
return RET_OK;
}
static retvalue add_dsc(struct database *database,
struct distribution *into, struct strlist *dereferenced,
struct trackingdata *trackingdata, struct candidate_package *p) {
static retvalue add_dsc(struct database *database, struct distribution *into, struct trackingdata *trackingdata, struct candidate_package *p) {
retvalue r;
struct target *t = distribution_getpart(into,
p->component_atom, architecture_source, pt_dsc);
......@@ -1374,8 +1372,7 @@ static retvalue add_dsc(struct database *database,
p->master->dsc.version,
p->control,
&p->filekeys, &usedmarker,
false, dereferenced,
trackingdata,
false, trackingdata,
architecture_source);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
......@@ -1409,7 +1406,7 @@ static retvalue checkadd_dsc(struct database *database,
return r;
}
static retvalue candidate_add_into(struct database *database,struct strlist *dereferenced,const struct incoming *i,const struct candidate *c,const struct candidate_perdistribution *d) {
static retvalue candidate_add_into(struct database *database, const struct incoming *i, const struct candidate *c, const struct candidate_perdistribution *d) {
retvalue r;
struct candidate_package *p;
struct trackingdata trackingdata;
......@@ -1461,7 +1458,7 @@ static retvalue candidate_add_into(struct database *database,struct strlist *der
continue;
}
if( p->master->type == fe_DSC ) {
r = add_dsc(database, into, dereferenced,
r = add_dsc(database, into,
(tracks==NULL)?NULL:&trackingdata,
p);
} else if( FE_BINARY(p->master->type) ) {
......@@ -1469,8 +1466,7 @@ static retvalue candidate_add_into(struct database *database,struct strlist *der
bool usedmarker = false;
r = binaries_adddeb(&p->master->deb, database,
p->master->architecture_atom,
p->packagetype,
into, dereferenced,
p->packagetype, into,
(tracks==NULL)?NULL:&trackingdata,
p->component_atom, &p->filekeys,
&usedmarker, p->control);
......@@ -1495,8 +1491,7 @@ static retvalue candidate_add_into(struct database *database,struct strlist *der
if( tracks != NULL ) {
retvalue r2;
r2 = trackingdata_finish(tracks, &trackingdata,
database, dereferenced);
r2 = trackingdata_finish(tracks, &trackingdata, database);
RET_UPDATE(r,r2);
r2 = tracking_done(tracks);
RET_ENDUPDATE(r,r2);
......@@ -1528,8 +1523,7 @@ static inline retvalue candidate_checkadd_into(struct database *database,const s
r = binaries_checkadddeb(&p->master->deb, database,
p->master->architecture_atom,
p->packagetype,
into,
into->tracking != dt_NONE,
into, into->tracking != dt_NONE,
p->component_atom,
i->permit[pmf_oldpackagenewer]);
} else if( p->master->type == fe_UNKNOWN ) {
......@@ -1659,7 +1653,7 @@ static retvalue check_architecture_availability(const struct incoming *i, const
return RET_OK;
}
static retvalue candidate_add(struct database *database, struct strlist *dereferenced, struct incoming *i, struct candidate *c) {
static retvalue candidate_add(struct database *database, struct incoming *i, struct candidate *c) {
struct candidate_perdistribution *d;
struct candidate_file *file;
retvalue r;
......@@ -1751,8 +1745,7 @@ static retvalue candidate_add(struct database *database, struct strlist *derefer
for( d = c->perdistribution ; d != NULL ; d = d->next ) {
if( d->skip )
continue;
r = candidate_add_into(database,
dereferenced, i, c, d);
r = candidate_add_into(database, i, c, d);
if( RET_WAS_ERROR(r) )
return r;
}
......@@ -1766,7 +1759,7 @@ static retvalue candidate_add(struct database *database, struct strlist *derefer
return RET_OK;
}
static retvalue process_changes(struct database *database, struct strlist *dereferenced, struct incoming *i, int ofs) {
static retvalue process_changes(struct database *database, struct incoming *i, int ofs) {
struct candidate *c IFSTUPIDCC(=NULL);
retvalue r;
int j,k;
......@@ -1846,9 +1839,7 @@ static retvalue process_changes(struct database *database, struct strlist *deref
i->files.values[ofs]);
r = RET_ERROR;
} else
r = candidate_add(database,
dereferenced,
i, c);
r = candidate_add(database, i, c);
if( RET_WAS_ERROR(r) && i->cleanup[cuf_on_error] ) {
struct candidate_file *file;
......@@ -1864,7 +1855,7 @@ static retvalue process_changes(struct database *database, struct strlist *deref
}
/* tempdir should ideally be on the same partition like the pooldir */
retvalue process_incoming(struct database *database, struct strlist *dereferenced, struct distribution *distributions, const char *name, const char *changesfilename) {
retvalue process_incoming(struct database *database, struct distribution *distributions, const char *name, const char *changesfilename) {
struct incoming *i;
retvalue result,r;
int j;
......@@ -1886,7 +1877,7 @@ retvalue process_incoming(struct database *database, struct strlist *dereference
if( changesfilename != NULL && strcmp(basefilename, changesfilename) != 0 )
continue;
/* a .changes file, check it */
r = process_changes(database, dereferenced, i, j);
r = process_changes(database, i, j);
RET_UPDATE(result, r);
}
......
......@@ -6,5 +6,5 @@
#warning "What's hapening here?"
#endif
retvalue process_incoming(struct database *,struct strlist *dereferenced,struct distribution *distributions,const char *name,/*@null@*/const char *onlychangesfilename);
retvalue process_incoming(struct database *, struct distribution *distributions, const char *name, /*@null@*/const char *onlychangesfilename);
#endif
This diff is collapsed.
/* This file is part of "reprepro"
* Copyright (C) 2008 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 <assert.h>
#include <limits.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <search.h>
#include "error.h"
#include "ignore.h"
#include "mprintf.h"
#include "atoms.h"
#include "pool.h"
#include "reference.h"
#include "files.h"
/* for now save them only in memory. In later times some way to store
* them on disk would be nice */
static void **file_changes_per_component = NULL;
static void *legacy_file_changes = NULL;
bool pool_havedereferenced = false;
#define pl_ADDED 1
#define pl_UNREFERENCED 2
static int legacy_compare(const void *a, const void *b) {
const char *v1 = a, *v2 = b;
v1++;
v2++;
return strcmp(v1,v2);
}
static retvalue pool_addfile(const char *filename) {
char **p; size_t l;
p = tsearch(filename - 1, &legacy_file_changes, legacy_compare);
if( p == NULL )
return RET_ERROR_OOM;
if( *p == filename - 1 ) {
l = strlen(filename);
*p = malloc(l + 2);
if (*p == NULL)
return RET_ERROR_OOM;
**p = pl_ADDED;
memcpy((*p) + 1, filename, l + 1);
} else {
**p |= pl_ADDED;
}
return RET_OK;
};
retvalue pool_dereferenced(const char *filename) {
char **p; size_t l;
p = tsearch(filename - 1, &legacy_file_changes, legacy_compare);
if( p == NULL )
return RET_ERROR_OOM;
if( *p == filename - 1 ) {
l = strlen(filename);
*p = malloc(l + 2);
if (*p == NULL)
return RET_ERROR_OOM;
**p = pl_UNREFERENCED;
memcpy((*p) + 1, filename, l + 1);
pool_havedereferenced = true;
} else {
**p |= pl_UNREFERENCED;
}
return RET_OK;
};