[pacman-dev] [PATCH] Dependency error/log messages fix

Nagy Gabor ngaba at bibl.u-szeged.hu
Fri Oct 26 19:15:43 EDT 2007


From 4ee4c412b7ce0a688a81b1f856ef6462c8ee269d Mon Sep 17 00:00:00 2001
From: Nagy Gabor <ngaba at bibl.u-szeged.hu>
Date: Sat, 27 Oct 2007 01:14:35 +0200
Subject: [PATCH] Dependency error/log messages fix
 The old code used only the depend.name in messages, which might have not been informative. The new code uses the whole dependency string in %DEPENDS% format.

---
 lib/libalpm/deps.c |   18 +++++++++++-------
 lib/libalpm/sync.c |    4 +++-
 src/util/testdb.c  |    4 +++-
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 7f4fb0b..4beaf70 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -306,7 +306,7 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op,
 
 							if(alpm_depcmp(pkg, depend)) {
 								_alpm_log(PM_LOG_DEBUG, "checkdeps: dependency '%s' has moved from '%s' to '%s'\n",
-													depend->name, alpm_pkg_get_name(oldpkg), alpm_pkg_get_name(pkg));
+													k->data, alpm_pkg_get_name(oldpkg), alpm_pkg_get_name(pkg));
 								satisfied = 1;
 								break;
 							}
@@ -322,7 +322,7 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op,
 									/* we ignore packages that will be updated because we know
 									 * that the updated ones don't satisfy depend */
 									_alpm_log(PM_LOG_DEBUG, "checkdeps: dependency '%s' satisfied by installed package '%s'\n",
-														depend->name, alpm_pkg_get_name(pkg));
+														k->data, alpm_pkg_get_name(pkg));
 									satisfied = 1;
 									break;
 								}
@@ -380,7 +380,7 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op,
 				/* else if still not found... */
 				if(!found) {
 					_alpm_log(PM_LOG_DEBUG, "missing dependency '%s' for package '%s'\n",
-					                          depend->name, alpm_pkg_get_name(tp));
+					                          j->data, alpm_pkg_get_name(tp));
 					miss = _alpm_depmiss_new(alpm_pkg_get_name(tp), PM_DEP_TYPE_DEPEND, depend->mod,
 					                         depend->name, depend->version);
 					if(!_alpm_depmiss_isin(miss, baddeps)) {
@@ -426,7 +426,7 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op,
 							pmpkg_t *pkg = l->data;
 							if(alpm_depcmp(pkg, depend) && !_alpm_pkg_find(alpm_pkg_get_name(pkg), packages)) {
 								_alpm_log(PM_LOG_DEBUG, "checkdeps: dependency '%s' satisfied by installed package '%s'\n",
-										depend->name, alpm_pkg_get_name(pkg));
+										k->data, alpm_pkg_get_name(pkg));
 								satisfied = 1;
 								break;
 							}
@@ -686,8 +686,10 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
 		for(j = *list; j && !found; j = j->next) {
 			pmpkg_t *sp = j->data;
 			if(alpm_depcmp(sp, missdep)) {
+				char *missdepstring = alpm_dep_get_string(missdep);
 				_alpm_log(PM_LOG_DEBUG, "%s satisfies dependency %s -- skipping\n",
-				          alpm_pkg_get_name(sp), missdep->name);
+				          alpm_pkg_get_name(sp), missdepstring);
+				free(missdepstring);
 				found = 1;
 			}
 		}
@@ -713,8 +715,10 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
 		}
 
 		if(!found) {
-			_alpm_log(PM_LOG_ERROR, _("cannot resolve dependencies for \"%s\" (\"%s\" is not in the package set)\n"),
-			          miss->target, missdep->name);
+			char *missdepstring = alpm_dep_get_string(missdep);
+			_alpm_log(PM_LOG_ERROR, _("cannot resolve \"%s\" dependency of \"%s\"\n"),
+			          missdepstring, miss->target);
+			free(missdepstring);
 			if(data) {
 				if((miss = malloc(sizeof(pmdepmissing_t))) == NULL) {
 					_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes\n"), sizeof(pmdepmissing_t));
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 3e12ffb..f4ed6dd 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -674,8 +674,10 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
 						pmsyncpkg_t *sp = l->data;
 						pmpkg_t *sppkg = sp->pkg;
 						if(alpm_depcmp(sppkg, &(miss->depend))) {
+							char *missdepstring = alpm_dep_get_string(&(miss->depend));
 							_alpm_log(PM_LOG_DEBUG, "sync: dependency '%s' satisfied by package '%s'\n",
-									miss->depend.name, alpm_pkg_get_name(sppkg));
+									missdepstring, alpm_pkg_get_name(sppkg));
+							free(missdepstring);
 							satisfied = 1;
 						}
 					}
diff --git a/src/util/testdb.c b/src/util/testdb.c
index 1331f2c..a06456a 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -178,8 +178,10 @@ int main(int argc, char **argv)
   for(i = data; i; i = alpm_list_next(i)) {
     pmdepmissing_t *miss = alpm_list_getdata(i);
     pmdepend_t *dep = alpm_miss_get_dep(miss);
+    char *depstring = alpm_dep_get_string(dep);
     printf("missing dependency for %s : %s\n", alpm_miss_get_target(miss),
-        alpm_dep_get_name(dep));
+        depstring);
+    free(depstring);
   }
 
   /* check requiredby */
-- 
1.5.3.4





More information about the pacman-dev mailing list