reverted back to trans->packages instead of install and remove queues

This commit is contained in:
Aurelien Foret 2005-04-06 21:00:57 +00:00
parent 48f8f521b1
commit e59e963f1f
6 changed files with 30 additions and 40 deletions

View file

@ -93,7 +93,7 @@ int add_loadtarget(pmdb_t *db, pmtrans_t *trans, char *name)
* if so, replace it in the list */ * if so, replace it in the list */
/* ORE /* ORE
we'd better do it before load_pkg. */ we'd better do it before load_pkg. */
for(j = trans->install_q; j; j = j->next) { for(j = trans->packages; j; j = j->next) {
pmpkg_t *pkg = j->data; pmpkg_t *pkg = j->data;
if(strcmp(pkg->name, info->name) == 0) { if(strcmp(pkg->name, info->name) == 0) {
@ -107,7 +107,7 @@ int add_loadtarget(pmdb_t *db, pmtrans_t *trans, char *name)
} }
/* add the package to the transaction */ /* add the package to the transaction */
trans->install_q = pm_list_add(trans->install_q, info); trans->packages = pm_list_add(trans->packages, info);
return(0); return(0);
@ -138,7 +138,7 @@ int add_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL); TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, "looking for conflicts or unsatisfied dependencies"); _alpm_log(PM_LOG_FLOW1, "looking for conflicts or unsatisfied dependencies");
lp = checkdeps(db, trans->type, trans->install_q); lp = checkdeps(db, trans->type, trans->packages);
if(lp != NULL) { if(lp != NULL) {
int errorout = 0; int errorout = 0;
@ -187,10 +187,10 @@ int add_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
/* re-order w.r.t. dependencies */ /* re-order w.r.t. dependencies */
_alpm_log(PM_LOG_FLOW1, "sorting by dependencies"); _alpm_log(PM_LOG_FLOW1, "sorting by dependencies");
lp = sortbydeps(trans->install_q, PM_TRANS_TYPE_ADD); lp = sortbydeps(trans->packages, PM_TRANS_TYPE_ADD);
/* free the old alltargs */ /* free the old alltargs */
FREELISTPTR(trans->install_q); FREELISTPTR(trans->packages);
trans->install_q = lp; trans->packages = lp;
TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL); TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);
} }
@ -201,7 +201,7 @@ int add_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
TRANS_CB(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL); TRANS_CB(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, "looking for file conflicts"); _alpm_log(PM_LOG_FLOW1, "looking for file conflicts");
lp = db_find_conflicts(db, trans->install_q, handle->root); lp = db_find_conflicts(db, trans->packages, handle->root);
if(lp != NULL) { if(lp != NULL) {
*data = lp; *data = lp;
RET_ERR(PM_ERR_FILE_CONFLICTS, -1); RET_ERR(PM_ERR_FILE_CONFLICTS, -1);
@ -225,11 +225,11 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
if(trans->install_q == NULL) { if(trans->packages == NULL) {
return(0); return(0);
} }
for(targ = trans->install_q; targ; targ = targ->next) { for(targ = trans->packages; targ; targ = targ->next) {
tartype_t gztype = { tartype_t gztype = {
(openfunc_t)_alpm_gzopen_frontend, (openfunc_t)_alpm_gzopen_frontend,
(closefunc_t)gzclose, (closefunc_t)gzclose,

View file

@ -489,8 +489,7 @@ void *alpm_trans_getinfo(unsigned char parm)
case PM_TRANS_TYPE: data = (void *)(int)trans->type; break; case PM_TRANS_TYPE: data = (void *)(int)trans->type; break;
case PM_TRANS_FLAGS: data = (void *)(int)trans->flags; break; case PM_TRANS_FLAGS: data = (void *)(int)trans->flags; break;
case PM_TRANS_TARGETS: data = trans->targets; break; case PM_TRANS_TARGETS: data = trans->targets; break;
case PM_TRANS_INSTALLQ: data = trans->install_q; break; case PM_TRANS_PACKAGES: data = trans->packages; break;
case PM_TRANS_REMOVEQ: data = trans->remove_q; break;
default: default:
data = NULL; data = NULL;
break; break;

View file

@ -188,6 +188,8 @@ enum {
void *alpm_sync_getinfo(PM_SYNCPKG *sync, unsigned char parm); void *alpm_sync_getinfo(PM_SYNCPKG *sync, unsigned char parm);
int alpm_sync_sysupgrade(PM_LIST **data);
/* /*
* Transactions * Transactions
*/ */
@ -234,8 +236,7 @@ enum {
PM_TRANS_TYPE = 1, PM_TRANS_TYPE = 1,
PM_TRANS_FLAGS, PM_TRANS_FLAGS,
PM_TRANS_TARGETS, PM_TRANS_TARGETS,
PM_TRANS_INSTALLQ, PM_TRANS_PACKAGES
PM_TRANS_REMOVEQ
}; };
void *alpm_trans_getinfo(unsigned char parm); void *alpm_trans_getinfo(unsigned char parm);

View file

@ -60,7 +60,7 @@ int remove_loadtarget(pmdb_t *db, pmtrans_t *trans, char *name)
_alpm_log(PM_LOG_ERROR, "could not find %s in database", name); _alpm_log(PM_LOG_ERROR, "could not find %s in database", name);
RET_ERR(PM_ERR_PKG_NOT_FOUND, -1); RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
} }
trans->remove_q = pm_list_add(trans->remove_q, info); trans->packages = pm_list_add(trans->packages, info);
return(0); return(0);
} }
@ -78,19 +78,19 @@ int remove_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL); TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, "looking for unsatisfied dependencies"); _alpm_log(PM_LOG_FLOW1, "looking for unsatisfied dependencies");
if((lp = checkdeps(db, trans->type, trans->remove_q)) != NULL) { if((lp = checkdeps(db, trans->type, trans->packages)) != NULL) {
if(trans->flags & PM_TRANS_FLAG_CASCADE) { if(trans->flags & PM_TRANS_FLAG_CASCADE) {
while(lp) { while(lp) {
PMList *j; PMList *j;
for(j = lp; j; j = j->next) { for(j = lp; j; j = j->next) {
pmdepmissing_t* miss = (pmdepmissing_t*)j->data; pmdepmissing_t* miss = (pmdepmissing_t*)j->data;
info = db_scan(db, miss->depend.name, INFRQ_ALL); info = db_scan(db, miss->depend.name, INFRQ_ALL);
if(!pkg_isin(info, trans->remove_q)) { if(!pkg_isin(info, trans->packages)) {
trans->remove_q = pm_list_add(trans->remove_q, info); trans->packages = pm_list_add(trans->packages, info);
} }
} }
FREELIST(lp); FREELIST(lp);
lp = checkdeps(db, trans->type, trans->remove_q); lp = checkdeps(db, trans->type, trans->packages);
} }
} else { } else {
*data = lp; *data = lp;
@ -100,15 +100,15 @@ int remove_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
if(trans->flags & PM_TRANS_FLAG_RECURSE) { if(trans->flags & PM_TRANS_FLAG_RECURSE) {
_alpm_log(PM_LOG_FLOW1, "finding removable dependencies"); _alpm_log(PM_LOG_FLOW1, "finding removable dependencies");
trans->remove_q = removedeps(db, trans->remove_q); trans->packages = removedeps(db, trans->packages);
} }
/* re-order w.r.t. dependencies */ /* re-order w.r.t. dependencies */
_alpm_log(PM_LOG_FLOW1, "sorting by dependencies"); _alpm_log(PM_LOG_FLOW1, "sorting by dependencies");
lp = sortbydeps(trans->remove_q, PM_TRANS_TYPE_REMOVE); lp = sortbydeps(trans->packages, PM_TRANS_TYPE_REMOVE);
/* free the old alltargs */ /* free the old alltargs */
FREELISTPTR(trans->remove_q); FREELISTPTR(trans->packages);
trans->remove_q = lp; trans->packages = lp;
TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL); TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);
} }
@ -126,7 +126,7 @@ int remove_commit(pmdb_t *db, pmtrans_t *trans)
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
for(targ = trans->remove_q; targ; targ = targ->next) { for(targ = trans->packages; targ; targ = targ->next) {
char pm_install[PATH_MAX]; char pm_install[PATH_MAX];
info = (pmpkg_t*)targ->data; info = (pmpkg_t*)targ->data;

View file

@ -45,8 +45,7 @@ pmtrans_t *trans_new()
} }
trans->targets = NULL; trans->targets = NULL;
trans->install_q = NULL; trans->packages = NULL;
trans->remove_q = NULL;
trans->type = 0; trans->type = 0;
trans->flags = 0; trans->flags = 0;
trans->cb = NULL; trans->cb = NULL;
@ -62,19 +61,15 @@ void trans_free(pmtrans_t *trans)
} }
FREELIST(trans->targets); FREELIST(trans->targets);
/* ORE - ugly */
if(trans->type == PM_TRANS_TYPE_SYNC) { if(trans->type == PM_TRANS_TYPE_SYNC) {
PMList *i = trans->install_q; PMList *i;
while(i) { for(i = trans->packages; i; i = i->next) {
PMList *j = i->next;
sync_free(i->data); sync_free(i->data);
i->data = NULL; i->data = NULL;
pm_list_free(i);
i = j;
} }
FREELIST(trans->packages);
} else { } else {
FREELISTPKGS(trans->install_q); FREELISTPKGS(trans->packages);
FREELISTPKGS(trans->remove_q);
} }
free(trans); free(trans);
@ -142,10 +137,6 @@ int trans_prepare(pmtrans_t *trans, PMList **data)
/* Sanity checks */ /* Sanity checks */
ASSERT(trans != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
if(trans->install_q == NULL && trans->remove_q == NULL) {
return(0);
}
switch(trans->type) { switch(trans->type) {
case PM_TRANS_TYPE_ADD: case PM_TRANS_TYPE_ADD:
case PM_TRANS_TYPE_UPGRADE: case PM_TRANS_TYPE_UPGRADE:
@ -179,7 +170,7 @@ int trans_commit(pmtrans_t *trans)
ASSERT(trans != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
/* If there's nothing to do, return without complaining */ /* If there's nothing to do, return without complaining */
if(trans->install_q == NULL && trans->remove_q == NULL) { if(trans->packages == NULL) {
return(0); return(0);
} }

View file

@ -35,8 +35,7 @@ typedef struct __pmtrans_t {
unsigned char flags; unsigned char flags;
unsigned char state; unsigned char state;
PMList *targets; /* PMList of (char *) */ PMList *targets; /* PMList of (char *) */
PMList *install_q; /* PMList of (pmpkginfo_t *) */ PMList *packages; /* PMList of (pmpkginfo_t *) */
PMList *remove_q; /* PMList of (pmpkginfo_t *) */
alpm_trans_cb cb; alpm_trans_cb cb;
} pmtrans_t; } pmtrans_t;