[pacman-dev] [PATCH] libalpm/package.c : fix requiredby with multiple providers.

Xavier shiningxc at gmail.com
Thu Oct 18 12:30:14 EDT 2007


On Thu, Oct 18, 2007 at 06:09:56PM +0200, Nagy Gabor wrote:
> > Good catch. I'll pull this into my tree later tonight.
> Indeed, this is really nice catch.
> I don't want to bother you, but do we need the line continue? ;-)
> And we don't need the satisfies variable neither.

lol, of course, you are perfectly right, I edited that blindly without
thinking :)
Attaching the updated patch.
-------------- next part --------------
>From 1c5d51f7103866c00d9a7bf4a2c0b5b0b9bbe1f1 Mon Sep 17 00:00:00 2001
From: Chantry Xavier <shiningxc at gmail.com>
Date: Thu, 18 Oct 2007 13:26:04 +0200
Subject: [PATCH] libalpm/package.c : fix requiredby with multiple providers.

The code didn't match the following comment :
"A depends on B through n depends <=> A listed in B's requiredby n times"

It stopped at n=1 with a break.

I was surprised to see this case happens in real, that's how I noticed the bug:
wine depends on both freeglut and glut, while freeglut provides glut.

So when installing wine, the update_depends function listed wine twice in freeglut's requiredby.
But the compute_requiredby function (used when installing freeglut, and used by testdb)
listed wine only once in freeglut's requiredby.
That made testdb unhappy.

Signed-off-by: Chantry Xavier <shiningxc at gmail.com>
---
 lib/libalpm/package.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 38e6e4c..9e45b1d 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -527,7 +527,6 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
 
 		for(j = alpm_pkg_get_depends(cachepkg); j; j = j->next) {
 			pmdepend_t *dep;
-			int satisfies;
 
 			if(!j->data) {
 				continue;
@@ -537,14 +536,12 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
 					continue;
 			}
 			
-			satisfies = alpm_depcmp(pkg, dep);
-			FREE(dep);
-			if(satisfies) {
+			if(alpm_depcmp(pkg, dep)) {
 				_alpm_log(PM_LOG_DEBUG, "adding '%s' in requiredby field for '%s'\n",
 				          cachepkgname, pkg->name);
 				reqs = alpm_list_add(reqs, strdup(cachepkgname));
-				break;
 			}
+			FREE(dep);
 		}
 	}
 	return(reqs);
-- 
1.5.3.4



More information about the pacman-dev mailing list