From 77efd512165ca2066dc6547bda52082f8bd11db2 Mon Sep 17 00:00:00 2001 From: Nagy Gabor Date: Sun, 9 Nov 2008 17:34:49 +0100 Subject: New error type: PM_ERR_PKG_IGNORED This patch fixes FS#12059. Now sync_addtarget can return with PM_ERR_PKG_IGNORED, which indicates that although the requested package was found it is in ignorepkg, so alpm could not add it to the transaction. So the front-end can decide what to do. Signed-off-by: Nagy Gabor Signed-off-by: Dan McGee --- lib/libalpm/alpm.h | 1 + lib/libalpm/deps.c | 10 +++++++++- lib/libalpm/error.c | 2 ++ lib/libalpm/sync.c | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 43df31c1..e3a512a1 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -493,6 +493,7 @@ enum _pmerrno_t { PM_ERR_TRANS_DOWNLOADING, /* Packages */ PM_ERR_PKG_NOT_FOUND, + PM_ERR_PKG_IGNORED, PM_ERR_PKG_INVALID, PM_ERR_PKG_OPEN, PM_ERR_PKG_LOAD, diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 694e5be5..dd5bd207 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -520,6 +520,7 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs, alpm_list_t *excluding, int prompt) { alpm_list_t *i, *j; + int ignored = 0; /* 1. literals */ for(i = dbs; i; i = i->next) { pmpkg_t *pkg = _alpm_db_get_pkgfromcache(i->data, dep->name); @@ -531,6 +532,7 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs, NULL, NULL, &install); } if(!install) { + ignored = 1; continue; } } @@ -550,6 +552,7 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs, pkg, NULL, NULL, &install); } if(!install) { + ignored = 1; continue; } } @@ -559,6 +562,11 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs, } } } + if(ignored) { /* resolvedeps will override these */ + pm_errno = PM_ERR_PKG_IGNORED; + } else { + pm_errno = PM_ERR_PKG_NOT_FOUND; + } return(NULL); } @@ -640,7 +648,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *pkg, alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_depmiss_free); alpm_list_free(deps); return(-1); - } else { + } else { _alpm_log(PM_LOG_DEBUG, "pulling dependency %s (needed by %s)\n", alpm_pkg_get_name(spkg), alpm_pkg_get_name(tpkg)); *packages = alpm_list_add(*packages, spkg); diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c index 1f605806..01dc758c 100644 --- a/lib/libalpm/error.c +++ b/lib/libalpm/error.c @@ -106,6 +106,8 @@ const char SYMEXPORT *alpm_strerror(int err) /* Packages */ case PM_ERR_PKG_NOT_FOUND: return _("could not find or read package"); + case PM_ERR_PKG_IGNORED: + return _("operation cancelled due to ignorepkg"); case PM_ERR_PKG_INVALID: return _("invalid or corrupted package"); case PM_ERR_PKG_OPEN: diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 49ea3c27..4cbdb621 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -297,7 +297,8 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy FREE(targline); if(spkg == NULL) { - RET_ERR(PM_ERR_PKG_NOT_FOUND, -1); + /* pm_errno is set by _alpm_resolvedep */ + return(-1); } if(_alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg))) { -- cgit v1.2.3-24-g4f1b