Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
authorNagy Gabor <ngaba@petra.hos.u-szeged.hu>2007-05-14 02:54:16 -0400
committerDan McGee <dan@archlinux.org>2007-05-14 10:56:52 -0400
commita3994f975ba6cc52c56efb081fc94809a03500ce (patch)
treeb3c21eae02a70efe567ed87a12af440ebcaf65e5 /lib/libalpm/package.c
parent2bcecbd62cb2bda681a3aba46bb0bbf690ba7219 (diff)
Use alpm_depcmp in _alpm_pkg_update_requiredby
The old function did too much on its own; let alpm_depcmp do the hard work. This will allow for future versioned provisions if necessary. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index e8dd5d60..17851535 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -533,11 +533,11 @@ int _alpm_pkg_splitname(const char *target, char *name, char *version, int witha
return(0);
}
-
+/* scan the local db to fill in requiredby field of package,
+ * used when we want to install or add a package */
void _alpm_pkg_update_requiredby(pmpkg_t *pkg)
{
- alpm_list_t *i, *j, *k;
- const char *pkgname = alpm_pkg_get_name(pkg);
+ alpm_list_t *i, *j;
pmdb_t *localdb = alpm_option_get_localdb();
for(i = _alpm_db_get_pkgcache(localdb); i; i = i->next) {
@@ -549,6 +549,8 @@ void _alpm_pkg_update_requiredby(pmpkg_t *pkg)
for(j = alpm_pkg_get_depends(cachepkg); j; j = j->next) {
pmdepend_t *dep;
+ int satisfies;
+
if(!j->data) {
continue;
}
@@ -557,33 +559,16 @@ void _alpm_pkg_update_requiredby(pmpkg_t *pkg)
continue;
}
- /* check the actual package itself */
- if(strcmp(dep->name, pkgname) == 0) {
+ satisfies = alpm_depcmp(pkg, dep);
+ free(dep);
+ if(satisfies) {
alpm_list_t *reqs = alpm_pkg_get_requiredby(pkg);
-
- if(!alpm_list_find_str(reqs, cachepkgname)) {
- _alpm_log(PM_LOG_DEBUG, _("adding '%s' in requiredby field for '%s'"),
- cachepkgname, pkg->name);
- reqs = alpm_list_add(reqs, strdup(cachepkgname));
- pkg->requiredby = reqs;
- }
+ _alpm_log(PM_LOG_DEBUG, _("adding '%s' in requiredby field for '%s'"),
+ cachepkgname, pkg->name);
+ reqs = alpm_list_add(reqs, strdup(cachepkgname));
+ pkg->requiredby = reqs;
+ break;
}
-
- /* check for provisions as well */
- for(k = alpm_pkg_get_provides(pkg); k; k = k->next) {
- const char *provname = k->data;
- if(strcmp(dep->name, provname) == 0) {
- alpm_list_t *reqs = alpm_pkg_get_requiredby(pkg);
-
- if(!alpm_list_find_str(reqs, cachepkgname)) {
- _alpm_log(PM_LOG_DEBUG, _("adding '%s' in requiredby field for '%s' (provides: %s)"),
- cachepkgname, pkgname, provname);
- reqs = alpm_list_add(reqs, strdup(cachepkgname));
- pkg->requiredby = reqs;
- }
- }
- }
- free(dep);
}
}
}