From 08b0b6de96243a67b6db095f760e0c2b22ef4536 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Sun, 1 Nov 2015 20:42:01 -0500 Subject: [PATCH] add detail to broken dependency errors The difference between a sync target having an unmet dependency and breaking a dependency for an installed package is a common source of confusion. Signed-off-by: Andrew Gregory Signed-off-by: Allan McRae --- src/pacman/remove.c | 3 ++- src/pacman/sync.c | 27 ++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/pacman/remove.c b/src/pacman/remove.c index 069f2363..e41e7f52 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -122,7 +122,8 @@ int pacman_remove(alpm_list_t *targets) for(i = data; i; i = alpm_list_next(i)) { alpm_depmissing_t *miss = i->data; char *depstring = alpm_dep_compute_string(miss->depend); - colon_printf(_("%s: requires %s\n"), miss->target, depstring); + colon_printf(_("%s: removing %s breaks dependency '%s'\n"), + miss->target, miss->causingpkg, depstring); free(depstring); alpm_depmissing_free(miss); } diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 2a0f4b55..b13f76af 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -707,6 +707,26 @@ static int sync_trans(alpm_list_t *targets) return sync_prepare_execute(); } +static void print_broken_dep(alpm_depmissing_t *miss) +{ + char *depstring = alpm_dep_compute_string(miss->depend); + alpm_list_t *trans_add = alpm_trans_get_add(config->handle); + alpm_pkg_t *pkg; + if(miss->causingpkg == NULL) { + /* package being installed/upgraded has unresolved dependency */ + colon_printf(_("%s: requires %s\n"), miss->target, depstring); + } else if((pkg = alpm_pkg_find(trans_add, miss->causingpkg))) { + /* upgrading a package breaks a local dependency */ + colon_printf(_("%s: installing %s (%s) breaks dependency '%s'\n"), + miss->target, miss->causingpkg, alpm_pkg_get_version(pkg), depstring); + } else { + /* removing a package breaks a local dependency */ + colon_printf(_("%s: removing %s breaks dependency '%s'\n"), + miss->target, miss->causingpkg, depstring); + } + free(depstring); +} + int sync_prepare_execute(void) { alpm_list_t *i, *packages, *data = NULL; @@ -727,11 +747,8 @@ int sync_prepare_execute(void) break; case ALPM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { - alpm_depmissing_t *miss = i->data; - char *depstring = alpm_dep_compute_string(miss->depend); - colon_printf(_("%s: requires %s\n"), miss->target, depstring); - free(depstring); - alpm_depmissing_free(miss); + print_broken_dep(i->data); + alpm_depmissing_free(i->data); } break; case ALPM_ERR_CONFLICTING_DEPS: