Commit efb0c330 authored by Bernhard Link's avatar Bernhard Link

move storing of the aptmethod to get things from from upgradelist.c to update.c

parent c6d60afa
......@@ -67,6 +67,7 @@
#include "names.h"
#include "signature.h"
#include "aptmethod.h"
#include "downloadcache.h"
#include "updates.h"
#include "upgradelist.h"
#include "distribution.h"
......@@ -1399,8 +1400,7 @@ static inline retvalue searchformissing(FILE *out,struct database *database,stru
if( verbose > 4 )
fprintf(out," reading '%s'\n", filename);
r = upgradelist_update(u->upgradelist,
remote_aptmethod(uindex->origin->from),
r = upgradelist_update(u->upgradelist, uindex,
filename,
ud_decide_by_pattern,
(void*)uindex->origin->pattern,
......@@ -1437,6 +1437,18 @@ static retvalue updates_readindices(FILE *out,struct database *database,struct u
* Step 10: enqueue downloading of missing packages *
****************************************************************************/
static retvalue enqueue_upgrade_package(void *calldata, struct database *database, const struct checksumsarray *origfiles, const struct strlist *filekeys, void *privdata) {
struct update_index_connector *uindex = privdata;
struct aptmethod *aptmethod;
struct downloadcache *cache = calldata;
assert(privdata != NULL);
aptmethod = remote_aptmethod(uindex->origin->from);
assert(aptmethod != NULL);
return downloadcache_addfiles(cache, database, aptmethod,
origfiles, filekeys);
}
static retvalue updates_enqueue(struct downloadcache *cache,struct database *database,struct update_distribution *distribution) {
retvalue result,r;
struct update_target *u;
......@@ -1445,7 +1457,7 @@ static retvalue updates_enqueue(struct downloadcache *cache,struct database *dat
for( u=distribution->targets ; u != NULL ; u=u->next ) {
if( u->nothingnew )
continue;
r = upgradelist_enqueue(u->upgradelist, cache, database);
r = upgradelist_enqueue(u->upgradelist, enqueue_upgrade_package, cache, database);
if( RET_WAS_ERROR(r) )
u->incomplete = true;
RET_UPDATE(result,r);
......
......@@ -27,7 +27,6 @@
#include "indexfile.h"
#include "dpkgversions.h"
#include "target.h"
#include "downloadcache.h"
#include "files.h"
#include "upgradelist.h"
......@@ -51,7 +50,7 @@ struct package_data {
* NULL means nothing found. */
char *new_version;
/* where the recent version comes from: */
/*@dependent@*/struct aptmethod *aptmethod;
/*@dependent@*/void *privdata;
/* the new control-chunk for the package to go in
* non-NULL if new_version && newversion == version_in_use */
......@@ -104,7 +103,7 @@ static retvalue save_package_version(struct upgradelist *upgrade, const char *pa
return RET_ERROR_OOM;
}
package->aptmethod = NULL;
package->privdata = NULL;
package->name = strdup(packagename);
if( package->name == NULL ) {
free(package);
......@@ -192,7 +191,7 @@ void upgradelist_free(struct upgradelist *upgrade) {
return;
}
static retvalue upgradelist_trypackage(struct upgradelist *upgrade, /*@null@*/struct aptmethod *aptmethod, upgrade_decide_function *predecide, void *predecide_data, const char *packagename_const, /*@null@*//*@only@*/char *packagename, /*@only@*/char *version, architecture_t architecture, const char *chunk){
static retvalue upgradelist_trypackage(struct upgradelist *upgrade, void *privdata, upgrade_decide_function *predecide, void *predecide_data, const char *packagename_const, /*@null@*//*@only@*/char *packagename, /*@only@*/char *version, architecture_t architecture, const char *chunk){
retvalue r;
upgrade_decision decision;
struct package_data *current,*insertafter;
......@@ -282,7 +281,7 @@ static retvalue upgradelist_trypackage(struct upgradelist *upgrade, /*@null@*/st
return RET_ERROR_OOM;
}
new->deleted = false; //to be sure...
new->aptmethod = aptmethod;
new->privdata = privdata;
if( packagename == NULL ) {
new->name = strdup(packagename_const);
if( FAILEDTOALLOC(new->name) ) {
......@@ -423,7 +422,7 @@ static retvalue upgradelist_trypackage(struct upgradelist *upgrade, /*@null@*/st
free(current->new_version);
current->new_version = version;
current->version = version;
current->aptmethod = aptmethod;
current->privdata = privdata;
strlist_move(&current->new_filekeys,&files);
checksumsarray_move(&current->new_origfiles, &origfiles);
free(current->new_control);
......@@ -432,7 +431,7 @@ static retvalue upgradelist_trypackage(struct upgradelist *upgrade, /*@null@*/st
return RET_OK;
}
retvalue upgradelist_update(struct upgradelist *upgrade, struct aptmethod *method, const char *filename, upgrade_decide_function *decide, void *decide_data, bool ignorewrongarchitecture) {
retvalue upgradelist_update(struct upgradelist *upgrade, void *privdata, const char *filename, upgrade_decide_function *decide, void *decide_data, bool ignorewrongarchitecture) {
struct indexfile *i;
char *packagename, *version;
const char *control;
......@@ -448,7 +447,7 @@ retvalue upgradelist_update(struct upgradelist *upgrade, struct aptmethod *metho
while( indexfile_getnext(i, &packagename, &version, &control,
&package_architecture,
upgrade->target, ignorewrongarchitecture) ) {
r = upgradelist_trypackage(upgrade, method, decide, decide_data,
r = upgradelist_trypackage(upgrade, privdata, decide, decide_data,
packagename, packagename, version,
package_architecture, control);
RET_UPDATE(result, r);
......@@ -539,18 +538,18 @@ retvalue upgradelist_listmissing(struct upgradelist *upgrade,struct database *da
return RET_OK;
}
/* request all wanted files in the downloadlists given before */
retvalue upgradelist_enqueue(struct upgradelist *upgrade,struct downloadcache *cache,struct database *database) {
retvalue upgradelist_enqueue(struct upgradelist *upgrade, enqueueaction *action, void *calldata, struct database *database) {
struct package_data *pkg;
retvalue result,r;
result = RET_NOTHING;
assert(upgrade != NULL);
for( pkg = upgrade->list ; pkg != NULL ; pkg = pkg->next ) {
if( pkg->version == pkg->new_version && !pkg->deleted) {
assert(pkg->aptmethod != NULL);
r = downloadcache_addfiles(cache, database,
pkg->aptmethod,
&pkg->new_origfiles, &pkg->new_filekeys);
r = action(calldata, database,
&pkg->new_origfiles,
&pkg->new_filekeys, pkg->privdata);
RET_UPDATE(result,r);
if( RET_WAS_ERROR(r) )
break;
......
#ifndef REPREPRO_UPGRADELIST_H
#define REPREPRO_UPGRADELIST_H
#ifndef REPREPRO_APTMETHOD_H
#include "aptmethod.h"
#endif
#ifndef REPREPRO_DOWNLOADCACHE_H
#include "downloadcache.h"
#endif
/* Things for making decisions what to upgrade and what not */
typedef enum { UD_ERROR, UD_NO, UD_UPGRADE, UD_HOLD } upgrade_decision;
......@@ -29,7 +22,7 @@ void upgradelist_dump(struct upgradelist *upgrade);
retvalue upgradelist_listmissing(struct upgradelist *upgrade,struct database *);
/* Take all items in 'filename' into account, and remember them coming from 'method' */
retvalue upgradelist_update(struct upgradelist *upgrade, /*@dependent@*/struct aptmethod *method, const char *filename, upgrade_decide_function *predecide, void *decide_data, bool ignorewrongarchitecture);
retvalue upgradelist_update(struct upgradelist *upgrade, /*@dependent@*/void *, const char *filename, upgrade_decide_function *predecide, void *decide_data, bool ignorewrongarchitecture);
/* Take all items in source into account */
retvalue upgradelist_pull(struct upgradelist *upgrade,struct target *source,upgrade_decide_function *predecide,void *decide_data,struct database *);
......@@ -37,12 +30,9 @@ retvalue upgradelist_pull(struct upgradelist *upgrade,struct target *source,upgr
/* mark all packages as deleted, so they will vanis unless readded or reholded */
retvalue upgradelist_deleteall(struct upgradelist *upgrade);
//TODO add a function to reduce data-load by removing anything not needed
//any longer. (perhaps with a flag to remove all packages that are no
//longer available upstream)
typedef retvalue enqueueaction(void *, struct database *, const struct checksumsarray *, const struct strlist *, void *);
/* request all wanted files refering the methods given before */
retvalue upgradelist_enqueue(struct upgradelist *upgrade,struct downloadcache *cache,struct database *);
retvalue upgradelist_enqueue(struct upgradelist *, enqueueaction *, void *, struct database *);
retvalue upgradelist_install(struct upgradelist *upgrade, /*@null@*/struct logger *, struct database *, bool ignoredelete);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment