From e7a2232934e2658c3c7827d2ce706c1a8f5301b9 Mon Sep 17 00:00:00 2001 From: Chantry Xavier Date: Sun, 16 Mar 2008 22:36:31 +0100 Subject: Kill PM_TRANS_TYPE_ADD. This was totally useless. Signed-off-by: Chantry Xavier Signed-off-by: Dan McGee --- lib/libalpm/add.c | 12 ++---------- lib/libalpm/alpm.h | 4 +--- lib/libalpm/deps.c | 13 ++++++------- lib/libalpm/deps.h | 2 +- lib/libalpm/error.c | 2 -- lib/libalpm/remove.c | 2 +- lib/libalpm/sync.c | 2 +- lib/libalpm/trans.c | 3 --- 8 files changed, 12 insertions(+), 28 deletions(-) diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 5dcc0587..78f6e951 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -68,14 +68,6 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) pkgname = alpm_pkg_get_name(pkg); pkgver = alpm_pkg_get_version(pkg); - if(trans->type != PM_TRANS_TYPE_UPGRADE) { - /* only install this package if it is not already installed */ - if(_alpm_db_get_pkgfromcache(db, pkgname)) { - pm_errno = PM_ERR_PKG_INSTALLED; - goto error; - } - } - /* check if an older version of said package is already in transaction * packages. if so, replace it in the list */ for(i = trans->packages; i; i = i->next) { @@ -130,7 +122,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) /* look for unsatisfied dependencies */ _alpm_log(PM_LOG_DEBUG, "looking for unsatisfied dependencies\n"); - lp = alpm_checkdeps(db, trans->type == PM_TRANS_TYPE_UPGRADE, NULL, trans->packages); + lp = alpm_checkdeps(db, 1, NULL, trans->packages); if(lp != NULL) { if(data) { *data = lp; @@ -168,7 +160,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) /* re-order w.r.t. dependencies */ _alpm_log(PM_LOG_DEBUG, "sorting by dependencies\n"); - lp = _alpm_sortbydeps(trans->packages, PM_TRANS_TYPE_ADD); + lp = _alpm_sortbydeps(trans->packages, 0); /* free the old alltargs */ alpm_list_free(trans->packages); trans->packages = lp; diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index b5294b90..8296bc7d 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -256,10 +256,9 @@ int alpm_sync_sysupgrade(pmdb_t *db_local, /* Types */ typedef enum _pmtranstype_t { - PM_TRANS_TYPE_ADD = 1, + PM_TRANS_TYPE_UPGRADE = 1, PM_TRANS_TYPE_REMOVE, PM_TRANS_TYPE_REMOVEUPGRADE, - PM_TRANS_TYPE_UPGRADE, PM_TRANS_TYPE_SYNC } pmtranstype_t; @@ -455,7 +454,6 @@ enum _pmerrno_t { PM_ERR_PKG_INVALID, PM_ERR_PKG_OPEN, PM_ERR_PKG_LOAD, - PM_ERR_PKG_INSTALLED, PM_ERR_PKG_CANT_FRESH, PM_ERR_PKG_CANT_REMOVE, PM_ERR_PKG_INVALID_NAME, diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 245323e6..180c46bf 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -109,20 +109,19 @@ static alpm_list_t *dep_graph_init(alpm_list_t *targets) /* Re-order a list of target packages with respect to their dependencies. * - * Example (PM_TRANS_TYPE_ADD): + * Example (reverse == 0): * A depends on C * B depends on A * Target order is A,B,C,D * * Should be re-ordered to C,A,B,D * - * mode should be either PM_TRANS_TYPE_ADD or PM_TRANS_TYPE_REMOVE. This - * affects the dependency order sortbydeps() will use. + * if reverse is > 0, the dependency order will be reversed. * * This function returns the new alpm_list_t* target list. * */ -alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, pmtranstype_t mode) +alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse) { alpm_list_t *newtargs = NULL; alpm_list_t *vertices = NULL; @@ -157,7 +156,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, pmtranstype_t mode) pmpkg_t *vertexpkg = vertex->data; pmpkg_t *childpkg = nextchild->data; _alpm_log(PM_LOG_WARNING, _("dependency cycle detected:\n")); - if(mode == PM_TRANS_TYPE_REMOVE) { + if(reverse) { _alpm_log(PM_LOG_WARNING, _("%s will be removed after its %s dependency\n"), vertexpkg->name, childpkg->name); } else { _alpm_log(PM_LOG_WARNING, _("%s will be installed before its %s dependency\n"), vertexpkg->name, childpkg->name); @@ -182,8 +181,8 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, pmtranstype_t mode) _alpm_log(PM_LOG_DEBUG, "sorting dependencies finished\n"); - if(mode == PM_TRANS_TYPE_REMOVE) { - /* we're removing packages, so reverse the order */ + if(reverse) { + /* reverse the order */ alpm_list_t *tmptargs = alpm_list_reverse(newtargs); /* free the old one */ alpm_list_free(newtargs); diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h index 0c3975e6..fe851288 100644 --- a/lib/libalpm/deps.h +++ b/lib/libalpm/deps.h @@ -45,7 +45,7 @@ pmdepend_t *_alpm_dep_dup(const pmdepend_t *dep); pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdepend_t *dep, const char *causinpkg); void _alpm_depmiss_free(pmdepmissing_t *miss); -alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, pmtranstype_t mode); +alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse); void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit); int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, alpm_list_t **list, alpm_list_t *remove, pmtrans_t *trans, alpm_list_t diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c index 2e015a68..66b4e288 100644 --- a/lib/libalpm/error.c +++ b/lib/libalpm/error.c @@ -109,8 +109,6 @@ const char SYMEXPORT *alpm_strerror(int err) return _("cannot open package file"); case PM_ERR_PKG_LOAD: return _("cannot load package data"); - case PM_ERR_PKG_INSTALLED: - return _("package already installed"); case PM_ERR_PKG_CANT_FRESH: return _("package not installed or lesser version"); case PM_ERR_PKG_CANT_REMOVE: diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index c04dab69..dfdcabe0 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -158,7 +158,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) /* re-order w.r.t. dependencies */ _alpm_log(PM_LOG_DEBUG, "sorting by dependencies\n"); - lp = _alpm_sortbydeps(trans->packages, PM_TRANS_TYPE_REMOVE); + lp = _alpm_sortbydeps(trans->packages, 1); /* free the old alltargs */ alpm_list_free(trans->packages); trans->packages = lp; diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 26d1d3ca..ea2d3143 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -443,7 +443,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync } /* re-order w.r.t. dependencies */ - alpm_list_t *sortlist = _alpm_sortbydeps(list, PM_TRANS_TYPE_ADD); + alpm_list_t *sortlist = _alpm_sortbydeps(list, 0); alpm_list_t *newpkgs = NULL; for(i = sortlist; i; i = i->next) { for(j = trans->packages; j; j = j->next) { diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 5836df5a..3edbbacb 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -307,7 +307,6 @@ int _alpm_trans_addtarget(pmtrans_t *trans, char *target) ASSERT(target != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); switch(trans->type) { - case PM_TRANS_TYPE_ADD: case PM_TRANS_TYPE_UPGRADE: if(_alpm_add_loadtarget(trans, handle->db_local, target) == -1) { /* pm_errno is set by _alpm_add_loadtarget() */ @@ -349,7 +348,6 @@ int _alpm_trans_prepare(pmtrans_t *trans, alpm_list_t **data) } switch(trans->type) { - case PM_TRANS_TYPE_ADD: case PM_TRANS_TYPE_UPGRADE: if(_alpm_add_prepare(trans, handle->db_local, data) == -1) { /* pm_errno is set by _alpm_add_prepare() */ @@ -394,7 +392,6 @@ int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data) trans->state = STATE_COMMITING; switch(trans->type) { - case PM_TRANS_TYPE_ADD: case PM_TRANS_TYPE_UPGRADE: if(_alpm_add_commit(trans, handle->db_local) == -1) { /* pm_errno is set by _alpm_add_commit() */ -- cgit v1.2.3-70-g09d2