summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-04-06 18:25:33 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-04-06 18:25:33 +0000
commit04e054f3cbc9ddda9d99e4891055ae2743b3b8ff (patch)
treec3b389113853b45b4bc99bf707a037a4ce186efc /lib/libalpm
parent08b34b8aef5e5567c9f186ed9c6ae2b5a7aee47b (diff)
downloadpacman-04e054f3cbc9ddda9d99e4891055ae2743b3b8ff.tar.xz
replaced transaction 'packages' field by 2 queues: one for packages to be installed and the other for the ones to be removed
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/add.c18
-rw-r--r--lib/libalpm/remove.c25
-rw-r--r--lib/libalpm/trans.c23
-rw-r--r--lib/libalpm/trans.h3
4 files changed, 43 insertions, 26 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 07b16dec..cb11a871 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -93,7 +93,7 @@ int add_loadtarget(pmdb_t *db, pmtrans_t *trans, char *name)
* if so, replace it in the list */
/* ORE
we'd better do it before load_pkg. */
- for(j = trans->packages; j; j = j->next) {
+ for(j = trans->install_q; j; j = j->next) {
pmpkg_t *pkg = j->data;
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 */
- trans->packages = pm_list_add(trans->packages, info);
+ trans->install_q = pm_list_add(trans->install_q, info);
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);
_alpm_log(PM_LOG_FLOW1, "looking for conflicts or unsatisfied dependencies");
- lp = checkdeps(db, trans->type, trans->packages);
+ lp = checkdeps(db, trans->type, trans->install_q);
if(lp != NULL) {
int errorout = 0;
@@ -187,10 +187,10 @@ int add_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
/* re-order w.r.t. dependencies */
_alpm_log(PM_LOG_FLOW1, "sorting by dependencies");
- lp = sortbydeps(trans->packages, PM_TRANS_TYPE_ADD);
+ lp = sortbydeps(trans->install_q, PM_TRANS_TYPE_ADD);
/* free the old alltargs */
- FREELISTPTR(trans->packages);
- trans->packages = lp;
+ FREELISTPTR(trans->install_q);
+ trans->install_q = lp;
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);
_alpm_log(PM_LOG_FLOW1, "looking for file conflicts");
- lp = db_find_conflicts(db, trans->packages, handle->root);
+ lp = db_find_conflicts(db, trans->install_q, handle->root);
if(lp != NULL) {
*data = lp;
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(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
- if(trans->packages == NULL) {
+ if(trans->install_q == NULL) {
return(0);
}
- for(targ = trans->packages; targ; targ = targ->next) {
+ for(targ = trans->install_q; targ; targ = targ->next) {
tartype_t gztype = {
(openfunc_t)_alpm_gzopen_frontend,
(closefunc_t)gzclose,
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index acff25fc..4ac99220 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -53,11 +53,14 @@ int remove_loadtarget(pmdb_t *db, pmtrans_t *trans, char *name)
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(name != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
+ /* ORE
+ we should better find the package in the cache, and then perform a
+ db_read(INFRQ_FILES) to add files information to it. */
if((info = db_scan(db, name, INFRQ_ALL)) == NULL) {
_alpm_log(PM_LOG_ERROR, "could not find %s in database", name);
RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
}
- trans->packages = pm_list_add(trans->packages, info);
+ trans->remove_q = pm_list_add(trans->remove_q, info);
return(0);
}
@@ -74,20 +77,20 @@ int remove_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
if(!(trans->flags & (PM_TRANS_FLAG_NODEPS)) && (trans->type != PM_TRANS_TYPE_UPGRADE)) {
TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
- _alpm_log(PM_LOG_FLOW1, "looking for conflicts or unsatisfied dependencies");
- if((lp = checkdeps(db, trans->type, trans->packages)) != NULL) {
+ _alpm_log(PM_LOG_FLOW1, "looking for unsatisfied dependencies");
+ if((lp = checkdeps(db, trans->type, trans->remove_q)) != NULL) {
if(trans->flags & PM_TRANS_FLAG_CASCADE) {
while(lp) {
PMList *j;
for(j = lp; j; j = j->next) {
pmdepmissing_t* miss = (pmdepmissing_t*)j->data;
info = db_scan(db, miss->depend.name, INFRQ_ALL);
- if(!pkg_isin(info, trans->packages)) {
- trans->packages = pm_list_add(trans->packages, info);
+ if(!pkg_isin(info, trans->remove_q)) {
+ trans->remove_q = pm_list_add(trans->remove_q, info);
}
}
FREELIST(lp);
- lp = checkdeps(db, trans->type, trans->packages);
+ lp = checkdeps(db, trans->type, trans->remove_q);
}
} else {
*data = lp;
@@ -97,15 +100,15 @@ int remove_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
if(trans->flags & PM_TRANS_FLAG_RECURSE) {
_alpm_log(PM_LOG_FLOW1, "finding removable dependencies");
- trans->packages = removedeps(db, trans->packages);
+ trans->remove_q = removedeps(db, trans->remove_q);
}
/* re-order w.r.t. dependencies */
_alpm_log(PM_LOG_FLOW1, "sorting by dependencies");
- lp = sortbydeps(trans->packages, PM_TRANS_TYPE_REMOVE);
+ lp = sortbydeps(trans->remove_q, PM_TRANS_TYPE_REMOVE);
/* free the old alltargs */
- FREELISTPTR(trans->packages);
- trans->packages = lp;
+ FREELISTPTR(trans->remove_q);
+ trans->remove_q = lp;
TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);
}
@@ -123,7 +126,7 @@ int remove_commit(pmdb_t *db, pmtrans_t *trans)
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
- for(targ = trans->packages; targ; targ = targ->next) {
+ for(targ = trans->remove_q; targ; targ = targ->next) {
char pm_install[PATH_MAX];
info = (pmpkg_t*)targ->data;
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 6e278cd7..af0c6b7d 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -45,7 +45,8 @@ pmtrans_t *trans_new()
}
trans->targets = NULL;
- trans->packages = NULL;
+ trans->install_q = NULL;
+ trans->remove_q = NULL;
trans->type = 0;
trans->flags = 0;
trans->cb = NULL;
@@ -63,9 +64,17 @@ void trans_free(pmtrans_t *trans)
FREELIST(trans->targets);
/* ORE - ugly */
if(trans->type == PM_TRANS_TYPE_SYNC) {
- FREELISTPTR(trans->packages);
+ PMList *i = trans->install_q;
+ while(i) {
+ PMList *j = i->next;
+ sync_free(i->data);
+ i->data = NULL;
+ pm_list_free(i);
+ i = j;
+ }
} else {
- FREELISTPKGS(trans->packages);
+ FREELISTPKGS(trans->install_q);
+ FREELISTPKGS(trans->remove_q);
}
free(trans);
@@ -133,7 +142,9 @@ int trans_prepare(pmtrans_t *trans, PMList **data)
/* Sanity checks */
ASSERT(trans != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
- ASSERT(trans->packages != NULL, return(0));
+ if(trans->install_q == NULL && trans->remove_q == NULL) {
+ return(0);
+ }
switch(trans->type) {
case PM_TRANS_TYPE_ADD:
@@ -168,7 +179,9 @@ int trans_commit(pmtrans_t *trans)
ASSERT(trans != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
/* If there's nothing to do, return without complaining */
- ASSERT(trans->packages != NULL, return(0));
+ if(trans->install_q == NULL && trans->remove_q == NULL) {
+ return(0);
+ }
switch(trans->type) {
case PM_TRANS_TYPE_ADD:
diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h
index 98732fbf..74ea7e8c 100644
--- a/lib/libalpm/trans.h
+++ b/lib/libalpm/trans.h
@@ -35,7 +35,8 @@ typedef struct __pmtrans_t {
unsigned char flags;
unsigned char state;
PMList *targets; /* PMList of (char *) */
- PMList *packages; /* PMList of (pmpkginfo_t *) */
+ PMList *install_q; /* PMList of (pmpkginfo_t *) */
+ PMList *remove_q; /* PMList of (pmpkginfo_t *) */
alpm_trans_cb cb;
} pmtrans_t;